indiespirit / react-native-chart-kit

📊React Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)
https://expo.io/@indiespirit/react-native-chart-kit
MIT License
2.84k stars 659 forks source link

Duplicate Y-Axis Labels #613

Open bwjohns4 opened 2 years ago

bwjohns4 commented 2 years ago

Has anyone encountered this issue where there are duplicate Y axis labels?

image
moisfelix commented 2 years ago

Yes, me. Basically this are not duplicated, if you set decimals to 1 or 2 you will see in fact are different values. But if y values are in fact 1,7 and 2.4 both values are rounded at 2.

bwjohns4 commented 2 years ago

Interesting. My application only uses whole numbers. Is there a way to set this up so that it does not show y-axis increments of less than a whole number increment?

I'm already using: yAxisInterval={1}

BuniEmris commented 2 years ago

@bwjohns4 I also faced issue. the problem was as there are 5 lines of Y axis,all given data value will fill these lines my initial value is set to zero : fromZero={true} , if max value is less than 4 , the other values will be duplicated to fill 5 lines, so the solution is you need also give max value like this: fromNumber={Math.max(...arrdata) > 4 ? Math.max(...arrdata) : 4 }

Screen Shot 2022-07-24 at 20 44 05

if data value is higher than 4 then it draw like this:

Screen Shot 2022-07-24 at 20 44 59 Screen Shot 2022-07-24 at 20 48 55
Girishav commented 2 years ago

@BuniEmris Thank you for above solution. I had similar issue and suggesstions worked like a charm.

ZainAliSyed24 commented 10 months ago

@bwjohns4 I also faced issue. the problem was as there are 5 lines of Y axis,all given data value will fill these lines my initial value is set to zero : fromZero={true} , if max value is less than 4 , the other values will be duplicated to fill 5 lines, so the solution is you need also give max value like this: fromNumber={Math.max(...arrdata) > 4 ? Math.max(...arrdata) : 4 } Screen Shot 2022-07-24 at 20 44 05 if data value is higher than 4 then it draw like this: Screen Shot 2022-07-24 at 20 44 59 Screen Shot 2022-07-24 at 20 48 55

Thanks @BuniEmris It works for me

TrevorGarnett commented 5 months ago

I am having the same issue for a LineChart. If I allow it to show more decimal places, it shows {1,1.5,2,2.5,3}. Is there a similar solution for a LineChart? LineCharts unfortuantely don' thave "showBarTops" property.

IMG_366C560338BA-1