I have been trying to figure out and have read many post. but i am unable to set labels to xaxis in Bar Chart of MPAndroid. currently it is showing the position of the bar.
1
votes
2 Answers
1
votes
0
votes
- Step 1 : Initialize x axis like this = in global = ArrayList xaxis0
Initialize xaxis0 = new ArrayList<>(); Step 2 : After that if you have arraylist strings of data.Then start loop add all strings into the x axis values like below code
for (int i = 0; i < xdata.size(); i++) { * xaxis0.add(i, xdata.get(i).get("date")); int data222 = Integer.parseInt(str); BarEntry v1e11 = new BarEntry(data222, i); } BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Top 5 deals"); barDataSet1.setColors(whitecolors); barDataSet1.setHighLightColor(Color.GREEN); barDataSet1.setBarSpacePercent(60f); barDataSet1.setValueTextColor(Color.WHITE); dataSets = new ArrayList<>(); dataSets.add(barDataSet1); *BarData data11 = new BarData(xaxis0, dataSets); data11.setValueFormatter(new LargeValueFormatter()); data11.setGroupSpace(100f); holder.chart.setData(data11);That's its ...