[Flex] LineChart
개발/FLEX & AIR2009. 11. 24. 12:42
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var stockDataAC:ArrayCollection = new ArrayCollection( [
{date: "2005, 7, 27", close: 41.71},
{date: "2005, 7, 28", close: 42.21},
{date: "2005, 7, 29", close: 42.11},
{date: "2005, 8, 1", close: 42.71},
{date: "2005, 8, 2", close: 42.99},
{date: "2005, 8, 3", close: 44} ]);
public function myParseFunction(s:String):Date {
// Get an array of Strings from the comma-separated String passed in.
var a:Array = s.split(",");
// Create the new Date object. Subtract one from
// the month property because months are zero-based in
// the Date constructor.
var newDate:Date = new Date(a[0],a[1]-1,a[2]);
return newDate;
}
]]>
</mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var stockDataAC:ArrayCollection = new ArrayCollection( [
{date: "2005, 7, 27", close: 41.71},
{date: "2005, 7, 28", close: 42.21},
{date: "2005, 7, 29", close: 42.11},
{date: "2005, 8, 1", close: 42.71},
{date: "2005, 8, 2", close: 42.99},
{date: "2005, 8, 3", close: 44} ]);
public function myParseFunction(s:String):Date {
// Get an array of Strings from the comma-separated String passed in.
var a:Array = s.split(",");
// Create the new Date object. Subtract one from
// the month property because months are zero-based in
// the Date constructor.
var newDate:Date = new Date(a[0],a[1]-1,a[2]);
return newDate;
}
]]>
</mx:Script>
<mx:Panel title="DateTimeAxis Example" height="550" width="500">
<mx:LineChart id="mychart" height="500" width="450"
paddingRight="5" paddingLeft="5"
showDataTips="true" dataProvider="{stockDataAC}">
<mx:horizontalAxis>
<mx:DateTimeAxis dataUnits="days" parseFunction="myParseFunction"/>
</mx:horizontalAxis>
<mx:LineChart id="mychart" height="500" width="450"
paddingRight="5" paddingLeft="5"
showDataTips="true" dataProvider="{stockDataAC}">
<mx:horizontalAxis>
<mx:DateTimeAxis dataUnits="days" parseFunction="myParseFunction"/>
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis baseAtZero="false" />
</mx:verticalAxis>
<mx:LinearAxis baseAtZero="false" />
</mx:verticalAxis>
<mx:series>
<mx:LineSeries yField="close" xField="date" displayName="AAPL"/>
</mx:series>
</mx:LineChart>
</mx:Panel>
</mx:Application>
<mx:LineSeries yField="close" xField="date" displayName="AAPL"/>
</mx:series>
</mx:LineChart>
</mx:Panel>
</mx:Application>
'개발 > FLEX & AIR' 카테고리의 다른 글
XML과 E4X 다루기 (0) | 2009.12.20 |
---|---|
[Flex] PieChart (0) | 2009.11.24 |
[Chart] ColumnChart, BarChart (0) | 2009.11.24 |
[FLEX] HTTPService를 사용하여 파라미터 전송하기 (0) | 2009.10.25 |
[FLEX] HTTPService 서비스 사용하기 - 데이터그리드 결과값 바인딩 (0) | 2009.10.25 |