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

Message ListMessage List     Post MessagePost Message

  Set more then one ColorAxis to the same SurfaceChart
Posted by Alex on Aug-13-2023 19:58
Hello Peter! Could you tell me please is it possible to set more than one ColorAxis to the same SurfaceChart?

Here is code i am using:

SurfaceChart* c = new SurfaceChart(width * scalefactor.x, height * scalefactor.y, 0x000000, 0x00979C,0);
c->setRoundedFrame(0x000000, 20, 20, 20, 20);

ColorAxis* cAxis = c->setColorAxis(c->getWidth()-224, c->getHeight() -75, Chart::TopLeft, 150, Chart::Bottom);

  Re: Set more then one ColorAxis to the same SurfaceChart
Posted by Peter Kwan on Aug-14-2023 17:15
Attachments:
Hi Alex,

You can put multiple ColorAxis on any chart. For the surface chart, it will use one of the ColorAxis to color the surface. The other ColorAxis can be used for display.

To do this, simply create empty charts with just a color axis, and merge them with the SurfaceChart (or use MultiChart to combine the charts together).

For example:


// An empty chart with just a color axis
XYChart* c2 = new XYChart(100, 300);

// Set everything to transparent
c2->setPlotArea(0, 0, 1, 1, Chart::Transparent, Chart::Transparent, Chart::Transparent, Chart::Transparent, Chart::Transparent);
c2->xAxis()->setColors(Chart::Transparent, Chart::Transparent);
c2->yAxis()->setColors(Chart::Transparent, Chart::Transparent);

// Create an empty ContourLayer to obtain a color axis
ContourLayer *axisLayer = c2->addContourLayer(DoubleArray(0, 0), DoubleArray(0, 0), DoubleArray(0, 0));

// Configure the color axis
ColorAxis* extraColorAxis = c2->addContourLayer(DoubleArray(0, 0), DoubleArray(0, 0), DoubleArray(0, 0))->setColorAxis(20, 20, Chart::TopLeft, 200, Chart::Right);
double colorScale[] = { -1.0, 0x1a9850, -0.75, 0x66bd63, -0.5, 0xa6d96a, -0.25, 0xd9ef8b, 0, 0xfee08b, 0.25, 0xfdae61, 0.5, 0xf46d43, 0.75, 0xd73027, 1 };
const int colorScale_size = (int)(sizeof(colorScale) / sizeof(*colorScale));
extraColorAxis->setColorScale(DoubleArray(colorScale, colorScale_size));

// Merge with the main chart at (680, 150)
mySurfaceChart>getDrawArea()->merge(c2->makeChart(), 680, 150, Chart::TopLeft, 0);


Best Regards
Peter Kwan
surface_multi_color_axis.png

  Re: Set more then one ColorAxis to the same SurfaceChart
Posted by Alex on Aug-15-2023 09:22
Hi, Peter! Thank you very much for explanation and code example.