[flex_india:25693] Pie Chart Single Slice - Label Function

View: New views
3 Messages — Rating Filter:   Alert me  

[flex_india:25693] Pie Chart Single Slice - Label Function

by Kiran Kumar Vasireddy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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-function-on-a-piechart-in-flex/

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-function-on-a-piechart-in-flex/ -->
<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}%)",
                            item.@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>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_india@...
To unsubscribe from this group, send email to flex_india+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---


[flex_india:25719] Re: Pie Chart Single Slice - Label Function

by Sandeep P P :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kiran,

I think, even if you modify and save any of the flex api files, it wont get saved in background. Try extending the pie chart and override the method which is having you fix.

Cheers
Sandeep

On Tue, Oct 6, 2009 at 1:23 AM, Kiran Kumar Vasireddy <kiranvasi@...> wrote:
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-function-on-a-piechart-in-flex/

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-function-on-a-piechart-in-flex/ -->
<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}%)",
                            item.@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>





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_india@...
To unsubscribe from this group, send email to flex_india+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---


[flex_india:26437] Re: Pie Chart Single Slice - Label Function

by Kiran Kumar Vasireddy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Sandeep,

Can not able to extend the Pie chart and override that method since it is a private method. Any other Ideas?

Regards
Kiran

On Tue, Oct 6, 2009 at 6:57 PM, Sandeep P P <sandeep.nandanan@...> wrote:
Kiran,

I think, even if you modify and save any of the flex api files, it wont get saved in background. Try extending the pie chart and override the method which is having you fix.

Cheers
Sandeep


On Tue, Oct 6, 2009 at 1:23 AM, Kiran Kumar Vasireddy <kiranvasi@...> wrote:
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-function-on-a-piechart-in-flex/

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-function-on-a-piechart-in-flex/ -->
<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}%)",
                            item.@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>








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_india@...
To unsubscribe from this group, send email to flex_india+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---