使用一些知识非常有限的传统speghatti代码。
有两个不同的图表jqPlot
。第一个图表represnts每个YearMonth的国家总数。第二个图表将代表所有国家/地区名称和不同的数字。对于第二张图表,每个国家/地区的数量始终为1,但各国本身将为一个或多个。
第一个图表(如上所示)生成正确,从图表查询中选择一个BAR会返回国家/地区的正确名称。但是在绘制第二张图时会出现问题。给出错误。我错过了什么?
ERROR : Subscript out of range: '[number: 1]'
以下代码通过JSON
调用创建AJAX
并发送到Jquery函数以创建图表。
' Create categories
cat="["
for i = 0 to recCount
if i<>0 then cat=cat&"," end if
cat=cat&""""&data(0,i)&""""
next
cat = cat & "]"
DebugWrite("jsonCat:" & cat)
startYear= ymStart \ 100
startMonth=ymStart mod 100
periodMonths=25
json="[["
y=startYear
m=startMonth
for i=0 to recCount
DebugWrite("recCount:" & recCount)
if i<>0 then json=json&"," end if ' separator for all but first
json=json&"["&i+1
if data(1,i)<>0 then ' check if there are records to prevent / 0
json=json&","& data(1,i)&","""&data(1,i)&""","""&data(0,i)&"""]" '<<<<<THIS LINE CREATING PROBLEM>>>>>>>>>
else
json=json&",0,""n=0""]" ' put empty json data if no records
end if
next
json=json&"]]"
' clear data array, information now in JSON
set data = nothing
DATA的查询如下:
detLevel="Country"
sqlWhere="1=1"
strSQL = "SELECT "&detLevel&" from"&_
" (SELECT "&detLevel&",COUNT(Distinct c.Country) as CountryCount"&_
" FROM BIDashboard.dbo.ISO c"&_
" WHERE ym is not null AND ym="&ym&_
" AND "&sqlWhere&" GROUP BY "&detLevel&") as x"&_
" WHERE "&detLevel&" IN (SELECT DISTINCT "&detLevel&" FROM dbo.ISO)"&_
" ORDER BY 1"