2010年9月9日 星期四

AIR SDK 更新

之前沒有注意到,現在我已經將 flex 3.5 SDK 的AIR 更新到2.5
Overlay AIR SDK on Flex SDK

Yahoo 搜尋手寫板 Flex 開發的

今天看到的新聞,對於開發 flex程式及觸控相關的產業應該都很開心吧
可惜 Apple 的 iphone, ipad 應該無法使用

2010年9月8日 星期三

Flex Chart 動態 series

一般的圖表設計,會在 Tag mx:series 內新增多個 series ,然後每個對應不同的欄位 (yField or xField),
因為來自不同欄位,所以可以這樣作,但如果值是來自相同欄位的話,而另一個欄位則儲存分類的類別值,如
Sales Man Date Amount
Sales A 2010/01/01 100
Sales B 2010/01/01 200
不同的 Sales Man就是代表一條線,那要怎麼作呢,這邊有範例可以參考,使用XML方式,而程式碼的部份資料來源是使用 ArrayCollection,應該就可以達成其功能了。

Dynamic Create Series By XML Data Source


coding

try {
var wholist:Array = new Array();
var property:String ;

//partXRData is an arraycollection
for(var i:int =0; i property = partXRData.getItemAt(i).USER_NAME as String;
if (wholist[property] == null){
wholist[property] = new ArrayCollection();

}

(wholist[property] as ArrayCollection).addItem(partXRData.getItemAt(i));

}

var currentSeries:Array = new Array();


var count1:int = 0;
var localSeries:LineSeries = null;
for each (var ac1:ArrayCollection in wholist) {

// Create the new series and set its properties.
localSeries = new LineSeries();
localSeries.dataProvider = ac1;
localSeries.yField = "AVERAGE1";
localSeries.xField = "VALUE_SN";


// Set values that show up in dataTips and Legend.
localSeries.displayName = ac1.getItemAt(0).USER_NAME;

// Back up the current series on the chart.

// Add the new series to the current Array of series.
currentSeries.push(localSeries);


}
// Add the new Array of series to the chart.
avgChart1.series = currentSeries;

}catch(error:Error) {

}