0

I want to set my Bar-Data with two lines.

It's not possible to do it with \n.

I use MPAndroidChart Version v2.2.4.

I tried it with this code:

Bar1 = new BarEntry(20f,0,"20"+"\n"+"2");
Bar2 = new BarEntry(80f,1,"80"+"\n"+"8");
Bar3 = new BarEntry(60f,2,"60"+"\n"+"6");
Bar4 = new BarEntry(50f,3,"50"+"\n"+"5");
Bar5 = new BarEntry(70f,4,"70"+"\n"+"7");
Bar6 = new BarEntry(60f,5,"60"+"\n"+"6");

K1_barEntries = new ArrayList<>();

K1_barEntries.add(Bar1);
K1_barEntries.add(Bar2);
K1_barEntries.add(Bar3);
K1_barEntries.add(Bar4);
K1_barEntries.add(Bar5);
K1_barEntries.add(Bar6);

K1_barDataSet  = new BarDataSet(K1_barEntries,"");

K1_data = new BarData(labels, K1_barDataSet);
K1_barDataSet.setColors(ColorTemplate.COLORFUL_COLORS);

K1_barDataSet.setValueFormatter(new ValueFormatter() {
    @Override
    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
            return entry.getData().toString();
    }
});

Image

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Maho42
  • 1
  • 1

1 Answers1

1

This lib does not support break line with "\n"

Yıldırım
  • 757
  • 10
  • 24
  • Now I try it with the Version V3.0.3 but the problem is already the same. public class MyValueFormatter implements IValueFormatter { public MyValueFormatter() { mFormat = new DecimalFormat("###,###,##0.0"); // use one decimal } – Maho42 Nov 14 '18 at 20:32