react-native-chart
react-native-chart copied to clipboard
Vertical axis is very wrong on line chart
On OS X El Capitan version 10.11.5 (15F34)
node --version v6.0.0 nam --v v6.2.2 react-native-cli: 1.0.0 react-native: 0.28.0 watchman --v 4.5.0 xcode 7.3.1 react-native-chart: 1.0.8-beta
With this code:
progression = [ [1,0], [2, 10] ];
return (
<Chart
style={styles.chart}
data={progression}
showDataPoint={true}
color={colors.APP_COLOR}
axisColor={colors.BORDER_COLOR}
hideHorizontalGridLines={true}
hideVerticalGridLines={true}
dataPointFillColor={null}
dataPointColor={null}
xAxisHeight={50}
showXAxisLabels={true}
type="line"
/>);
I obtain a chart which is wrong in the vertical axis as you can see here:
In the progression variable, the highest value is 10 but in the chart the highest value is 5.
Thank you.
+1, any updates on this issue?
I've found a temporary workaround. The issue seems related to the value of verticalGridStep (defaulted to 4). When I set its value to (the number of unique y values - 1), it seems to work fine. This assumes that the result is greater than 0. If it is 0, I set it to 1 and that seems to work.
I confirm the Y-Axis is doing it wrong when multiple same values. I patched this in both Grid.js and yAxis.js by replacing the "unique" declaration by "const unique = data;", which take in consideration non unique values and scale everything perfectly. Tell me if I'm wrong, but this way I have no more problem.
@drpiou would you mind sharing with us your fork or more information on how to achieve this? Thank you!
@skleest I don't know how to fork something haha ^^'
Here is what I changed :
I replaced the Grid.js and yAxis.js in dist folder with those in src folder, then in both Grid.js and yAxis.js in the render method, I replaced const unique = uniqueValuesInDataSet(data);
with const unique = data;
.
As a generic FYI — I am no longer able to maintain this library. I recommend checking out victory-native as it's much more maintained.