Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Commit b28f1a0

Browse files
mlabrummarzolfb
authored andcommitted
Add min/max scale support to the y axis on the bar chart (#72)
1 parent e19c05a commit b28f1a0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Bar.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export default class BarChart extends Component {
5454
}
5555
},
5656
axisY: {
57+
min: false,
58+
max: false,
5759
showAxis: true,
5860
showLines: true,
5961
showLabels: true,
@@ -78,8 +80,9 @@ export default class BarChart extends Component {
7880
}
7981

8082
getMaxAndMin(values, scale) {
81-
let maxValue = 0
82-
let minValue = 0
83+
const axisY = this.props.options.axisY
84+
let maxValue = axisY.max || 0
85+
let minValue = axisY.min || 0
8386

8487
let max = _.max(values)
8588
if (max > maxValue) maxValue = max
@@ -106,7 +109,9 @@ export default class BarChart extends Component {
106109
gutter: this.props.options.gutter || 10,
107110
width: options.chartWidth,
108111
height: options.chartHeight,
109-
accessor: accessor
112+
accessor: accessor,
113+
min: this.props.options.axisY.min || undefined,
114+
max: this.props.options.axisY.max || undefined,
110115
})
111116

112117
let values = chart.curves.map((curve) => accessor(curve.item))

0 commit comments

Comments
 (0)