lex PieSeries class stroke and mx.graphics.Stroke to change

lex PieSeries class stroke and mx.graphics.Stroke to change

Postby tomrff » Sat Mar 19, 2011 10:27 am

This sample shows how to use Flex PieSeries class stroke and mx.graphics.Stroke to change border color and thickness of piechart

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">

    <mx:Script>
        <![CDATA[
            import mx.graphics.Stroke;

            private function setStroke(evt:Event):void {
                var stroke:Stroke = new Stroke();
                stroke.color = colorPicker.selectedColor;
                stroke.weight = slider.value;
                pieSeries.setStyle("stroke", stroke);
            }
        ]]>
    </mx:Script>

    <mx:XML id="dp">
        <products>
            <product label="Product 1" data="3" />
            <product label="Product 2" data="1" />
            <product label="Product 3" data="4" />
            <product label="Product 4" data="1" />
            <product label="Product 5" data="5" />
            <product label="Product 6" data="9" />
        </products>
    </mx:XML>

    <mx:ApplicationControlBar dock="true">
        <mx:Form>
            <mx:FormItem label="color:">
                <mx:ColorPicker id="colorPicker"
                        change="setStroke(event);" />
            </mx:FormItem>
            <mx:FormItem label="weight:">
                <mx:HSlider id="slider"
                        minimum="0"
                        maximum="10"
                        value="1"
                        liveDragging="true"
                        snapInterval="1"
                        tickInterval="1"
                        change="setStroke(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:PieChart id="pieChart"
            dataProvider="{dp.product}"
            height="250"
            width="100%">
        <mx:series>
            <mx:PieSeries id="pieSeries"
                    field="@data">
                <mx:stroke>
                    <mx:Stroke color="black"
                            weight="2" />
                </mx:stroke>
                <mx:filters>
                    <mx:Array />
                </mx:filters>
            </mx:PieSeries>
        </mx:series>
    </mx:PieChart>

</mx:Application>
Attachments
piechart.jpg
piechart.jpg (37.12 KiB) Viewed 682 times
tomrff
 
Posts: 33
Joined: Sat Jan 08, 2011 10:12 pm

Return to Adobe FLEX Flash

Who is online

Users browsing this forum: No registered users and 1 guest

cron