Page 1 of 1

Custom Labels on Axis

Posted: Fri Feb 17, 2012 3:02 pm
by 17060769
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

Re: Custom Labels on Axis

Posted: Mon Feb 20, 2012 12:19 pm
by narcis
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.

Re: Custom Labels on Axis

Posted: Mon Feb 20, 2012 12:46 pm
by 17060769
Using your code example it works perfect.

Thanks very much!

Steven.