This example demonstrates using CDML and Parameter Substitution and Formatting to include icons in sector labels. It also demonstrates gradient background color, glass shading effect for the title and rounded corners for the chart frame.
- The gradient background color is created using metalColor, with blue as the base color, and in vertical orientation.
- The rounded frame is configured using BaseChart.setRoundedFrame.
- The glass shading effect of the title is defined using glassEffect, then applied to the title using Box.setBackground of the title TextBox object.
- The icons file names are added to the chart as an extra field using BaseChart.addExtraField.
- The sector label format string is specified using CDML and Parameter Substitution and Formatting as:
<*block,
valign= absmiddle*><*img= {field0}*> <*block*>{label}<*br*>{percent}%<*/ *><*/ *>
This means that the sector label is a block, which contains an image followed by another text block. The image file is taken from the extra field. The text block contains two lines showing the sector name and percentage.
- The format string is applied to the chart using PieChart.setLabelFormat.
- For web applications, we need to set the search path to load the icon images from the current script directory using BaseChart.setSearchPath. It is because for some web servers (eg. IIS), the default current directory is not the script directory (eg. IIS uses the IIS executable directory), so the search path needs to be set explicitly.