Showing posts from May, 2009

Flex: Showing data in the legend of a Pie Chart

By default the legend class does not allow to output actual data values. All it can show is the marker's label and color. After searching the web, strangely enough, I did not find any published solution, and decided to extend the legend class in my application. Today, I am sharing my work with you. For the illustration I took an example from the official documentation of PieChart class. The name of the main application is TestLegend.mxml. All you need to do here is to add 'legendItemClass' property to the Legend tag. The Legend tag will look like: <mx:Legend dataProvider="{chart}" legendItemClass="utilities.CustomPieLegendItem"/> Next step is to create CustomPieLegendItem class, which extends LegendItem. I created a 'utilities' folder and added a new class there, in package utilities { import mx.charts.LegendItem; import mx.charts.series.PieSeries; import mx.collections.ArrayCollection; public class CustomPieLege