【问题标题】:create multiple arrays from SQL dataset in classic ASP for HighCharts在经典 ASP 中为 HighCharts 从 SQL 数据集创建多个数组
【发布时间】:2013-11-01 19:30:00
【问题描述】:

我想知道如何将此数据集拆分为多个数组以用作 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

【问题讨论】:

  • 循环中的循环有帮助吗?这样您就可以拥有多个记录集,而不必担心动态创建名称
  • 您的数据/系列在输出中的外观如何?它是一个 json 还是你打印一个文本?

标签: javascript jquery arrays asp-classic highcharts


【解决方案1】:

你实际上可以有一个数组数组...

chartData(i,j)(k)

...但我真的不推荐它。除了“无法绕开它”的问题之外,这是一种在服务器上耗尽内存的简单方法。

您能否在循环中生成图表,即重复使用相同的变量?

【讨论】:

    猜你喜欢
    • 2011-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多