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 |