In the recipe Building vertical bar charts in this chapter, we showed how to make a simple bar chart in ActionScript. For this recipe, we wanted to spice it up a bit and make it 3D.
The following steps will show you how to convert a 2D bar chart to 3D:
Take
BarData.as
,HorizontalAxis.as
,VerticalAxis.as
, andMain.as
from the Building vertical bar charts recipe from this chapter; these files are not going to change.Now in
BarChart.as
, increase the space between the bars. These are the lines that change:_barWidth = (width - 10) * 70 / 100 / data.length; _barSpacing = (width - 10) * 30 / 100 / (data.length + 1);
The big changes will be in the
Bar.as
file. First we will add two helper functions to go back and forth between the color model, as shown in the following code snippet:private function _hexToRGB(hex:uint):Object { var rgbObj:Object = { red: ((hex & 0xFF0000) >> 16), green...