24
Sep
07

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)“.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/24/setting-a-flex-pie-charts-start-angle/ -->
<mx:Application 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.


6 Responses to “Setting a Flex Pie Chart's start angle”


  1. 1 Val Sep 25th, 2007 at 2:11 am

    Hi,
    Thanks for this example.
    I use pie chart in my application, is there a way to have a semi pie chart ?
    Val

  2. 2 zeka oyunları May 1st, 2008 at 12:15 pm

    Hi,
    Thanks for this example.
    I use pie chart in my application, is there a way to have a semi pie chart ?
    Val

  3. 3 peterd May 1st, 2008 at 1:04 pm
  4. 4 Anonymous Aug 19th, 2008 at 8:48 pm

    can make it a 3D style?

  5. 5 peterd Aug 19th, 2008 at 9:01 pm

    Anonymous,

    I don’t believe that the Adobe Flex Charting components do 3D, but there are 3rd party components that offer 3D. For example, check out the ILOG Elixir components at http://www.ilog.com/products/ilogelixir/features/3d-charts/ .

    Peter

  6. 6 Boyama Oyunları Sep 24th, 2008 at 1:47 pm

    Does this work for you?

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".