|
X Axis labels not showing the -ve sign |
Posted by Anthony Edwards on Mar-30-2010 23:12 |
|
Hi
For some strange reason my X axis isnt showing the -ve sign for the labels. ie rather than -5, 0, 5 its showing 5, 0, 5. Any ideas? Is there a global setting in java to display the -ve sign?
I'm doing c.xAxis().setLabels(labels); // labels is a String [] and correct
c.xAxis().setLabelStep(3,1); // to show every 3rd label ...
Thanks! |
Re: X Axis labels not showing the -ve sign |
Posted by Anthony Edwards on Mar-30-2010 23:33 |
|
Ive tried adding c.xAxis().setLabelFormat("{label}"); but that doesnt seem to make any difference. Have I missed anything? |
Re: X Axis labels not showing the -ve sign |
Posted by Peter Kwan on Mar-31-2010 03:10 |
|
Hi Anthony,
In setLabels, the leading "-" character is used to mean that the label will be associated with a minor tick. If you look at the ticks carefully, you can see some ticks are shorter than the other.
To display the leading "-", there are two methods:
(a) Use "\\-" as the first two characters. Note that in Java syntax, the "\\" would need to be represented as "\\\\" if it is hard coded in source code. For example:
for (int i = 0; i < myLabels.length; ++i)
if (myLabels[i].startsWith("-")) myLabels[i] = "\\\\" + myLabels[i];
(b) Use numbers instead of text strings.
double[] myLabels; //declare as array of numbers
c.xAxis().setLabels2(myLabels);
Hope this can help.
Regards
Peter Kwan |
Re: X Axis labels not showing the -ve sign |
Posted by Anthony Edwards on Mar-31-2010 15:33 |
|
Perfect - thanks for your help. That works a treat. |
|