2013-11-01 35 views
0

我想知道我怎麼可以拆分該數據集爲多個陣列作爲HighCharts線圖創建SQL數據集的多個陣列在傳統的ASP爲HighCharts

下面的resultSet數據集中使用(0,I)包含日期和
resultSet(1,i)包含一個值。

我希望能夠取決於日期的年份;

Year(resultSet(0,i))將數據集分解爲HighCharts折線圖的多個數據集。基本上像

if recordDate = Year(resultSet(0,i)) then 
      ''populate recordSet1 
    recordSet1(i) = resultSet(1,i) 
else 
      'if the records now have a new date 
      'add a year to the recordDate, since they are in chronological order in the resultset 
    recordDate = recordDate + 1 
      'do the check on that record now and add it to a new resultSet, then re-enter the loop and populate the new recordSet 
    if recordDate = Year(resultSet(0,i)) then 
      recordSet2(i) = resultSet(1,i) 
    end if 
End If 

,但我想不出如何動態創建數組的名字,這樣我可以有多個記錄集。

'Get CurrentYear to Compare Dataset To 
dim CurrentYear 
CurrentYear = Year(Date) 

dim totalYears 
dim recordDate 
    totalYears = (adoRsChart("yr_count") - 1) 
    recordDate = CurrentYear - totalYears 
dim dateYearDiff 
dim yAxisData() 
dim xAxisData() 
dim resultSet 
resultSet = adoRsChart.GetRows() 

For i = 0 to UBound(resultSet, 2) 
    reDim preserve xAxisData(i) 
    xAxisData(i) = resultSet(1,i) 
    response.write(resultSet(0,i) & "<br/>") 
    response.write(resultSet(1,i) & "<br/>") 
    response.write(resultSet(2,i) & "<br/>") 
    response.write(resultSet(3,i) & "<br/>") 
    reDim preserve yAxisData(i) 
    yAxisData(i) = "'" & resultSet(3,i) & "'" 
Next 
+0

循環內循環會有幫助嗎?這樣你可以有多個記錄集,而不用擔心動態創建名稱 –

+0

你的數據/系列在輸出中的外觀如何?這是一個JSON或你打印一個文本? –

回答

0

實際上,你可以有一個數組的數組...

chartData(i,j)(k) 

...但我真的不會推薦它。除了「無法把我的大腦圍繞」問題之外,這是一種在服務器上耗盡內存的簡單方法。

您可以在循環中生成圖表,即只是重複使用相同的變量?