How Do I Add X-axis Lables In Mpcharts For Barcharts
I was using an older version of MPCharts and in that it was working fine,but in 3.0.2,it seems to be a bit diferent,their wiki page isn't helping much. this is what i have ArrayLi
Solution 1:
For the BarChart, u can use this to set the labels in xAxis
XAxisxAxis= barChart.getXAxis();
xAxis.setValueFormatter(newIndexAxisValueFormatter(labels));
For more information, look on its description: IndexAxisValueFormatter
Solution 2:
you have to use the value formatter.
Add entries like this
ArrayList<BarEntry> entryList = new ArrayList<BarEntry>();
for (int i = 0; i < yourValues.length; i++) {
entryList.add(new BarEntry(i, yourValues[i]));
}
and set the value formatter for your chart
IAxisValueFormatterxAxisFormatter=newLabelFormatter(mChart);
XAxisxAxis= mChart.getXAxis();
xAxis.setValueFormatter(xAxisFormatter);
here is the LabelFormatter class:
publicclassLabelFormatterimplementsIAxisValueFormatter {
private labels[] = {"Jan", "Feb", ..... }
publicLabelFormatter(BarLineChartBase<?> chart) {
this.chart = chart;
}
@Overridepublic String getFormattedValue(float value, AxisBase axis) {
return label[(int)value];
}
}
you can check this class for more information.
Post a Comment for "How Do I Add X-axis Lables In Mpcharts For Barcharts"