ChartDirctor is a really cool program.
The programming environment is done in the MFC dialog base.
I am trying to draw a picture like the attached picture.
The graph color is a total of six colors.
Color may vary depending on conditions.
I am trying to do the program below.
int Colr_black = layer->xZoneColor(0, 0x000000,0);
int Colr_Green = layer->xZoneColor(5, 0x00ff00,0);
int Colr_Blue = layer->xZoneColor(10, 0x0000ff,0);
int Colr_Purple = layer->xZoneColor(15, 0x660066,0);
int Colr_Red = layer->xZoneColor(20, 0xff0000,0);
int Colr_Pink = layer->xZoneColor(25, 0xFF66FF,0);
In your attached chart, the color of the lines are not continuous. It has 5 colors. but there are 11 segments. For example, the red color line is separated into 4 segments.
The xZoneColor is used if if there are two colors depending on a threshold value. For example, if the color is red (0xff0000) when x <= 20, and blue (0x0000ff) when x > 20, then you can layer->xZoneColor(20, 0xff0000, 0x0000ff). For your case, because the color segments can be separated, so xZoneColor is not the best method.
Below is an example of a multi-color line. The dataX and dataY are the x and y coordinates of the data points. The pointType specifies the type of data point. (There are 4 types in the example below). Each pointType has a different color.
// Obtain the points of the same type and put them in a line layer
for (int i = 0; i < colorLen; ++i)
for (int j = 0; j < dataLen - 1; ++j)
if (pointType[j] == i)
// A line segment joins the current point with the next point, so we need to add both points.
// However, the current point may have already been added as the "next point" of the previous
// segment, so we need to check if we need to add the current point.
if ((yCoor.size() == 0) || (yCoor.back() == Chart::NoValue))
xCoor.push_back(dataX[j + 1]);
yCoor.push_back(dataY[j + 1]);
else if ((yCoor.size() > 0) && (yCoor.back() != Chart::NoValue))
// If the point is of a different type, we need to add Chart::NoValue to break the segment.
// Draw the layer that contains all segments of the same color
LineLayer* layer = c->addLineLayer(DoubleArray(&(yCoor), yCoor.size()), colors[i]);
It was really helpful. Was solved.
I'll ask a few more.
1. Is it possible to change the Y-axis color on the surface chart? (checked part in the picture)
2. Is it possible to adjust the graph color according to the conditions specified by the user regardless of the Y axis in the surface chart?
In ChartDirector, this is called the color-axis. You can certainly configure the colors. The followings are some examples that use contour charts. The same methods can be applied to surface charts too.