I am using MPAndroidChart to create grouped Dataset, but it is showing an error BarData data = new BarData(labels,dataSets );
at this line that is Unable to resolve constructor,BarData(java.util.ArrayList)<java.lang.String>,java.util.ArrayList<com.github.mikephil.charting.data.BarDataSet;>
I have also casted IBarDataSet
then the Application is getting Unfortunately Stopped
. I have used dependency compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
. Somebody Please help me!!
//create BarEntry for group 1
ArrayList<BarEntry> group1 = new ArrayList<>();
group1.add(new BarEntry(4f, 0));
group1.add(new BarEntry(8f, 1));
group1.add(new BarEntry(6f, 2));
group1.add(new BarEntry(12f, 3));
group1.add(new BarEntry(18f, 4));
group1.add(new BarEntry(9f, 5));
// create BarEntry for group 2
ArrayList<BarEntry> group2 = new ArrayList<>();
group2.add(new BarEntry(6f, 0));
group2.add(new BarEntry(7f, 1));
group2.add(new BarEntry(8f, 2));
group2.add(new BarEntry(12f, 3));
group2.add(new BarEntry(15f, 4));
group2.add(new BarEntry(10f, 5));
// creating dataset for group1
BarDataSet barDataSet1 = new BarDataSet(group1, "Brand 1");
barDataSet1.setColors(ColorTemplate.COLORFUL_COLORS);
// creating dataset for group2
BarDataSet barDataSet2 = new BarDataSet(group2, "Brand 2");
barDataSet2.setColors(ColorTemplate.COLORFUL_COLORS);
// combined all dataset into an arraylist
ArrayList<BarDataSet> dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
dataSets.add(barDataSet2);
ArrayList<String> labels = new ArrayList<>();
labels.add("JAN");
labels.add("FEB");
labels.add("MAR");
labels.add("APR");
labels.add("MAY");
labels.add("JUN");
BarData data = new BarData(labels,dataSets );// initialize the Bardata with argument labels and dataSet
barChartGroup.setData(data);
I want to get the dataset like the following example : -
Thanks!!