Reputation: 1
English isn't my first language. So, Please excuse me if I'm not so clear, feel free to ask details.
I'm having the same problem as in this post: MPAndroidChart BarChart xValues Issue
In a barchart with 2 series xVals labels aren't displayed correctly, here are some test cases:
case 1
xVals = from 1 (index 0) to 30 (index 29) (days in a month, say april)
set1 = 3 values for 3 days (10,17,22): a.e. barentry(100,10), barentry(200,17), barentry(300,22)
set2 = 3 values for 3 days (4,11,18): a.e. barentry(100,4), barentry(200,11), barentry(300,18)
in this case the barchart
displays bars and xvals labels as independent, any bar is below his xvals label
case 2
xVals = from 1 (index 0) to 30 (index 29) (days in april)
set1 = as previous but added 0 values with set2 index : a.e. barentry(0,4), barentry(100,10), barentry(0,11),barentry(200,17), barentry(0,18), barentry(300,22)
set2 = as previous but added 0 values with set1 index : a.e. barentry(100,4), barentry(0,10), barentry(200,11),barentry(0,17), barentry(300,18), barentry(0,22)
in this case the barchart
displays bars and xvals labels as independent, any bar is below his xvals label
case 3
xVals = from 1 (index 0) to 30 (index 29) (days in april)
set1 filled with 0 for everyday barentry(0,[0 to 29]), then added values for 3 days (10,17,22): barentry(0,10)....
set2 filled with 0 for everyday barentry(0,[0 to 29]), then added values for 3 days (4,11,18): barentry(0,4)....
in this case I can see every bar in the right place with relative xvals label but it's horrible to see all these 0s!
Please take note that if in case 1 I don't add set2 (so a simple barchart with 1 series) everything it's ok without the need 0 values.
The question is: How can I get rid of the 0 values where not needed (as in example in days 1 to 3 and so on)?
Thanks in advance
Edit:
PFA screenshots, both are the same graph the only difference are sets with/without all days value.
The code is same from multidataset example and it works fine for every graph.
Only days with data: http://mysite.altervista.org/temp/some.png
All days: http://mysite.altervista.org/temp/all.png
Upvotes: 0
Views: 472
Reputation: 51421
For getting rid of the zeroes, use the ValueFormatter, and return an empty string whenever the value is zero.
Concerning the issue with the x-labels: I'm not sure what the issue is here.
The chart does only dispalys as many x-values as there is space on the screen. The position of the x-labels depends on their position in the xvalues-array, and is independent from the position of your entries.
If you zoom in, all x-values should appear.
Upvotes: 0