|
Coloured Contour Lines |
Posted by Pete on Dec-08-2012 19:14 |
|
Hi Peter,
I am using Contour Maps often. I use these in both Gradient Fill with Contours and also
sometimes I transparent the Gradient Fill, so I am just seeing the Contour Lines.
In php I am using $layer->setContourColor(0xFF0000); in order to set the Colour of the
Contours.
Is there anyway to define the Contour Colours to be different for each value the lines
represent? Actually I would like them to be the same as the colours I have set for the
Gradient Fill, which I then make Transparent, so I will just see the relevant Coloured
Contour line.
Regards,
Pete |
Re: Coloured Contour Lines |
Posted by Peter Kwan on Dec-11-2012 01:13 |
|
Hi Pete,
You can use Axis.addMark to specify the color of each contour. For example:
#The contour at z = 6 should be in yellow 0xffff00
$myColorAxis->addMark(6, 0xffff00);
If you would like ChartDirector to automatically determine the contour levels and colors, and provides a color legend, you may try the following method:
(A) Create the contour layer as usual, with a transparent fill color.
(B) Create a second contour layer with no data (just use empty arrays as data). Configure the colorAxis of this second contour layer using the z data range from the first layer. The purpose of this second layer is to provide a non-transparent color legend and allow you to obtain the colors by given the z values.
$layer2 = $c->addContourLayer(array(), array(), array());
$cAxis2 = $layer2->setColorAxis(..... position to display the color legend ....);
$cAxis2->setLinearScale(min($dataZ), max(dataZ));
(C) Use addMark color the contours.
#layout the chart, so we can fix the color scale (determine color based on z value)
$c->layout();
$ticks = $cAxis->getTicks();
for ($i = 0; $i < count($ticks); ++$i)
$cAxis->addMark($ticks[$i], $cAxis2->getColor($ticks[$i]));
Hope this can help.
Regards
Peter Kwan |
|