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

Message ListMessage List     Post MessagePost Message

  Format the values in a dataset
Posted by John Nelson on Dec-14-2017 23:09
Hi - I have an array of very large numbers that represent US dollar amounts.  I need to use the actual values to build the correct bar charts - percent bar and stacked bar.

I would like to use a formatted value for the tool tips - or possibly as the value on the chart itself.

One issue is that I have no idea what the values will be - they can range from zero to a trillion.

Example:  my dataset may be [0,123456789012, 222, 44444444, 55555]

I would like to use that data to build the bar charts but I would like the tool tip to display

"$0" for the 0 value
"$123.4 B" for the 123456789012 value
"$222"  for the 222value
"$44.4M" for the 44444444 value
$55.5k" for the 55555 value

Are there any utilities or algorithms that you have that can help me out?

I assum I need to use code similar to this...

String representation = " "{"value"}";

       imageGraphic.setHtmlImageMap(c.getHTMLImageMap("", "", "title='{xLabel}: {dataSetName} Value = "+representation+"'"));

where the representation  string would be the desired string to display.

Thoughts?

  Re: Format the values in a dataset
Posted by Peter Kwan on Dec-16-2017 03:37
Hi John,

You can provide the tooltip you want to use as an array of text strings by adding them as extra fields to the layer. For example:

double[] redPercentage = ....
string[] redPrecentageToolTips = ....

layer.addDataSet(redPercentage, project.getHighLevelColor(), "High");
layer.addExtraField(redPercentageToolTips);

Then in the data label format (for labels on the chart), you can use:

// Use the extra field (the text strings) as the tooltip
layer.setDataLabelFormat("{dsdiField0}");

You can also use {dsdiField0} in the tooltips.

Hope this can help.

Regards
Peter Kwan