Share on Google+Share on Google+

CandleStick Control in Flex4

The CandlestickChart Control is a MX Component. There is no Spark component.

CandleStick control in Flex4:

The CandlestickChart Control is a MX Component. There is no Spark component.
The CandlestickChart Control represents financial data. It represents the data in a series of candlesticks which is represents the high, low, opening, and closing values of data series.

You can provide the data to the chart control by using data provider property. You will use <mx:horizontalAxis> or <mx:verticalAxis> and <mx:Series> in it. You will use xField, closeField, highField, lowField and openField property for series.  You can use more than one series in it. You can set the color by using <mx:SolidColor> and <mx:SolidColorStroke>. The tag of CandlestickChart Control is <mx:CandleStickChart>.


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

<s:Application xmlns:fx=""





import mx.collections.ArrayCollection;


private var market1:ArrayCollection = new ArrayCollection( [

{ Date: "25-Jan", Open: 40.75, High: 40.75, Low: 40.24, Close:40.31},

{ Date: "26-Jan", Open: 39.98, High: 40.78, Low: 39.97, Close:40.34},

{ Date: "27-Jan", Open: 40.38, High: 40.66, Low: 40, Close:40.63},

{ Date: "28-Jan", Open: 40.49, High: 40.99, Low: 40.3, Close:40.98},

{ Date: "29-Jan", Open: 40.13, High: 40.4, Low: 39.65, Close:39.95},

{ Date: "1-Feb", Open: 39.00, High: 39.50, Low: 38.7, Close:38.6},

{ Date: "2-Feb", Open: 38.68, High: 39.34, Low: 37.75, Close:38.84},

{ Date: "3-Feb", Open: 38.76, High: 38.76, Low: 38.03, Close:38.12},

{ Date: "4-Feb", Open: 37.98, High: 37.98, Low: 36.56, Close:36.69},

{ Date: "5-Feb", Open: 36.61, High: 37, Low: 36.48, Close:36.86} ]);


private var market2:ArrayCollection = new ArrayCollection( [

{ Date: "25-Jan", Open: 18.50, High: 19, Low: 18.48, Close:18.86},

{ Date: "26-Jan", Open: 19.56, High: 19.98, Low: 18.6, Close:18.69},

{ Date: "27-Jan", Open: 20.81, High: 20.99, Low: 20.03, Close:20.12},

{ Date: "28-Jan", Open: 20.70, High: 21.00, Low: 19.5, Close:20.84},

{ Date: "29-Jan", Open: 21.7, High: 21.79, Low: 20.45, Close:20.6},

{ Date: "1-Feb", Open: 22.45, High: 22.65, Low: 21.65, Close:21.95},

{ Date: "2-Feb", Open: 22.56, High: 22.6, Low: 22.05, Close:22.98},

{ Date: "3-Feb", Open: 22.42, High: 22.70, Low: 22.1, Close:22.63},

{ Date: "4-Feb", Open: 21.67, High: 22.82, Low: 21.67, Close:22.34},

{ Date: "5-Feb", Open: 22.44, High: 22.85, Low: 22.12, Close:22.31} ]);




<mx:SeriesSlide id="interpolate" duration="1500"/>


<s:Panel title="CandleStickChart Control Example" width="677" height="469">




<mx:CandlestickChart id="candlestickchart1"






dataProvider="{market1}" width="558" height="429">


<mx:LinearAxis baseAtZero="false" />



<mx:CategoryAxis categoryField="Date" title="Date"/>



<mx:CandlestickSeries openField="Open"







<mx:SolidColor color="green"/>



<mx:SolidColor color="red"/>



<mx:SolidColorStroke weight="2" color="black"/>






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

<s:RadioButton groupName="sel" label="First Market"

selected="true" click="candlestickchart1.dataProvider=market1;"/>

<s:RadioButton groupName="sel" label="Second Market"






Running Application:

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

Download this code



Posted on: June 8, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null