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.
Asked
Active
Viewed 1,783 times
2 Answers
1
It is difficult to answer without your work samples , try this, it may help you
// Plotting Data
ArrayList<BarEntry> XValues = new ArrayList<>();
BarEntry v1e1 = new BarEntry(110.000f, 0);
valueSet1.add(v1e1);
// Setting X label this way
BarDataSet set = new BarDataSet(XValues, "Age Distribution");

Vinod Kumar
- 337
- 5
- 19
-
Hi @Vinod Kumar , can you please answer my bounty question regarding xAxis labels https://stackoverflow.com/questions/55325511/mpandroid-chart-not-displaying-any-labels-for-xaxis-what-is-missing?noredirect=1#comment97407907_55325511 – Deep Shah Mar 27 '19 at 04:51
0
- 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 ...

George Udosen
- 906
- 1
- 13
- 28

Venkatesh
- 1,034
- 13
- 25