rss
twitter

Wednesday, September 24, 2008

Dynamic Itemrenderer With Plotchart

Here is my first post in technical site.As i am currently working on Flex Project.
i have decided to post the same here in Blogger.

here i am giving the technique how to set the itemrenderer to Plotseries (PlotChart) at runtime.

This toggle the itemrenderer between CircleItemRenderer and TriangleItemRenderer when clicking the Change Renderer button


Download the Source


Actionscript Code:

import mx.collections.ArrayCollection;
import mx.charts.renderers.*;
[Bindable]
private var value:Number=0;
[Bindable]
private var Mstatus:ArrayCollection = new ArrayCollection( [
{ Month: "January", Profit: 5000, Expense: 2500, Amount: 250 },
{ Month: "February", Profit: 2000, Expense: 4200, Amount: 500 },
{ Month: "March", Profit: 1700, Expense: 700, Amount: 200 } ]);

private function changerend():void{
if(value==0){
chart_series.setStyle("itemRenderer",new classFactory(mx.charts.renderers.CircleItemRenderer));
value=1;
}
else {
value=0;
chart_series.setStyle("itemRenderer",new ClassFactory(mx.charts.renderers.TriangleItemRenderer));
}
plot.dataProvider.refresh();
}


MXML Code:

< mx:Panel title="PlotChart Item Renderer Sample" height="100%" width="100%">
< mx:PlotChart id="plot" height="100%" width="100%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{Mstatus}">
< mx:series >
< mx:PlotSeries xField="Expense" yField="Profit" displayName="Profit" id="chart_series"/>


< mx:Legend dataProvider="{plot}"/>
< mx:Button label="Change Renderer" click="changerend()"/>
< /mx:Panel>

Bookmark and Share

0 comments:

Post a Comment

  © Blogger templates by Ourblogtemplates.com updated with zenplate.com tips

Back to TOP