0
votes

Trying to get String labels to render on the x axis of my bar chart. Just not appearing. Below is the code snippet. Everything is rendering fine except the labels not showing up. I've tried setting the below and still nothing.

 xAxis.setDrawLabels(true);

...

entries.add(new BarEntry((float) e.getX(), ((float) e.getY()),labels));
}
    BarDataSet set1;

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

        ArrayList<Integer> colors = new ArrayList<Integer>();

        for (int c : ColorTemplate.VORDIPLOM_COLORS)
            colors.add(c);

        for (int c : ColorTemplate.JOYFUL_COLORS)
            colors.add(c);

        for (int c : ColorTemplate.COLORFUL_COLORS)
            colors.add(c);

        for (int c : ColorTemplate.LIBERTY_COLORS)
            colors.add(c);

        for (int c : ColorTemplate.PASTEL_COLORS)
            colors.add(c);

        colors.add(ColorTemplate.getHoloBlue());

        set1.setColors(colors);

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

        BarData data = new BarData(dataSets);
        data.setValueTextSize(50f);
        data.setValueTextColor(Color.WHITE);
        data.setValueTypeface(mTfLight);
        data.setBarWidth(0.9f);

        mChart.setData(data);
1

1 Answers

-1
votes

So, I ended up answering my own question. Using the below I was able to get the values to render. Still some issues with positioning but at least they are appearing.

mChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(labels));