Siddhant
Siddhant

Reputation: 1104

Legend Colors not being displayed in Flex Mobile Project?

I am a beginner in Flex and have recently started with Flex Mobile Projects using Flash Builder 4.6. This project is for Android.

I wanted to add effects in my Pie Chart and made the use of :

<mx:SeriesInterpolate id="interpol" 
duration="1000" 
elementOffset="0" 
minimumElementDuration="200"
/>

The whole code is as follows :

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        creationComplete="init()"
        title="Pie Chart">


    <fx:Script>
        <![CDATA[ 
        import mx.charts.events.ChartItemEvent;
        import mx.collections.ArrayCollection;


        [Bindable]
        public var expenses:ArrayCollection = new ArrayCollection([
        { Expense:"Taxes", Amount:2000 },
        { Expense:"Rent", Amount:1000 },
        { Expense:"Timepass", Amount:500 },
        { Expense:"Screwing Around", Amount:3200 },
        { Expense:"Food", Amount:200 } ]);


        private function init():void
        {
            pieSeries1.setStyle("showDataEffect", interpol);
            myPieChart.dataProvider=expenses;
        }

        private function setLegends():void
        {
            pieLegend.dataProvider=myPieChart;
        }

        private function pieChart_itemClick(event:ChartItemEvent):void
        {
            pieHighlight( event.currentTarget.id , event.hitData.chartItem.index );
        }

        private function pieHighlight( pieName:String, pieIndex:int ):void
        {
            var explodeData:Array = [];  //create an empty array
            explodeData[ pieIndex ] = 0.15; //Set the index of our pie piece to > 0
            this[pieName].series[0].perWedgeExplodeRadius = explodeData;
            myPieChart.dataProvider=expenses;
        }

        ]]> 
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <mx:SeriesInterpolate id="interpol" 
                              duration="1000" 
                              elementOffset="0" 
                              minimumElementDuration="200"
                              />
    </fx:Declarations>

    <mx:PieChart id="myPieChart" x="49" y="93" width="100%" height="100%" itemClick="pieChart_itemClick(event);"
                   selectionMode="multiple" showDataTips="true" creationComplete="setLegends();">
        <mx:series>
            <mx:PieSeries id="pieSeries1" field="Amount" labelPosition="callout" nameField="Expense"/>
        </mx:series>
    </mx:PieChart>
    <mx:Legend id="pieLegend"/>
</s:View>

I have noticed that when i set the dataProvider dynamically (myPieChart.dataProvider=expenses), the effects take place. The effects include the "swipe-open" effect and the "gently pullout slice" effect. However, the Legends have a label but no color.

Why is this happening and what is the solution to this?

Thanks in advance for any help that you can provide..

Here is the screenshot :

Pie Chart View

Upvotes: 1

Views: 569

Answers (2)

Pradeep K
Pradeep K

Reputation: 11

There is some issue with seriesinterpolate effect If you remove the effect everything works fine so kindly refer link to draw legend dynamically http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c3e.html

Upvotes: 1

Unknown
Unknown

Reputation: 21

removing series interpolation might solve the problem. That worked for me.

Upvotes: 2

Related Questions