I have spend a lot of time but can not find answer . I have a line graphics from 40 to 120 points. Each of the point has time. I wanted to show on Xaxis only points which have 0:00 or 12:00 time.
combinedChart.setData(prepareHistoryHour(photo_data)); combinedChart.fitScreen(); combinedChart.getXAxis().setAxisMinimum(0); combinedChart.getXAxis().setGranularity(1); combinedChart.getXAxis().setGranularityEnabled(true); combinedChart.getXAxis().setLabelCount(72); combinedChart.getXAxis().setTextSize(14f); combinedChart.setVisibleXRangeMaximum(72); combinedChart.setMaxVisibleValueCount(700); combinedChart.getLineData().setDrawValues(true); combinedChart.getXAxis().setValueFormatter(new ValueFormatter() { @Override public String getFormattedValue(float value) { Log.d("WHS xaxis", String.valueOf(value)); long time=dc_forecastHourList.get((int)value).getDT_withOffset(); String s=new SimpleDateFormat("HH").format(new Date(time*1000L)); if (Integer.parseInt(s) ==0){ return new SimpleDateFormat("MMdd").format(new Date(time*1000L)); } if (Integer.parseInt(s) %12==0){ return new SimpleDateFormat("HH").format(new Date(time*1000L))+":00"; } return ""; } }); But ValueFormatter is called not for all points. It was call with skip different intervals..
Logs: for example
D/WHS xaxis: 24.0 D/WHS xaxis: 27.0 D/WHS xaxis: 30.0 D/WHS xaxis: 33.0 D/WHS xaxis: 36.0 As a result I cannot show correct values on Xaxis. Thank you for help!
https://stackoverflow.com/questions/66512806/mpandroidchart-xaxis-does-not-call-valueformatter-for-each-points March 07, 2021 at 11:02AM
没有评论:
发表评论