Page 1 of 1

How to insert gap between legend value and text

Posted: Wed Aug 31, 2016 3:14 pm
by 17079028
In the legend (on android), is there a way to add a gap between the value and the text? Manually addind a space as the first character in the text leads to a legend that shows some of its text outside of its boundind box.

Re: How to insert gap between legend value and text

Posted: Thu Sep 01, 2016 11:34 am
by yeray
Hello,

You can play with the custom items in a similar way to this (the x and y positions aren't 100% correct):

Code: Select all

        int tmpX = metrics.widthPixels - 200;
        int tmpY = 200;

        tChart1.getLegend().getLegendItems().setCustom(true);
        tChart1.getLegend().getLegendItems().clear();
        for (int i = 0; i<tChart1.getSeries(0).getCount(); i++) {
            LegendItem tmpItem = new LegendItem(tChart1.getLegend());
            tChart1.getLegend().getLegendItems().setLegendItem(tmpItem);

            tmpItem.setFText(String.valueOf(tChart1.getSeries(0).getYValues().getValue(i)));
            tmpItem.setFText2(tChart1.getSeries(0).getLabels().getString(i));
            tmpItem.setAlign(StringAlignment.CENTER);
            tmpItem.setTop(tChart1.getLegend().getTop() + i*20);
            tmpItem.setLeft(tmpX);
            tmpItem.setSymbolRect(new Rectangle(tmpItem.getLeft() + 2, tmpY + i*20, 20, 20));
        }