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

Message ListMessage List     Post MessagePost Message

  Set color and threshold of z-axis data in surface chart
Posted by JS on Nov-20-2020 00:44
hello.

Currently I am drawing sensor data through a surface chart in .net, and there is a problem due to the current z-axis value setting.

I want to set the threshold and color of the z-axis value in the surface chart to the value I want.

but I don't know what to do

What should I do? please help me..

Thank you.

  Re: Set color and threshold of z-axis data in surface chart
Posted by JS on Nov-20-2020 07:10
Attachments:
ie)
wanna.png

  Re: Set color and threshold of z-axis data in surface chart
Posted by Peter Kwan on Nov-20-2020 17:27
Hi JS,

There are several coloring demonstrations for contour chart. The same method can work in SurfaceChart too with an additional line of code.

The following examples is based on C++. If you are using another programming language, please let me know.

https://www.advsofteng.com/doc/cdcpp.htm#contourcolor.htm
https://www.advsofteng.com/doc/cdcpp.htm#contourlegend.htm

For the surface chart, you need to add an additional line:

c->colorAxis()->syncAxis(c->colorAxis());

For your case, it seems your thresholds are not regularly spaced (eg. at 8, 83, 832). You can use this for the color axis, but the labels will not be regularly spaced too. The distance between 8 and 83 will be much smaller than between 83 to 832. So for your case, I suggest to use the color legend style. (The second one in the above links.) The code would be like:

// Do not display the color axis. We will use legend keys instead
//ColorAxis *cAxis = c->setColorAxis(660, 80, Chart::TopRight, 200, Chart::Right);

ColorAxis *cAxis = c->colorAxis();
cAxis->syncAxis(cAxis);

double colorScale[] = {0, 0x0044cc, 8, 0xffff00, 83, 0xff6600, 832, 0xff0000, 1000};
cAxis->setColorScale(DoubleArray(colorScale, 9));   // The array size is 9.

// Add the legend box entries
LegendBox *b = c->addLegend(660, 80, true, "arial.ttf", 12);
b->setBackground(Chart::Transparent, Chart::Transparent);
b->setKeySize(15, 15);
b->setKeySpacing(0, 8);

b->addKey(">= 832", 0xff0000);
b->addKey("83 to 832", 0xff6600);
b->addKey("8 to 83", 0xffff00);
b->addKey("< 8", 0x0044cc);

Hope this can help.

Regards
Peter Kwan

  Re: Set color and threshold of z-axis data in surface chart
Posted by Peter Kwan on Nov-20-2020 17:39
Hi JS,

For the z-axis label, by default, the label will rotate by 90 degrees. To achieve your preferred style, we need to set the rotation angle back to 0. Also, we need to put each character in a separate line by inserting linefeed characters. In C++, it is like:

const char* zAxisLabel = "Z-Axis";

// Insert linefeed between characters and center aligned the characters.
std::string label = "<*block,halign=center*>";
for (const char* ptr = zAxisLabel; *ptr; ++ptr)
{
    label += *ptr;
    label += 'n';
}
label.resize(label.size() - 1);   // remove the last linefeed

// Set the font angle back to 0
c->colorAxis()->setTitle(label.c_str(), "arialbd.ttf", 10)->setFontAngle(0);

Regards
Peter Kwan

  Re: Set color and threshold of z-axis data in surface chart
Posted by JS on Nov-24-2020 09:31
Hi Peter,

It works exactly in C# and that's what I want

Thank you very much and hope you have a nice day

Thanks