ChartDirector 6.2 (.NET Edition)
Parameter Substitution and Formatting
ChartDirector charts often contain a lot of text strings. For example, sector labels in pie charts, axis labels for x and y axes, data labels for the data points, HTML image maps, etc, are all text strings.
ChartDirector uses parameter substitution to allow you to configure precisely the information contained in the text and their format.
Format Strings
In parameter substitution, format strings are used to specify the entities to be include into labels and how to format numbers and dates.
For example, when drawing a pie chart with side label layout, the default sector label format string is:
"{label} ({percent}%)"
When the sector label is actually drawn, ChartDirector will replace "{label}" with the sector name, and "{percent}" with the sector percentage. So the above label format will result is a sector label similar to
"ABC (34.56%)".
You may change the sector label format by changing the format string. For example, you may change it to:
"{label}: US${value2}K ({percent}%)"
The sector label will then become something like
"ABC: US$123.00 (34.56%)".
In general, in ChartDirector parameter substitution, parameters enclosed by curly brackets will be substituted with their actual values when creating the texts.
For parameters that are numbers or
dates/times, ChartDirector supports a special syntax in parameter substitution to allow formatting for these values. Please refer to the
Number Formatting and
Date/Time Formatting sections below for details.
Parameter Expressions
ChartDirector supports numeric expressions in format strings. They are denoted by enclosing the expression with curly brackets and using "=" as the first character. For example:
"USD {value} (Euro {={value}*0.9})"
In the above, "{value}" will be substituted with the actual value of the sector. The expression "{={value}*0.9}" will be substituted with the actual value of the sector multiplied by 0.9.
ChartDirector parameter expressions support operators "+", "", "*", "/", "%" (modulo) and "^" (exponentiation). Operators "*", "/", "%", "^" is computed first, followed by "+" and "". Operators of the same precedence are computed from left to right). Parenthesis "(" and ")" can be used to change the computation order.
Parameters for Pie Charts
The following table describes the parameters available for pie charts.
Parameter  Description 

sector  The sector number. The first sector is 0. The nth sector is (n1).

dataSet  Same as {sector}. See above. 
label  The text label of the sector. 
dataSetName  Same as {label}. See above. 
value  The data value of the sector. 
percent  The percentage value of the sector. 
fieldN  The (N + 1)th extra field. For example, {field0} means the first extra field. An extra field is an array of custom values added using BaseChart.addExtraField or BaseChart.addExtraField2.

Parameters for All XY Chart Layers
The followings are parameters that are apply to all XY Chart layers in general. Some layer types may have additional parameters (see below).
Note that certain parameters are inapplicable in some context. For example, when specifying the aggregate label of a stacked bar chart, the {dataSetName} parameter is inapplicable. It is because a stacked bar is composed of multiple data sets. It does not belong to any particular data set and hence does not have a data set name.
Parameter  Description 

x  The x value of the data point. For an enumerated xaxis (see Axis.setLabels on what is an enumerated axis), the first data point is 0, and the nth data point is (n1).

xLabel  The bottom xaxis label of the data point.

x2Label  The top xaxis label of the data point.

value  The value of the data point.

accValue  The sum of values of all data points that are in the same x position and same data group as the current data point, and with data set number less than or equal to the current data point. This is useful for stacked charts, such as stacked bar chart and stacked area chart.

totalValue  The sum of values of all data points that are in the same x position and same data group as the current data point. This is useful for stacked charts, such as stacked bar chart and stacked area chart.

percent  The percentage of the data point based on the total value of all data points that are in the same x position and same data group as the current data point. This is useful for stacked charts, such as stacked bar chart and stacked area chart.

accPercent  The accumulated percentage of the data point based on the total value of all data points that are in the same x position and same data group as the current data point. This is useful for stacked charts, such as stacked bar chart and stacked area chart.

gpercent  The percentage of the data point based on the total value of all data points in a layer.

dataSet  The data set number to which the data point belongs. The first data set is 0. The nth data set is (n1).

dataSetName  The name of the data set to which the data point belongs.

dataItem  The data point number within the data set. The first data point is 0. The nth data point is (n1).

dataGroup  The data group number to which the data point belongs. The first data group is 0. The nth data group is (n1).

dataGroupName  The name of the data group to which the data point belongs.

