Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shape] pass d3 accessor arguments to the x and y props of LinePath, AreaClosed, and LinePath #295 #309

Merged
merged 1 commit into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/vx-shape/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ AreaClosed is a closed area under a curve.

| Name | Default | Type | Description |
|:--------------- |:------------------- |:-------- |:----------------------------------------------------------------------------------------------------------- |
| x | | function | A function that takes in a data element and returns the x value. |
| y | | function | A function that takes in a data element and returns the y value. |
| x | | function | The d3 [x function](https://github.com/d3/d3-shape#area_x). |
| y | | function | The d3 [y1 function](https://github.com/d3/d3-shape#area_y1). |
| xScale | | function | A [scale function](https://github.com/hshoff/vx/tree/master/packages/vx-scale) for the xs. |
| yScale | | function | A [scale function](https://github.com/hshoff/vx/tree/master/packages/vx-scale) for the ys. |
| data | | array | An array of x and y data. |
Expand Down Expand Up @@ -189,16 +189,16 @@ A more complicated line path. A `<LinePath />` is useful for making line graphs
| data | | array | The data in x, y. |
| xScale | | function | A [scale function](https://github.com/hshoff/vx/tree/master/packages/vx-scale) for the xs. |
| yScale | | function | A [scale function](https://github.com/hshoff/vx/tree/master/packages/vx-scale) for the ys. |
| x | | function | A function that takes in a data element and returns the x value. |
| y | | function | A function that takes in a data element and returns the y value. |
| x | | function | The d3 [x function](https://github.com/d3/d3-shape#line_x). |
| y | | function | The d3 [y function](https://github.com/d3/d3-shape#line_y). |
| defined | | function | A [function](https://github.com/d3/d3-shape/blob/master/README.md#line_defined) called by `line.defined()`. |
| className | | string | The class name for the `path` element. |
| stroke | steelblue | string | The color of the stroke. |
| strokeWidth | 2 | number | The pixel value for the stroke. |
| strokeDasharray | | array | The [pattern of dashes](https://mzl.la/1l7EiTQ) in the stroke. |
| fill | none | string | The color of the fill for the `path` element. |
| curve | Curve.linear | function | The [curve function](https://github.com/hshoff/vx/tree/master/packages/vx-curve) |
| glyph | | glyph | [A glyph](https://github.com/hshoff/vx/tree/master/packages/vx-glyph) to be added to the line. |
| glyph | | glyph | [A glyph](https://github.com/hshoff/vx/tree/master/packages/vx-glyph) to be added to the line. |

## `<LineRadial />`

Expand Down
12 changes: 6 additions & 6 deletions packages/vx-shape/src/shapes/Area.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export default function Area({
...restProps
}) {
const path = area();
if (x) path.x(d => xScale(x(d)));
if (x0) path.x0(d => xScale(x0(d)));
if (x1) path.x1(d => xScale(x1(d)));
if (y) path.y(d => yScale(y(d)));
if (y0) path.y0(d => yScale(y0(d)));
if (y1) path.y1(d => yScale(y1(d)));
if (x) path.x((...args) => xScale(x(...args)));
if (x0) path.x0((...args) => xScale(x0(...args)));
if (x1) path.x1((...args) => xScale(x1(...args)));
if (y) path.y((...args) => yScale(y(...args)));
if (y0) path.y0((...args) => yScale(y0(...args)));
if (y1) path.y1((...args) => yScale(y1(...args)));
if (defined) path.defined(defined);
if (curve) path.curve(curve);
if (children) return children({ path });
Expand Down
4 changes: 2 additions & 2 deletions packages/vx-shape/src/shapes/AreaClosed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default function AreaClosed({
...restProps
}) {
const path = area()
.x(d => xScale(x(d)))
.x((...args) => xScale(x(...args)))
.y0(yScale.range()[0])
.y1(d => yScale(y(d)))
.y1((...args) => yScale(y(...args)))
.defined(defined);
if (curve) path.curve(curve);
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/vx-shape/src/shapes/LinePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default function LinePath({
...restProps
}) {
const path = line()
.x((d, i) => xScale(x(d, i)))
.y((d, i) => yScale(y(d, i)))
.x((...args) => xScale(x(...args)))
.y((...args) => yScale(y(...args)))
.defined(defined)
.curve(curve);
if (children) return children({ path });
Expand Down