ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  change datacolors for z-axis of a surface plot
Posted by Michael Baacke on Jul-23-2009 21:53
Hi,

yesterday I purchased ChartDirector and I love it. It easily allows me to create impressive technical surface plots with logarithmic z-scaling and the best:  I do not have to step into deep graphic programming.

But now I have to change the datacolors in the z-axis and the legend and I think I'm "too stupid" to understand the documentation.

Please can you help me with a code snippet that substitutes 10 datacolors. Normally the colors start with blue and end with red when I create a surface chart from scratch.  But I need 10 totally different colors starting with white and ending in dark blue.

To your information: I'm actually modifing an older trechnical evaluation tool written in Visual Basic 6. The only thing - and then I can finish the work - is to change the colors.

Thanks in advance
and best regards

Michael Baacke

  Re: change datacolors for z-axis of a surface plot
Posted by Peter Kwan on Jul-24-2009 02:24
Hi Michael,

The API to use is ColorAxis.setColorGradient. For example:

'array of 10 colors
myColors = Array(&Hffffff, &Hccccff, .....)

'c = SurfaceChart object
Call c.colorAxis().setColorGradient(False, myColors)

Note that in the actual chart, if your z-axis only have 8 steps (eg. the z-axis labels are 0, 1, 2, 3, 4, 5, 6, 7, 8), ChartDirector will interpolate the 10 colors to get the 8 colors for the 8 steps. See the documentation on ColorAxis.setColorGradient for the details. (You may look for ColorAxis.setColorGradient in the documentation index.)

If you want to ensure the z-axis has exactly 10 steps, you can set it using Axis.setLinearScale. For example:

Call c.zAxis().setLinearScale(0, 100, 10)

Hope this can help.

Regards
Peter Kwan

  Re: change datacolors for z-axis of a surface plot
Posted by maloin56 on Aug-20-2012 21:15
Hi,

I would like to change the color pallette for coloring the surface plot but I can not do it. My image is all black.

I show you my code in PHP :

$vmin=965;
$vmax=1045;
$pas=5;

$c = new XYChart(600, 520);
$c->setPlotArea(0, 0, 600, 520, -1, -1, -1, 0xc0000000, -1);
$layer = $c->addContourLayer($dataX, $dataY, $dataZ);
$cAxis=$layer->colorAxis->setColorGradient(false, array("0xc000000", "0xcffffff"));
$cAxis = $layer->setColorAxis(300, 490, TopCenter, 250, Top);
$cAxis->setLinearScale($vmin, $vmax, $pas);

$c->xAxis->setLinearScale(0, 600, 5);
$c->yAxis->setLinearScale(0, 520, 5);
$c->makeChart("pressiona.png");

I have an error in this line?
$cAxis=$layer->colorAxis->setColorGradient(false, array("0xc000000", "0xcffffff"));

When I remove this line, I get the basic coloring.

Thank you in advance for your help.

  Re: change datacolors for z-axis of a surface plot
Posted by Peter Kwan on Aug-20-2012 23:13
HI maloin56,

ChartDirector colors are numbers, like 0xc000000, not "0xc000000". If you use double quotes, it is not a number, but a text string. According to PHP standard, "0xc0000000", if coerced into a number, is equal to 0. So it is equivalent to 0x00000000, which is the black color. The correct code should be:

$cAxis = $layer->setColorAxis(300, 490, TopCenter, 250, Top);
$cAxis->setColorGradient(false, array(0xc000000, 0xcffffff));

In the above code, the gradient should change from black 0xc000000 to white 0xcffffff. There should be a little bit of transparency (transparency level is 0xc).

Hope this can help.

Regards
Peter Kwan

  Re: change datacolors for z-axis of a surface plot
Posted by maloin56 on Aug-24-2012 05:58
Hi Peter,

Thank you very much, it works. Another question. I looked in the manual, I did not find the possibility of putting values ​​along isoline. It is not possible?

According to the value, I would have liked to isolines of different thicknesses, but I don't think it is possible too.

Thank You

J?r?me

  Re: change datacolors for z-axis of a surface plot
Posted by Peter Kwan on Aug-25-2012 00:23
Hi maloin56,

Unluckily, ChartDirector cannot automatically put text on the isolines.

You can, however, use isolines of different thicknesses or colors. This is by applying Axis.addMark to the color axis.

//make the isoline z = 6 three pixels thick.
$cAxis->addMark(6, 0x000000)->setLineWidth(3);

Hope this can help.

Regards
Peter Kwan