Home Tutorial Flex Flex4 Components PlotChart Control in Flex4

 
 

PlotChart Control in Flex4
Posted on: June 9, 2010 at 12:00 AM
The PlotChart Control is a MX Component. There is no Spark component.

PlotChart control in Flex4:

The PlotChart Control is a MX Component. There is no Spark component. The PlotChart Control represents the each data value by a single point. This point represents the Cartesian coordinate position along x-axis and y-axis. You can provide the data to the chart control by using data provider property. You will use xField, yField and radius property for series.  You can use more than one series in it. You can change the icon style by busing itrmRenderer property.
There are some default item renderer classes:
1. BoxItemRenderer
2. CircleItemRenderer
3. CrossItemRenderer
4. DiamondItemRenderer
5. ShadowBoxItemRenderer
TriangleItemRenderer
You can set the color by using <mx:SolidColor> and <mx:SolidColorStroke>.
The tag of PlotChart Control is <mx:PlotChart>.

Example:strong>

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

minWidth="955" minHeight="600">

<fx:Declarations>

<s:SolidColor id="s1" color="#990000" alpha=".3"/>

<s:SolidColor id="s2" color="#808080" alpha=".3"/>

<s:SolidColor id="s3" color="#cc00cc" alpha=".3"/>

<s:SolidColorStroke id="scs1" color="#990000" weight="2"/>

<s:SolidColorStroke id="scs2" color="#808080" weight="2"/>

<s:SolidColorStroke id="scs3" color="#cc00cc" weight="2"/>

</fx:Declarations>

<fx:Script>

<![CDATA[

import mx.collections.ArrayCollection;

[Bindable]

public var student:ArrayCollection = new ArrayCollection([

{Stream: "Management", Girls:1000, Boys:1400, TotalStudent:2400},

{Stream: "Computer Science", Girls:800, Boys:1200, TotalStudent:2000},

{Stream: "Mechanical", Girls:200, Boys:1500, TotalStudent:1700},

{Stream: "Electical", Girls:800, Boys:850, TotalStudent:1650},

{Stream: "Electronics", Girls:500, Boys:1000, TotalStudent:1500},

{Stream: "Civil", Girls:300, Boys:900, TotalStudent:1200}

]);

]]>

</fx:Script>

<s:Panel title="PlotChart Control Example" width="546" height="564">

<s:layout>

<s:VerticalLayout/>

</s:layout>

<mx:PlotChart id="pchart"

dataProvider="{student}"

showDataTips="true"

fontFamily="verdana"

width="537" height="445">

<mx:series>

<mx:PlotSeries id="ps1"

xField="Boys"

yField="Girls"

displayName="Boys/Girls"

fill="{s1}"

stroke="{scs1}"

itemRenderer="mx.charts.renderers.CrossItemRenderer"

radius="10"/>

<mx:PlotSeries id="ps2"

xField="TotalStudent"

yField="Boys"

displayName="TotalStudent/Boys"

fill="{s2}"

stroke="{scs2}"

itemRenderer="mx.charts.renderers.DiamondItemRenderer"

radius="10"/>

<mx:PlotSeries id="ps3"

xField="TotalStudent"

yField="Girls"

displayName="TotalStudent/Girls"

fill="{s3}"

stroke="{scs3}"

itemRenderer="mx.charts.renderers.TriangleItemRenderer"

radius="10"/>

</mx:series>

</mx:PlotChart>

<mx:Legend dataProvider="{pchart}"/>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Related Tags for PlotChart Control in Flex4:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.