Skinning Data Item in Chart in Flex4


 

Skinning Data Item in Chart in Flex4

In this section you can see how we can provide the skin to data item in chart control.

In this section you can see how we can provide the skin to data item in chart control.

Skinning Data Item in Chart in Flex4:

In this section you can see how we can provide the skin to data item in chart control. We will use the itemRenderer for providing the skin to data item. In this example we change the representation of data item. we use the image for showing the data values in the chart.

Example:

<?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="s3" color="#cc00cc" alpha=".3"/>

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

</fx:Declarations>

<fx:Style>

@namespace s "library://ns.adobe.com/flex/spark";

@namespace mx "library://ns.adobe.com/flex/mx";

mx|Legend{

label-placement:right;

marker-height:30;

marker-width:30;

background-color:#000000;

}

mx|LegendItem{

font-family: verdana;

font-size:12px;

color: #FFFFFF;

font-weight:bold;

}

</fx:Style>

<fx:Script>

<![CDATA[

import mx.collections.ArrayCollection;

import mx.core.BitmapAsset;

0

[Bindable]

[Embed(source="C:/work/bikrant/flex4component/skinningchartitem/girlstud.jpg")]

1

public var gitlStudent:Class;

[Bindable]

2

[Embed(source="C:/work/bikrant/flex4component/skinningchartitem/students.gif")]

public var boyStudent:Class;

3

[Bindable]

public var gitlStudentFactory:ClassFactory = new ClassFactory(gitlStudent);

4

[Bindable]

public var boyStudentFactory:ClassFactory = new ClassFactory(boyStudent);

5

[Bindable]

public var student:ArrayCollection = new ArrayCollection([

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

6

{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},

7

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

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

]);

8

]]>

</fx:Script>

<s:Panel title="

9

Skinning Data item in Chart Example" width="546" height="564">

<s:layout>

<s:VerticalLayout horizontalAlign="center"/>

0

</s:layout>

<mx:PlotChart id="pchart"

dataProvider="{student}"

1

showDataTips="true"

fontFamily="verdana"

width="537" height="445">

2

<mx:series>

<mx:PlotSeries id="ps1"

xField="Boys"

3

yField="Girls"

displayName="Boys/Girls"

itemRenderer="{gitlStudentFactory}"

4

legendMarkerRenderer="{gitlStudentFactory}"

radius="20"/>

<mx:PlotSeries id="ps2"

5

xField="TotalStudent"

yField="Boys"

displayName="TotalStudent/Boys"

6

itemRenderer="{boyStudentFactory}"

legendMarkerRenderer="{boyStudentFactory}"

radius="20"/>

7

<mx:PlotSeries id="ps3"

xField="TotalStudent"

yField="Girls"

8

displayName="TotalStudent/Girls"

fill="{s3}"

stroke="{scs3}"

9

itemRenderer="mx.charts.renderers.TriangleItemRenderer"

radius="10"/>

</mx:series>

0

</mx:PlotChart>

<mx:Legend dataProvider="{pchart}" direction="horizontal" cornerRadius="20"/>

</s:Panel>

1

</s:Application>

Output:

Running Application:

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

2

Download this code

Ads