Setting a Flex Pie Chart’s start angle

The following example shows how you can change the start angle in a Flex Pie Chart.

Full code after the jump.

For more information on setting up charting in an Adobe Flex 3 Beta 1 project, see “Charting in Flex Builder 3 (public beta 1 edition)”.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/24/setting-a-flex-pie-charts-start-angle/ -->
<mx:Application name="PieChart_startAngle_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            private function degrees_func(item:Number):String {
                return item + String.fromCharCode(176);
            }
        ]]>
    </mx:Script>
 
    <mx:Array id="dp">
        <mx:Object data="3" />
        <mx:Object data="1" />
        <mx:Object data="4" />
        <mx:Object data="1" />
        <mx:Object data="5" />
        <mx:Object data="9" />
    </mx:Array>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Label text="startAngle:" />
        <mx:HSlider id="slider"
                minimum="0"
                maximum="360"
                liveDragging="true"
                snapInterval="1"
                tickInterval="10"
                showTrackHighlight="true"
                dataTipPrecision="0"
                dataTipFormatFunction="degrees_func" />
    </mx:ApplicationControlBar>
 
    <mx:PieChart id="chart"
            height="100%"
            width="100%"
            dataProvider="{dp}">
        <mx:series>
            <mx:PieSeries id="pieSeries"
                    field="data"
                    startAngle="{slider.value}" />
        </mx:series>
    </mx:PieChart>
 
</mx:Application>

View source is enabled in the following example.

8 thoughts on “Setting a Flex Pie Chart’s start angle

Comments are closed.