我从数据表中获取了数据生成echarts所需要的json,但是发现月份排序乱了。
我的表:
此主题相关图片如下:11.png
此主题相关图片如下:22.png
就算是加了 order by [_Identify] 也没有用。
生成的图表如下:
此主题相关图片如下:33.png
代码如下:
Dim cmd1 As new SQLCommand
Dim cmd2 As new SQLCommand
cmd1.CommandText = "S elect * from {salesshiji} where [years] = '2018' order by [_Identify]"
cmd2.CommandText = "S elect * from {salesjihua} where [years] = '2018' order by [_Identify]"
Dim dt1 = cmd1.ExecuteReader
Dim dt2 = cmd2.ExecuteReader
Dim Arys1 As List(Of String())
Dim Arys2 As List(Of String())
Arys1 = dt1.GetValues("month|nums")
Arys2 = dt2.GetValues("month|nums")
Dim salesdata As New JObject
Dim xmlb As New JArray
Dim i As Integer
salesdata("xsjh") = xmlb
For Each Ary1 As String() In Arys1
xmlb.Add(New Jobject)
xmlb(i)("month") = Ary1(0).ToString
xmlb(i)("num") = Ary1(1).ToString
i += 1
Next
Dim salesdata2 As New JObject
Dim xmlb2 As New JArray
Dim j As Integer
j = 0
salesdata("sjxs") = xmlb2
For Each Ary2 As String() In Arys2
xmlb2.Add(New Jobject)
xmlb2(j)("month") = Ary2(0).ToString
xmlb2(j)("num") = Ary2(1).ToString
j += 1
Next
'Output.Show(salesdata.ToString)
JSON格式如下:
{
"xsjh": [
{
"month": "八月",
"num": "330.5"
},
{
"month": "二月",
"num": "29.56"
},
{
"month": "九月",
"num": "268.99"
},
{
"month": "六月",
"num": "150.39"
},
{
"month": "七月",
"num": "166.47"
},
{
"month": "三月",
"num": "85.82"
},
{
"month": "十二月",
"num": "141.11"
},
{
"month": "十一月",
"num": "184.8"
},
{
"month": "十月",
"num": "209.77"
},
{
"month": "四月",
"num": "118.6"
},
{
"month": "五月",
"num": "200.11"
},
{
"month": "一月",
"num": "110.34"
}
],
"sjxs": [
{
"month": "八月",
"num": "300"
},
{
"month": "二月",
"num": "20"
},
{
"month": "九月",
"num": "300"
},
{
"month": "六月",
"num": "200"
},
{
"month": "七月",
"num": "200"
},
{
"month": "三月",
"num": "80"
},
{
"month": "十二月",
"num": "100"
},
{
"month": "十一月",
"num": "200"
},
{
"month": "十月",
"num": "200"
},
{
"month": "四月",
"num": "100"
},
{
"month": "五月",
"num": "200"
},
{
"month": "一月",
"num": "150"
}
]
}