Arnab Kundu
Arnab Kundu

Reputation: 1527

MP Android Chart barchart

enter image description here

How to date text for each bar indicator in MP Android chart.I have tried this. I'm not getting any option to set individual bar indicator settext properties

   private void plotData1(ArrayList<BarEntry> yVals1) {
    BarDataSet set1;

    if (mChart.getData() != null && mChart.getData().getDataSetCount() > 0) {
        set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
        set1.setValues(yVals1);
        mChart.getData().notifyDataChanged();
        mChart.notifyDataSetChanged();
    } else {
        set1 = new BarDataSet(yVals1, "Data Set");


        set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set1.setDrawValues(true);//give values at the top of bar

        ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
        dataSets.add(set1);

        BarData data = new BarData(dataSets);
        mChart.setData(data);
        mChart.setFitBars(true);
    }
}

Upvotes: 0

Views: 1711

Answers (1)

R. Zag&#243;rski
R. Zag&#243;rski

Reputation: 20278

You need to have separate DataSet's for each color.

Create set1, set2, set3 and so on, then pass them all to dataSets variable.

An example BarChartActivityMultiDataset from the official examples can be found here.

Upvotes: 3

Related Questions