layerId  The layer number to which the data point belongs. The first layer is 0. The nth layer is (n1).

fieldN  The (N + 1)th extra field. For example, {field0} means the first extra field, and {field1} means the second extra field. An extra field is an array of custom values added using Layer.addExtraField, Layer.addExtraField2, BaseChart.addExtraField or BaseChart.addExtraField2.
{fieldN} means the extra field is indexed by the data point number. The Pth data point corresponds to the Pth element of the extra field.

diFieldN  Same as fieldN. See above.

dsFieldN  Similar to fieldN, except that dsFieldN means the extra field is indexed by data set number. The Pth data set corresponds to the Pth element of the extra field.

dsdiFieldN  Similar to fieldN, except that dsdiFieldN means the extra fields are indexed by both the data set number and data point number. The Pth data item of the Qth data set corresponds to the Pth element of the (N + Q)th extra field.

Additional Parameters for Line Layers
The followings are parameters that are in additional to the parameters for all XY Chart layers.
Parameter  Description 

zx  The symbol scale in the x dimension. Applicable for layers with symbol scales set by LineLayer.setSymbolScale. 
zy  The symbol scale in the y dimension. Applicable for layers with symbol scales set by LineLayer.setSymbolScale. 
z  The symbol scale without distinguishing the dimension to use. Applicable for layers with symbol scales set by LineLayer.setSymbolScale. 
Additional Parameters for Trend Layers
The followings are parameters that are in additional to the parameters for all XY Chart layers.
Parameter  Description 

slope  The slope of the trend line in linear regression analysis. 
intercept  The yintercept of the trend line in linear regression analysis. 
corr  The correlation coefficient in regression analysis. 
stderr  The standard error in regression analysis. 
coeffN  The coefficient with index N in the regression formula. For example, coeff0 and coeff1 are the a_{0} and a_{1} in the regression formula. See TrendLayer for the supported regression formulas.

Additional Parameters for BoxWhisker Layers
The followings are parameters that are in additional to the parameters for all XY Chart layers.
Parameter  Description 

top  The value of the top edge of the boxwhisker symbol. 
bottom  The value of the bottom edge of the boxwhisker symbol. 
max  The value of the maximum mark of the boxwhisker symbol. 
min  The value of the minimum mark of the boxwhisker symbol. 
med  The value of the median mark of the boxwhisker symbol. 
Additional Parameters for HLOC and CandleStick Layers
The followings are parameters that are in additional to the parameters for all XY Chart layers.
Parameter  Description 

high  The high value. 
low  The low value. 
open  The open value. 
close  The close value. 
Additional Parameters for Vector Layers
The followings are parameters that are in additional to the parameters for all XY Chart layers.
Parameter  Description 

dir  The direction of the vector. 
len  The length of the vector. 
Parameters for All Polar Layers
The followings are parameters that are apply to all Polar Chart layers in general. Some layer types may have additional parameters (see below).
Parameter  Description 

radius  The radial value of the data point. 
value  Same as {radius}. See above. 
angle  The angular value of the data point. 
x  Same as {angle}. See above. 
label  The angular label of the data point. 
xLabel  Same as {label}. See above. 
name  The name of the layer to which the data point belongs. 
dataSetName  Same as {name}. See above. 
i  The data point number. The first data point is 0. The nth data point is (n1). 
dataItem  Same as {i}. See above. 
z  The symbol scale. Applicable for layers with symbol scales set by PolarLayer.setSymbolScale.

fieldN  The (N + 1)th extra field. For example, {field0} means the first extra field. An extra field is an array of custom elements added using BaseChart.addExtraField or BaseChart.addExtraField2.
{fieldN} means the extra field is indexed by the data point number. The Pth data point corresponds to the Pth element of the extra field.

diFieldN  Same as fieldN. See above.

dsFieldN  Similar to fieldN, except that dsFieldN means the extra field is indexed by layer index. The Pth layer corresponds to the Pth element of the extra field.

dsdiFieldN  Similar to fieldN, except that dsdiFieldN means the extra fields are indexed by both the layer index and data point number. The Pth data item of the Qth layer corresponds to the Pth element of the (N + Q)th extra field.

Additional Parameters for PolarVector Layers
The followings are parameters that are in additional to the parameters for all Polar Chart layers.
Parameter  Description 

