react-native-chart icon indicating copy to clipboard operation
react-native-chart copied to clipboard

Vertical axis is very wrong on line chart

Open laura-chacon opened this issue 8 years ago • 6 comments

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: progression1 In the progression variable, the highest value is 10 but in the chart the highest value is 5.

Thank you.

laura-chacon avatar Aug 08 '16 10:08 laura-chacon

+1, any updates on this issue?

vtam311 avatar Sep 12 '16 22:09 vtam311

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.

vtam311 avatar Sep 12 '16 23:09 vtam311

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 avatar Oct 19 '16 14:10 drpiou

@drpiou would you mind sharing with us your fork or more information on how to achieve this? Thank you!

skleest avatar Oct 31 '16 23:10 skleest

@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;.

drpiou avatar Nov 01 '16 19:11 drpiou

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.

tomauty avatar Jul 07 '17 20:07 tomauty