|
X-Axis labels: Can I force label at last (right) value? |
Posted by John I on Feb-22-2012 02:46 |
|
Hi Peter -
This may have been asked before and I don't know the terms to search on.
(I'm using the Perl version but can translate)
What I'm dealing with is standard x/y line chart data with a time/date X-axis, and I need to
force a label on the far-right (oldest/last) tick. I can do it easily with simple division using
setLabelStep against a known data set size, but if it's variable then no go there.
What I'd envisioned is a method to force the X-axis labels to "align" from the right so that
the last instance gets a label, then increments to the left using the setLabelStep values.
This leaves the left-most likely without a label, but that is acceptable.
Obviously, if I could get a right-most AND a left-most label, that's bonus points!
Is there a setLabelxxx method that could do this? All the documentation examples use fixed
data set size, so you ALWAYS get first/last labels there - but that's cheating! hehe
Can this be done? If it's already discussed, can someone point me to that discussion
please?
Thanks!
|
Re: X-Axis labels: Can I force label at last (right) value? |
Posted by Peter Kwan on Feb-23-2012 01:08 |
|
Hi John,
The setLabelStep allows you to provide an initial offset for the first label. You can always set the offset to ($noOfLabels - 1) % $labelStep, so that there is a label on the last value. For example:
$c->xAxis()->setLabelStep($labelStep, 0, ($noOfLabels - 1) % $labelStep);
Hope this can help.
Regards
Peter Kwan |
Re: X-Axis labels: Can I force label at last (right) value? |
Posted by David S. on Mar-22-2012 02:03 |
|
Is there a way to do this on the linearmeter? setLabelStep doesn't seem to be available for basemeter. My first value of the meter is an odd-ball number and I'd like to have the scale show a normal set of intervals.
Thanks. |
Re: X-Axis labels: Can I force label at last (right) value? |
Posted by Peter Kwan on Mar-23-2012 00:40 |
|
Hi David,
The setLabelStep is for label based axis. For a linear meter, the scale is always a linear numeric. Instead of using setLabelStep, you may use setLinearScale and addLabel to configure the label positions. For example:
//scale from 33.53 to 100, with no ticks
c.setLinearScale(33.53, 100, Chart.NoValue);
//add labels at 100, 90, 80, .... 40
for (int i = 100; i >= 33.53; i -= 10)
c.addLabel(i, "" + i);
Hope this can help.
Regards
Peter Kwan |
Re: X-Axis labels: Can I force label at last (right) value? |
Posted by David S. on Mar-23-2012 20:39 |
|
Thanks Peter. |
|