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
Custom Labels on Axis
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Custom Labels on Axis
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?
Thanks in advance.
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);
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 21
- Joined: Tue Nov 15, 2011 12:00 am
Re: Custom Labels on Axis
Using your code example it works perfect.
Thanks very much!
Steven.
Thanks very much!
Steven.