|
Linear scale axis : ticks at predefined values |
Posted by Jacques on Jan-30-2015 03:29 |
|
Hello,
I use a contour chart to display temperature (and wind) forecast in fonction of altitude and
time for a given place.
For the altitude, i use currently in Y axis a linear scale from 0 to 5000 m, with one tick every
500 m :
$c->yAxis->setLinearScale(0, 5000,500); see Chart1.png.
Instead of starting ? 0, I prefer starting at the altitude of the place for which the
forecast is established.
For example, with a start altitude of 390 m :
$c->yAxis->setLinearScale(390, 5000,500); see Chart2.png
What I would like is to have, in Chart2.png, the first tick at 500 (instead of 400), and then
the next ticks as in Chart1.png : at 1000, 1500, 2000 ...etc
... but I have not found how to do it.
Any suggestion would be appreciated
|
Re: Linear scale axis : ticks at predefined values |
Posted by Peter Kwan on Jan-31-2015 00:19 |
|
Hi Jacques,
The exact code depends on exactly what you need. If you want ChartDirector to
automatically scale the y-axis, but does not extend the y-axis to the "next tick position",
you may use:
#do not "round" the axis scale at the lower limit
$c->yAxis->setRounding(false, true);
For example, if your original data are from 390 to 5200, ChartDirector may end up with the
scale of 390 to 5500 and the labels at 500, 1000, 1500, .... Note that the upper limit is
extended to 5500, while the lower limited is not extended. If there is no setRounding (the
default), the lower limit will be extend to 0 (the "next tick position").
If you do not want auto-scaling, but would like to specify the scale and labels completely,
you may use:
#axis scale from 390 to 5500 with no labels
$c->yAxis->setLinearScale2(390, 5000, array());
#add the labels at the desired positions
for ($i = 500; $i <= 5000; $i += 500)
$c->yAxis->addLabel($i, $i);
Hope this can help.
Regards
Peter Kwan |
Re: Linear scale axis : ticks at predefined values |
Posted by Jacques on Jan-31-2015 02:05 |
|
Many thanks Peter.
Using setLinearScale2() and adding the labels at desired position was best for me. |
|