How to insert gap between legend value and text

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
teechart_user
Newbie
Newbie
Posts: 1
Joined: Mon Aug 29, 2016 12:00 am

How to insert gap between legend value and text

Post by teechart_user » Wed Aug 31, 2016 3:14 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: How to insert gap between legend value and text

Post by Yeray » Thu Sep 01, 2016 11:34 am

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));
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply