Skip to content

Commit e17a09b

Browse files
Feature/area chart start (#43)
* add `start` to `AreaChart`
1 parent fbcd7db commit e17a09b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ See [Common Props](#common-props)
141141
| Property | Default | Description |
142142
| --- | --- | --- |
143143
| renderLineGradient | undefined | The same as `renderGradient` but for the line in the chart |
144+
| start | 0 | The value of which the area should start (will always end on the data point) |
144145

145146
### StackedAreaChart
146147

src/area-chart.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class AreaChart extends PureComponent {
2424

2525
const {
2626
dataPoints,
27+
start,
2728
animate,
2829
animationDuration,
2930
style,
@@ -72,7 +73,7 @@ class AreaChart extends PureComponent {
7273

7374
const area = shape.area()
7475
.x((d, index) => x(index))
75-
.y0(y(0))
76+
.y0(y(start) || y(0))
7677
.y1(d => y(d))
7778
.defined(value => typeof value === 'number')
7879
.curve(curve)
@@ -156,6 +157,7 @@ AreaChart.propTypes = {
156157
renderLineGradient: PropTypes.func,
157158
curve: PropTypes.func,
158159
renderGrid: PropTypes.func,
160+
start: PropTypes.number,
159161
}
160162

161163
AreaChart.defaultProps = {

0 commit comments

Comments
 (0)