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

Message ListMessage List     Post MessagePost Message

  formatValue() behaviour and crash
Posted by Serge on Aug-24-2011 02:40
Hi,

I'm using chartdir50.dll, version 5.0.3.0, and the following code produces errors.

XYChart* c = new XYChart(...);

c->formatValue(1, "{value|2}");
// returns "1.00" as expected

c->formatValue(1, "ABC");
// returns "ABC" as expected

c->formatValue(1, "3");
// returns "1.000" instead of expected "3"?

c->formatValue(1.0, "2011");
// crashes inside chartdir50.dll!101c908c()

This was found accidentally by passing the wrong string as the format argument.

Serge

  Re: formatValue() behaviour and crash
Posted by Peter Kwan on Aug-24-2011 04:18
Hi Serge,

Thanks for reporting this problem to us.

In ChartDirector, the format string is using {xxx}, where xxx is the field to be formatted. Typically, it is something like "{label}: {value|2} ({percent}%)".

However, for BaseChart.formatValue, the only field is {value}. So there is no need to specify the field to be formatted. Anyway, for consistency, the {value} is still used. However, ChartDirector also supports the short-cut of not specifying the {value} part at all. For example, "12" will be assumed to mean "{value|12}". This feature is currently not documented.

I think for c->formatValue(1.0, "2011"), ChartDirector is attempting to treat the format string as "{value|2011}". A format with over two thousand decimal points may have cause some internal errors within ChartDirector.

We will fix it in the next version of ChartDirector so that it will no longer crash. However, the short-cut behaviour probably will not be changed.

Regards
Peter Kwan

  Re: formatValue() behaviour and crash
Posted by Serge on Aug-24-2011 04:31
Peter, thanks for the detailed explanation.