Very similar to pie charts, donut charts allow you to vary the visual if you have been using pie charts a lot. And since we used Flex to build the pie chart in the previous recipe, we thought it would be good to show how to build a pie chart/donut chart using pure ActionScript 3.
This recipe bases some of its code on the wedge class by Adobe's evangelist Lee Brimelow; you can check it here: http://www.leebrimelow.com/?p=430. Apart from that you can look up the code you will get from http://www.packtpub.com.
The following are the steps required to build a donut chart:
We will start by creating the data class in this case
DonutChartData.as
.public var color : uint; public var percent : Number; public function DonutChartData(newPercent:Number, newColor:uint){ percent = newPercent; color = newColor; }
From there we will create the visual building block of this chart:
DonutChartWedge.as
. This class could also be used in a pie chart. The following...