
This example extends the Icon Pie Chart example to demonstrate using CDML to include multiple fonts and colors in chart title, sector labels and to draw logo. It also demonstrates silver background color, rounded corners, and glass shading effect for title.
- The silver background is achieved by using silverColor to create the silver color, then use it in PieChart.PieChart as the chart background color.
- The rounded frame is configured using BaseChart.setRoundedFrame.
- The title containing multiple fonts and colors is written in CDML and added to the chart using BaseChart.addTitle.
- 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 logo designed using CDML is added to the chart as another title using BaseChart.addTitle2 with BottomRight alignment.
- The icons file names for sector labels 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}*> {label} ({percent|0}%)
This means that the sector label is a block, which contains an image, followed by the sector name and percentage. The image file is taken from the extra field.
- 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.