Drawing transparent pie wedges in a Flex PieChart control

by Peter deHaan on November 11, 2007

in Charting, PieChart, PieSeries, SolidColor

The following example shows how you can create transparent wedges in a Flex PieChart control by setting the SolidColor object’s alpha property to 0, as seen in the following snippet:

<mx:PieChart dataProvider="{arrColl}" height="100%" width="100%">
    <mx:series>
        <mx:PieSeries id="pieSeries" field="data">
            <mx:fills>
                <mx:SolidColor alpha="0.0" />
                <mx:SolidColor color="haloBlue" alpha="1.0" />
            </mx:fills>
            <mx:filters>
                <mx:Array />
            </mx:filters>
        </mx:PieSeries>
    </mx:series>
</mx:PieChart>

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/11/11/drawing-transparent-pie-wedges-in-a-flex-piechart-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:ArrayCollection id="arrColl">
        <mx:source>
            <mx:Array>
                <mx:Object label="Product 1" data="4" />
                <mx:Object label="Product 2" data="27" />
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:PieChart id="pieChart"
            dataProvider="{arrColl}"
            height="100%"
            width="100%"
            showDataTips="true">
        <mx:series>
            <mx:PieSeries id="pieSeries"
                    field="data">
                <mx:fills>
                    <mx:SolidColor alpha="0.0" />
                    <mx:SolidColor color="haloBlue" alpha="1.0" />
                </mx:fills>
                <mx:filters>
                    <mx:Array />
                </mx:filters>
            </mx:PieSeries>
        </mx:series>
    </mx:PieChart>

</mx:Application>

View source is enabled in the following example.

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: