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.*;
private var value:Number=0;
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{
chart_series.setStyle("itemRenderer",new classFactory(mx.charts.renderers.CircleItemRenderer));
else {
chart_series.setStyle("itemRenderer",new ClassFactory(mx.charts.renderers.TriangleItemRenderer));

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


Post a Comment

Tech World

Label Cloud

Must Buy

  © Blogger templates by updated with tips

Back to TOP