Foxtable(狐表)用户栏目专家坐堂 → [求助]关于数据表生成JSON后的排序问题


  共有2399人关注过本帖树形打印复制链接

主题:[求助]关于数据表生成JSON后的排序问题

帅哥哟,离线,有人找我吗?
xndd
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:537 积分:4465 威望:0 精华:0 注册:2014/11/26 15:23:00
[求助]关于数据表生成JSON后的排序问题  发帖心情 Post By:2018/11/15 13:50:00 [显示全部帖子]


我从数据表中获取了数据生成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"
    }
  ]
}


 回到顶部
帅哥哟,离线,有人找我吗?
xndd
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:537 积分:4465 威望:0 精华:0 注册:2014/11/26 15:23:00
  发帖心情 Post By:2018/11/15 14:45:00 [显示全部帖子]

难道只能自己再建一个排序字段吗?

 回到顶部