I just started learning flex and working on Pie Chart

This question may look silly , but I come across in my project . Following 
is flex code copied from 

http://blog.flexexamples.com/2008/09/26/setting-a-custom-label-functi... 

Problem :- XML collection ( id is "dp") has only one value and if you run 
this code the label is not getting displayed , But if you add two or more 
products the label function is working perfect . 

There is a bug raised for it and the URL is 

http://bugs.adobe.com/jira/browse/FLEXDMV-1569 

Fix is :- we need to modify PieSeries.as . I modified the file as per 
instructions and closed my Flex Builder 3 and modified the code and ran , 
But I still see the same problem . Any one come across this issue ? Please 
shed some light on this... 

Regards 


<?xml version="1.0" encoding="utf-8"?> 
<!-- 
http://blog.flexexamples.com/2008/09/26/setting-a-custom-label-functi...> 
<mx:Application name="PieSeries_labelFunction_test" 
        xmlns:mx="http://www.adobe.com/2006/mxml"; 
        layout="vertical" 
        verticalAlign="middle" 
        backgroundColor="white"> 

    <mx:Script> 
        <![CDATA[ 
            import mx.utils.StringUtil; 

            private function pieSeries_labelFunc(item:Object, field:String, 
index:Number, percentValue:Number):String { 
                return StringUtil.substitute("{0} ({1}%)", 
                            it...@label, 
                            percentValue.toFixed(1)); 
            } 
        ]]> 
    </mx:Script> 

    <mx:XMLListCollection id="dp"> 
        <mx:source> 
            <mx:XMLList> 
                <product label="Product 1" data="3" /> 
            </mx:XMLList> 
        </mx:source> 
    </mx:XMLListCollection> 

    <mx:Panel styleName="opaquePanel" 
            width="100%" 
            height="100%"> 
        <mx:PieChart id="pieChart" 
                dataProvider="{dp}" 
                showDataTips="false" 
                height="100%" 
                width="100%"> 
            <mx:series> 
                <mx:PieSeries id="pieSeries" 
                        field="@data" 
                        nameField="@label" 
                        labelPosition="inside" 
                        labelFunction="pieSeries_labelFunc" /> 
            </mx:series> 
        </mx:PieChart> 
        <mx:ControlBar width="100%"> 
            <mx:Legend dataProvider="{pieChart}" 
                    direction="horizontal" 
                    horizontalGap="100" 
                    width="100%" /> 
        </mx:ControlBar> 
    </mx:Panel> 

</mx:Application> 


      

Reply via email to