Chart Event in Flex4


 

Chart Event in Flex4

Chart uses the chartEvent when you perform the operation click and doubleclick on the chart.

Chart uses the chartEvent when you perform the operation click and doubleclick on the chart.

Chart Event in Flex4:

Chart uses the chartEvent when you perform the operation click and doubleclick on the chart. This event is the part of chart package. ChartEvent is used by the mx.charts.events package. If your mouse sensitivity is greater than 3 then the ChartEvent will not work. When you will click on the chart item the ChartEvent will not triggered.

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="s1" color="#738994"/>

<s:SolidColor id="s2" color="#a7c8d8"/>

<s:SolidColor id="s3" color="#406374"/>

</fx:Declarations>

<fx:Script>

<![CDATA[

import mx.charts.events.ChartEvent;

import mx.collections.ArrayCollection;

import mx.controls.Alert;

private function chartEventHandler(event:ChartEvent):void {

Alert.show("Chart Event has been fired");

}

[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="Chart Event Example" width="627" height="542">

<s:layout>

<s:VerticalLayout/>

</s:layout>

<mx:ColumnChart id="cchart"

dataProvider="{student}"

showDataTips="true"

width="621"

fontFamily="verdana" chartClick="chartEventHandler(event);">

<mx:verticalAxis>

<mx:LinearAxis title="Number of Students" />

</mx:verticalAxis>

<mx:horizontalAxis>

<mx:CategoryAxis dataProvider="{student}" categoryField="Stream"/>

</mx:horizontalAxis>

<mx:series>

<mx:ColumnSeries id="cs1"

xField="Stream"

yField="Girls"

displayName="Girls"

fill="{s1}"

/>

<mx:ColumnSeries id="cs2"

xField="Stream"

yField="Boys"

displayName="Boys"

fill="{s2}"

/>

<mx:ColumnSeries id="cs3"

xField="Stream"

yField="TotalStudent"

displayName="TotalStudent"

fill="{s3}"

/>

</mx:series>

</mx:ColumnChart>

<s:HGroup>

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

<s:VGroup>

</s:VGroup>

</s:HGroup>

</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

Ads