Custom Labels on Axis

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
froggyware
Newbie
Newbie
Posts: 21
Joined: Tue Nov 15, 2011 12:00 am

Custom Labels on Axis

Post by froggyware » Fri Feb 17, 2012 3:02 pm

Hi,

I'm attempting to create a custom label on an Axis but I am unable to format the label in any way. (Using Java for Android). For example:

chart.getAxes().getLeft().getLabels().getItems().clear();
for(int i = 0; i < chart.getAxes().getLeft().getMaximum()+2; i ++) {
chart.getAxes().getLeft().getLabels().getItems().add((double)i,i+"");
chart.getAxes().getLeft().getLabels().getItems().getItem(i).setColor(Color.WHITE); // NO EFFECT
}
chart.getAxes().getLeft().getLabels().getFont().setSize(13); // NO EFFECT
chart.getAxes().getLeft().getLabels().getFont().setColor(Color.WHITE);
chart.getAxes().getLeft().getLabels().getFont().setName("Arial");


The above creates the customer Label, But I am completely unable to set the font size, color, etc. It simply does not work. Everything remains at the default values.

What am I doing wrong?

thx.
Steven

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Custom Labels on Axis

Post by Narcís » Mon Feb 20, 2012 12:19 pm

Hi Steven,

It works fine for me here doing as in the the addCustomLabels below. Can you please check if it works fine at your end?

Code: Select all

    protected void addCustomLabels() {
        Axis axis = tChart1.getAxes().getLeft();
        AxisLabelsItems items = axis.getCustomLabels();
        //remove all custom labels
        items.clear();
        //add custom labels
        AxisLabelItem item;
        item = items.add(123.0, "Hello");
        item.getFont().setSize(16);
        item = items.add(466.0, "Good\nBye");
        item.setTransparent(false);
        items.add(300);
        item = items.add(-100);
        item.setTransparent(false);
        item.setTransparency(50);
        item.setColor(Color.BLUE);
    }
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

froggyware
Newbie
Newbie
Posts: 21
Joined: Tue Nov 15, 2011 12:00 am

Re: Custom Labels on Axis

Post by froggyware » Mon Feb 20, 2012 12:46 pm

Using your code example it works perfect.

Thanks very much!

Steven.

Post Reply