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

Message ListMessage List     Post MessagePost Message

  Using Mark Line with X-Axis
Posted by Ji-hyeon Choi on Jun-20-2024 12:24
Attachments:
When setting a mark line based on the x-axis, if a value is added, the value is calculated and drawn as an index of the x-axis. Is there any way to draw a value? The mark line in the picture is drawn when 4.5 is substituted.
캡처.PNG

  Re: Using Mark Line with X-Axis
Posted by Peter Kwan on Jun-21-2024 04:23
Hi Ji-hyeon,

If the bars do not have x-coordinates (Layer.setXData is not used), then the array index will be assumed to be the x-coordinates. For the x-axis, if it is configured to display labels (using Axis.setLabels), the x-coordinates of the labels will be assumed to be the array index too. So the bars will match the labels.

The labels can be {"Mon", "Tue", "Wed", "Thu", "Fri"} or {"2", "4", "77", "9", "10"} or any other text/numbers. ChartDirector will just treat them as "names" and display them as is.

If the bars have x-coordinates, ChartDirector will use those x-coordinates. For example:

// The x and y coordinates of the bars
double dataY[] = { 85, 156, 179.5, 211, 123 };
double dataX[] = { 2, 3, 4, 5, 6 };

BarLayer *layer = c->addBarLayer(DoubleArray(dataY, 5));
layer->setXData(DoubleArray(dataX, 5));

// The following is optional. If the x-axis scale is not set, ChartDirector will automatically
// determine the scale, just like it will automatically determine the y-axis scale.
//c->xAxis()->setLinearScale(2, 6, 1);

// Add a mark line between the x-coordinates 4 and 5
c->xAxis()->addMark(4.5, 0xff0000);

Best Regards
Peter Kwan