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

Message ListMessage List     Post MessagePost Message

  Number Formatting
Posted by Electron Shepherd on May-24-2015 05:19
I'm drawing a line chart, and adding some Y values using calls to addDataSet.

If the data ranges from say, 0 to 1600, the labels on the Y axis display, for example, "1600", without any other formatting such as commas separating the groups of digits.

I've seen the section in the help about "Parameter Substitution and Formatting", and I could use CD's built-in formatting. However, it seems from the documentation that this functionality is not fully culture aware.

Does this functionality replicate that available via the LOCALE_SGROUPING option under Windows, or does it always group digits in threes, regardless of the culture options set for the underlying operating system?

If not, can I supply my own function to format the text corresponding to the source values somehow?

  Re: Number Formatting
Posted by Peter Kwan on May-26-2015 02:03
Hi Electron,

Unluckily, the ChartDirector number format is not aware of LOCALE_SGROUPING. The
separator are always in groups of 3 digits.

To perform custom formatted, if the y-axis is auto-scaled by ChartDirector, you may ask
ChartDirector for the label position after laying out the axis, and ask ChartDirector to use
your own label at those positions. The code is like:


..... create chart as usual and enter all data and layers .....

// with all the data available, can now auto-scale the axis
c->layoutAxes();

// the label positions
DoubleArray ticks = c->yAxis()->getTicks();

for (int i = 0; i < ticks.len; ++i)
   c->yAxis()->addLabel(ticks[i], myFormatFunction(ticks[i]));

Hope this can help.

Regards
Peter Kwan

  Re: Number Formatting
Posted by Electron Shepherd on May-26-2015 04:32
Thank you - that's very useful.