Mpandroidchart Linechart: Using Dates Instead Of Strings For X-axis
MPAndroidChart LineChart by default accepts Strings for X-axis. Is there a way to set the Date as a datatype for the X-axis? The problem with just converting Date into strings is
Solution 1:
I found a thread on the project's gitHub ( https://github.com/PhilJay/MPAndroidChart/issues/12 ).
Apparently, this feature is not yet implemented.
Update
Doing a bit of search, I found this alternative library:
https://github.com/lecho/hellocharts-android
It supports values for x-axis.
UPDATE Since 2016, this feature has been included in MPAndroid. See https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartTime.java for an exapmle in the docs.
Solution 2:
You can make new array with full dates and fill empty positions with previous values. For example: you making an array may[31] for each day of may, initializate it with zeroes, and then do something like this:
may[1] = values[1];
for (int i = 2; i <= may.size(); ++i) {
if (may[i] == 0)
may[i] = may[i-1];
}
Post a Comment for "Mpandroidchart Linechart: Using Dates Instead Of Strings For X-axis"