android - Formatting Dates on x-axis in MPAndroidChart -


i'm using mpandroidchart , know topic covered quite bit in docs, apologies if i've missed obvious, i'm having bit of trouble formatting timestamp values dates on x-axis of linechart.

it appears getformattedvalue() isn't being invoked x-axis value whatever reason. if debug axisbase, seems looking format y-axis values, not have custom formatter set on.

here code snippets, taken github docs:

          linechart chart = (linechart) findviewbyid(r.id.chart);           xaxis xaxis = chart.getxaxis();            // set min timestamp jul 2017            houraxisvalueformatter(long.parselong("1499814559"));            xaxis.setvalueformatter(new iaxisvalueformatter() {              // never invoked!             @override             public string getformattedvalue(float value, axisbase axis)              {                 return new date(long.parselong(""+value)).tostring();             }         });          // rating map of timestamp numeric value, both stored          // strings         (map.entry<string, string> rating : ratings.entryset()) {             string timestamp = rating.getkey();             string ratingvalue = rating.getvalue();             entries.add(new entry(float.parsefloat(timestamp),              float.parsefloat(ratingvalue)));         }              // add entries dataset             linedataset dataset = new linedataset(entries, "ratings");             linedata linedata = new linedata(dataset);             chart.setdata(linedata);             chart.invalidate(); // refresh' 

i'm using version 3.0.2 of library:

compile 'com.github.philjay:mpandroidchart:v3.0.2'

thanks in advance, gary

edit per request desired output/actual output: ideally have series of dates along x-axis , e.g. 10/7, 11/8, 12/8, etc. constructed epoch values i've provided. know code above wont format in format stands, want formatting date value (so ignore now), crux of issue formatter isn't getting invoked @ all.

below screenshot of current output, prints single value on x=0 line (note though there multiple y values being provided, wonder if on same x=0 line draw last point or something?):

enter image description here

debugging timestamp values above, float.parsefloat(timestamp) equal 1.50516885e^12. actual timestamp value example 1505168846751, after parsing float rounded, , given exponent value.

edit 2 :

screen grab of values supplied 'entries' linedataset:

enter image description here

edit 3: issue appears to size/format of timestamp values x-values i'm providing, changing these small float values in range 1.0 -> 20.0f, causes formatter invoked expected. need debug code further see why exponential timestamp values not being formatted.

from looking think limitation @ moment, specific use case (timestamps close together) since entry accept floating point values, timestamps getting passed 1.50516885e^12, though precise timestamp values different. when axisrenderer works out range x-axis sees 0, , sets entries 0 also, in block here


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -