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

Message ListMessage List     Post MessagePost Message

  How to set label number of the Axis When using the 'addDataSet' function.
Posted by mirro187 on May-22-2019 10:05
for example , set 01/2019 02/2019 03/2019 04/2019 05/2019 06/2019 ...... 12/2019

std::map<std::string, UsageRateDataChart>::iterator it = mapdata.begin();
for (it; it != mapdata.end(); it++)
UsageRateDataChart data = it->second;
if (!isFirst)
layer->setXData(DoubleArray(, data._xData.size()));
isFirst = true;
QString   qstr = QString::fromLocal8Bit(it->first.c_str());
layer->addDataSet(DoubleArray(, data._yData.size()),data._color, qstr.toStdString().data());

  Re: How to set label number of the Axis When using the 'addDataSet' function.
Posted by Peter Kwan on May-22-2019 22:56
Hi mirro187,

By default, ChartDirector will automatically determine the axis scale and labels based on the xData and yData of all the layers in the chart. There are several API that can control how the labels are automatically determined. Some of them are:

For example, you can use the following code to configure the x and y label formats:


If you prefer to configure the axis scale and labels with your own code, you can use Axis.setLinearScale or Axis.setDateScale. For example:

// y-axis scale from 0 to 100, with a tick every 20 units, and with a "%" after the label
c->yAxis()->setLinearScale(0, 100, 20);

// x-axis scale from 2019-1-1 00:00:00 to 2019-12-31 00:00:00, with a tick every 2 months
c->xAxis()->setDateScale(Chart::chartTime(2019, 1, 1), Chart::chartTime(2019, 12, 31), 60 * 86400);

Hope this can help.

Peter Kwan