android - How to set legend labels MPChart -
i trying customize legend not able so.my purpose give different legend labels.i ma using mpchart library so.
arraylist<barentry> entries = new arraylist<>(); entries.add(new barentry(4f, 0)); entries.add(new barentry(8f, 1)); entries.add(new barentry(6f, 2)); entries.add(new barentry(12f, 3)); entries.add(new barentry(18f, 4)); mcolors.add(r.color.red); mcolors.add(r.color.text_color_gray); mcolors.add(r.color.text_color_blue); mcolors.add(r.color.green); mcolors.add(r.color.black); bardataset dataset = new bardataset(entries, null); arraylist<string> labels = new arraylist<string>(); labels.add("05"); labels.add("06"); labels.add("07"); labels.add("08"); labels.add("09"); bardata data = new bardata(labels, dataset); legend legend = mchart.getlegend(); legend.setenabled(true); legend.setposition(legend.legendposition.below_chart_center); legend.setform(legend.legendform.square); legend.setcolors(mcolors); legend.setlabels(mlabels); mchart.setdata(data); mchart.animatey(2000); limitline line = new limitline(10f); yaxis yaxis = mchart.getaxisleft(); yaxis.addlimitline(line); yaxis.setdrawaxisline(true); mchart.setdrawvalueabovebar(true); mchart.setdrawbarshadow(false); mchart.setvisiblexrange(4); mchart.moveviewtox(2); mchart.setdrawvalueabovebar(false); mchart.invalidate();
please let me know solution this.
if want have 4 legend labels, need 4 bardataset objects.
having different colours group different colours on 1 legend generated.
and need pass colors dataset , mapped legend.
finally, datasets need label used legend. can specify label second parameter in constructor.
Comments
Post a Comment