dir  The direction of the vector. 
len  The length of the vector. 
Parameters for Axis
The following table describes the parameters available for the axis.
Parameter  Description 

value  The axis value at the tick position. 
label  The axis label at the tick position. 
Parameters for Pyramid Charts
The following table describes the parameters available for pyramid charts.
Parameter  Description 

index  The index number of the pyramid layer. The first pyramid layer is 0. The nth pyramid layer is (n1).

dataSet  Same as {index}. See above. 
label  The text label of the pyramid layer. 
dataSetName  Same as {label}. See above. 
value  The data value of the pyramid layer. 
percent  The percentage value of the pyramid layer. 
fieldN  The (N + 1)th extra field. For example, {field0} means the first extra field. An extra field is an array of custom values added using BaseChart.addExtraField or BaseChart.addExtraField2.

Number Formatting
For parameters that are numbers, ChartDirector supports a number of formatting options in parameter substitution.
For example, if you want a numeric field
{value} to have a precision of two digits to the right of the decimal point, use ',' (comma) as the thousand separator, and use '.' (dot) as the decimal point, and you may use
{value2,.}. The number
123456.789 will then be displayed as
123,456.79.
For numbers, the formatting options are specified using the following syntax:
{[param][a][b][c][d]}
where:
Parameter  Description 

[param]  The name of the parameter

[a] 
 If this field a number, it specifies the number of decimal places (digits to the right of the decimal point).
 If this field starts with "E" or "e", followed by a number n, the value will be formatted using scientific notation with n decimal places. If the "E" or "e" is not followed by a number, 3 is assumed.
For example, {valueE4} will format the value 10.3 to 1.0300E+1, and {valuee4} will format the same value to 1.0300e+1.
 If this field starts with "G" or "g", followed by a number n, the value will be formatted using the scientific notation only if the value is large and requires more than the n digits, or the value is less than 0.001. If scientific notation is used, n is the number of significant digits. If the "G" or "g" is not followed by a number, 4 is assumed.
For example, consider the format string {valueG4}. The value 10 will be formatted to 10. The value 100000 will be formatted to 1.000E+5. Similarly, for {valueg4}, the value 10 will be formatted to 10, while the value 100000 will be formatted to 1.000e+5.
 If this field starts with "P" followed by a number n, the value will be formatted with no more than n decimal places. The result may contain less decimal places if they are not needed, or if the value already has more than n significant digits. If the "P" is not followed by a number, 3 is assumed.
For example, if P3 is used, the value 1.234567 will be formatted to 1.235 (3 decimal points); the value 1.2 will be formatted to 1.2 (additional decimal places are not needed); the value 12.34567 will be formatted to 12.35 (already has more than 3 significant digits), and the value 123456.789 will be formatted to 123457 (already has more than 3 significant digits).
The "P" format is useful to format a number to a given precision, without using more decimal places than needed or switching to scientific formatting.
 For Axis label formatting, the special character "@" can be used. It means to use a fixed number of decimal places automatically determined by the Axis object. For example, if the axis labels are 0, 0.5, 1, 1.5, 2, the Axis object may decide to use 1 decimal place, in which case the labels will become 0.0, 0.5, 1.0, 1.5, 2.0.
If you skip this field, ChartDirector will display the exact value using at most 6 decimal places.

[b]  The thousand separator, which should be a nonalphanumeric character (not 09, AZ, az). Use '~' for no thousand separator. If this character is not specified or is '?', the default is no thousand separator. The default is configurable using BaseChart.setNumberFormat.

[c]  The decimal separator. Use '~' for no decimal separator. If this character is not specified or is '?', the default is '.'. The default is configurable using BaseChart.setNumberFormat.

[d]  The negative sign character. Use '~' for no negative sign character. If this character is not specified or is '?', the default is ''. The default is configurable using BaseChart.setNumberFormat.

[e]  The currency character. The currency character will appear before the digits of the number, but after the negative sign character for negative numbers.

Date/Time Formatting
For parameters that are
dates/times, the formatting options can be specified using the following syntax:
{[param][datetime_format_string]}
where
[datetime_format_string]
must start with an english character (AZ or az) that is not "G", "g", "E" or "e", and may contain any characters except '}'. (If it starts with "G", "g", "E" or "e", it will be considered as a number format string.)
Certain characters are substituted according to the following table. Characters that are not substituted will be copied to the output.
Parameter  Description 

