|
Set YAxis2 on XYChart to 0-100 range |
Posted by AlanW on Jul-22-2014 23:04 |
|
Hi,
I am adding a linelayer to a XYChart and want it to use the YAxis2 as I am overlaying in
on a barlayer whihc is using the main y-axis. The values I am plotting in the linelayer are
actually percentages so I would like to fix the Y-axis2 to have a range of 0-100 no matter
what the values being charted are. At the moment the graph scales the Yaxis2 labels as per
the values being plotted.
The general flow of my code is:
my $c = new XYChart( 1200, 475, 0xffffc0, 0x000000 );
$lineLayer = $c->addLineLayer( [@pastVal], 0x000000, "% vals");
$lineLayer->setUseYAxis2();
$c->yAxis()->setLabelFormat("{value}")
$layer = $c->addBarLayer2( $perlchartdir::Stack, 0 );
$layer->addDataSet( [@pastCnts], 0xdddd00, "Warnings" )
I want YAxis2 to be labeled from 0-100 no matter what values are in @pastVal. The values
are guartantted to be less than or equal 100. Is there a way of doing this?
Thanks
Alan |
Re: Set YAxis2 on XYChart to 0-100 range |
Posted by Peter Kwan on Jul-22-2014 23:42 |
|
Hi AlanW,
Yes. You can use Axis.setLinearScale to configure the axis scale. For example:
#From 0 to 100, with a label every 10 units
$c->yAxis2()->setLinearScale(0, 100, 10);
Hope this can help.
Regards
Peter Kwan |
Re: Set YAxis2 on XYChart to 0-100 range |
Posted by AlanW on Jul-24-2014 22:36 |
|
Spot on. Works perfectly. Thanks. |
|