I am working on Mpandroidchart
. I have created a line chart and tried to place strings on my xaxis
.
final ArrayList<String> xAxisLabel = new ArrayList<>(Arrays.asList("March","April","May"));
private ArrayList<Entry> lineChartDataSet(){
ArrayList<Entry> dataSet = new ArrayList<Entry>();
dataSet.add(new Entry(1,40));
dataSet.add(new Entry(2,10));
dataSet.add(new Entry(3,15));
return dataSet;
}
lineDataSet = new LineDataSet(lineChartDataSet(),"data set");
XAxis xAxis = lineChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
//String setter in x-Axis
xAxis.setValueFormatter(new com.github.mikephil.charting.formatter.IndexAxisValueFormatter(xAxisLabel));
xAxis.setGranularity(1f);
xAxis.setGranularityEnabled(true);
Output
In the above image, you can see that month names are not properly placed. i.e march
is not displaying and only april
and may
are shown.
Expected Output
How can I do it?
Any help would be highly appreciated
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…