yyyy  The year in 4 digits (e.g. 2002)

yyy  The year showing only the least significant 3 digits (e.g. 002 for the year 2002)

yy  The year showing only the least significant 2 digits (e.g. 02 for the year 2002)

y  The year showing only the least significant 1 digits (e.g. 2 for the year 2002)

mmm  The month formatted as its name. The default is to use the first 3 characters of the english month name (Jan, Feb, Mar ...). The names can be configured using BaseChart.setMonthNames.

mm  The month formatted as 2 digits from 01  12, adding a leading zero if necessary.

m  The month formatted using the minimum number of digits from 1  12.

MMM  The first 3 characters of the month name converted to upper case. The names can be configured using BaseChart.setMonthNames.

MM  The first 2 characters of the month name converted to upper case. The names can be configured using BaseChart.setMonthNames.

M  The first character of the month name converted to upper case. The names can be configured using BaseChart.setMonthNames.

dd  The day of month formatted as 2 digits from 01  31, adding a leading zero if necessary.

d  The day of month formatted using the minimum number of digits from 1  31.

w  The name of the day of week. The default is to use the first 3 characters of the english day of week name (Sun, Mon, Tue ...). The names can be configured using BaseChart.setWeekDayNames.

hh  The hour of day formatted as 2 digits, adding a leading zero if necessary. The 2 digits will be 00  23 if the 'a' option (see below) is not specified, otherwise it will be 01  12.

h  The hour of day formatted using the minimum number of digits. The digits will be 0  23 if the 'a' option (see below) is not specified, otherwise it will be 1  12.

nn  The minute formatted as 2 digits from 00  59, adding a leading zero if necessary.

n  The minute formatted using the minimum number of digits from 00  59.

ss  The second formatted as 2 digits from 00  59, adding a leading zero if necessary.

s  The second formatted using the minimum number of digits from 00  59.

fff  The millisecond formatted as 3 digits from 000  999.

ff  The hundredths of a second formatted as 2 digits from 00  99.

f  The tenths of a second formatted as 1 digit from 0  9.

a  Display either 'am' or 'pm', depending on whether the time is in the morning or afternoon. The text 'am' and 'pm' can be modified using BaseChart.setAMPM.

For example, a parameter substitution format of
{valuemmddyyyy} will display a date as something similar to
09152002. A format of
{valuedd/mm/yy hh:nn:ss a} will display a date as something similar to
15/09/02 03:04:05 pm.
If you want to include characters in the format string without substitution, you may enclose the characters in single or double quotes.
For example, the format
{valuemmm '<*color=dd0000*>'yyyy} will display a date as something like
Jan <*color=dd0000*>2005 (the <*color=dd0000*> is a
CDML tag to specify red text color). Note that the <*color=dd0000*> tag is copied directly without substitution, even it contains "dd" which normally will be substituted with the day of month.
Escaping URL/HTML/CDML characters
Parameter substitution is often used to create HTML image maps. In HTML, some characters has special meanings and cannot be used reliably. For example, the '>' is used to represent the end of an HTML tag.
Furthermore, if the field happens to be used as an URL, characters such as '?', '&' and '+' also have special meanings.
By default, ChartDirector will escape template fields used in URL and query parameters when generating image maps. It will modify URL special characters to the URL escape format "%XX" (eg. "?" will become "%3F"). After that, it will modify HTML special characters to the HTML escape format "&#nn;" (eg. ">" will become ">"). Similarly, it will escape other attributes in the image map using HTML escape format (but not URL escape format).
In addition to escaping HTML and URL special characters, ChartDirector will also remove
CDML fields in creating image maps. It is because CDML is only interpreted in ChartDirector, and should not be useful outside of ChartDirector (such as in browser tool tips).
In some cases, you may not want ChartDirector to escape special characters. For example, if the parameters have already been escaped before passing to ChartDirector, you may want to disable ChartDirector from escaping them again.
ChartDirector supports the following special fields to control the escape methods  "{escape_url}", "{noescape_url}", "{escape_html}", "{noescape_html}", "{escape_cdml}" and "{noescape_cdml}". These fields enable/disable the escape methods used in the template fields that follow them.
© 2017 Advanced Software Engineering Limited. All rights reserved.