android - How to create a BarChart with grouped bars with MPAndroidChart? -
how can compare 2 set of data using barchart
of mpandroidchart.
i edited code, sample project in github. how can put 100f , 110f
value in 1 xaxis
label whole number
score score1 = new score(100f, 0, "whole number"); mrealm.copytorealm(score1); score score2 = new score(110f, 0, "whole number"); mrealm.copytorealm(score2);
yes, can done quite easily.
what need barchart
multiple bardatasets
each set (in case) represents 1 sex (men or women).
- here example of how create barchart multiple datasets
- here tutorial of how use mpandroidchart realm.io
example code (without realm.io)
list<string> xvalues = ...; // "denmark", "finland", ... xaxis xaxis = chart.getxaxis(); xaxis.setvalueformatter(new myvalueformatter(xvalues)); // create 2 datasets bardataset set1 = new bardataset(valuesmen, "men"); set1.setcolor(color.blue); bardataset set2 = new bardataset(valueswomen, "women"); set2.setcolor(color.red); bardata data = new bardata(set1, set2); chart.setdata(data); chart.groupbars(...); // available since release v3.0.0 chart.invalidate(); // refresh
if need further assistance, here detailed tutorial on grouped barchart
available on wiki.
if want "stack" values in barchart
above each other, need create stacked-barchart: android stacked bars chart
Comments
Post a Comment