Inspired by Peter Baird’s line chart class, here’s a pie chart class in Actioncript 2.0. It’s designed for FlashLite, small screen UIs, keyboard interaction. The pie chart is constructed using a data array that specifies, for each pie wedge, the size, colour and a wedge label.
The zip below contains the pie chart class and a fla showing an example of how to use attachMovie to create the chart.
It’s possible to move focus around the pie wedges – the fla passes 4 way navigation events to the pie chart. The focussed wedge is withdrawn from the pie and can have a different graphical treatment applied to it – by default, the focussed wedge isn’t dimmed, all other wedges are dimmed.
The example fla uses a property object to pass parameters to the pie chart when it’s instantiated. The property object includes the data used to populate the chart, but also a number of other settings used to customise the look of the pie chart:
- vKeepPieCircular_boo = determines whether the pie chart is circular or whether it fills the available space by going elliptical.
- vDropShadow_boo = determines whether the pie has a drop shadow.
-vDimming_boo = determines whether non-selected wedges are dimmed, or whether all wedges are shown the same.
- vPieChartTitleAlignment_str = the title of the chart can be positioned at the top or bottom of the chart.
All the options are described in the fla, so feel free to experiment.