android - How to create a BarChart with grouped bars with MPAndroidChart? -


how can compare 2 set of data using barchart of mpandroidchart.

it should image below: enter image description here

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).

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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -