以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- json生成 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=103548) |
-- 作者:zhy400137 -- 发布时间:2017/7/11 13:49:00 -- json生成 {
foxtable:[ {name: \'北京\',value: 20 }, {name: \'天津\',value: 10 }, {name: \'上海\',value: 30 }, {name: \'重庆\',value: 8 }, {name: \'河北\',value: 5 }, {name: \'河南\',value: 7 }, {name: \'云南\',value: 3 }, {name: \'辽宁\',value: 11 }, {name: \'黑龙江\',value: 12 }, {name: \'湖南\',value: 13 }, {name: \'安徽\',value: 18 }, {name: \'山东\',value: 20 }, {name: \'新疆\',value: 10 }, {name: \'江苏\',value: 11 }, {name: \'浙江\',value: 25 }, {name: \'江西\',value: 6 }, {name: \'湖北\',value: 16 }, {name: \'广西\',value: 12 }, {name: \'甘肃\',value: 8 }, {name: \'山西\',value: 9 }, {name: \'内蒙古\',value: 10 }, {name: \'陕西\',value: 11 }, {name: \'吉林\',value: 12 }, {name: \'福建\',value: 13 }, {name: \'贵州\',value: 8 }, {name: \'广东\',value: 30 }, {name: \'青海\',value: 10 }, {name: \'西藏\',value: 5 }, {name: \'四川\',value: 9 }, {name: \'宁夏\',value: 10 }, {name: \'海南\',value: 11 }, {name: \'台湾\',value: 3 }, {name: \'香港\',value: 5 }, {name: \'澳门\',value: 2 } ] } 今天看了版主在FT里使用百度ECHARTS图表的例子比较喜欢,但对查询出来的dt 如何生成JSON看了帮助还是有点不懂,能否基于上面的例子,写一个查询表如何生 成上述JSON的小例,供我等学习下,谢谢!
|
-- 作者:zhy400137 -- 发布时间:2017/7/11 13:55:00 -- foxtable:[ 主要是这里,我看狐表帮助里生成的都带引号 "foxtable:[",这个不影响吗? |
-- 作者:有点蓝 -- 发布时间:2017/7/11 14:42:00 -- 这个不影响,js支持这种用法。 生成json方法参考 ...... Case "getdata.htm" Dim json As String If e.GetValues("type") = "1" Then json = FileSys.ReadAllText("d:\\web\\lib\\data1.txt") Else Dim jo As New JObject Dim ja As New Jarray \'定义数组 Dim arr() As String = {"北京","天津","上海","重庆","河北","河南","云南"} For Each csh As String In arr Dim j2 As new JObject j2("name") = csh j2("value") = Rand.Next(3,20) ja.Add(j2) Next jo("foxtable") = ja json = jo.ToString End If e.WriteString(json ) ...... 如果是查表把上面代码的数组和赋值改为从数据库查询的结果就可以了
|
-- 作者:zhy400137 -- 发布时间:2017/7/11 20:22:00 -- var data = [ [[28604,77,17096869,\'Australia\',1990],[31163,77.4,27662440,\'Canada\',1990],[1516,68,1154605773,\'China\',1990],[13670,74.7,10582082,\'Cuba\',1990],[28599,75,4986705,\'Finland\',1990],[29476,77.1,56943299,\'France\',1990],[31476,75.4,78958237,\'Germany\',1990],[28666,78.1,254830,\'Iceland\',1990],[1777,57.7,870601776,\'India\',1990],[29550,79.1,122249285,\'Japan\',1990],[2076,67.9,20194354,\'North Korea\',1990],[12087,72,42972254,\'South Korea\',1990],[24021,75.4,3397534,\'New Zealand\',1990],[43296,76.8,4240375,\'Norway\',1990],[10088,70.8,38195258,\'Poland\',1990],[19349,69.6,147568552,\'Russia\',1990],[10670,67.3,53994605,\'Turkey\',1990],[26424,75.7,57110117,\'United Kingdom\',1990],[37062,75.4,252847810,\'United States\',1990]], [[44056,81.8,23968973,\'Australia\',2015],[43294,81.7,35939927,\'Canada\',2015],[13334,76.9,1376048943,\'China\',2015],[21291,78.5,11389562,\'Cuba\',2015],[38923,80.8,5503457,\'Finland\',2015],[37599,81.9,64395345,\'France\',2015],[44053,81.1,80688545,\'Germany\',2015],[42182,82.8,329425,\'Iceland\',2015],[5903,66.8,1311050527,\'India\',2015],[36162,83.5,126573481,\'Japan\',2015],[1390,71.4,25155317,\'North Korea\',2015],[34644,80.7,50293439,\'South Korea\',2015],[34186,80.6,4528526,\'New Zealand\',2015],[64304,81.6,5210967,\'Norway\',2015],[24787,77.3,38611794,\'Poland\',2015],[23038,73.13,143456918,\'Russia\',2015],[19360,76.5,78665830,\'Turkey\',2015],[38225,81.4,64715810,\'United Kingdom\',2015],[53354,79.1,321773631,\'United States\',2015]] ]; 那散点图中这样的也是JSON吗?还是是单纯的数组,要如何生成呢?谢谢
|
-- 作者:有点蓝 -- 发布时间:2017/7/11 21:22:00 -- 这个是数组,也可以通过json返回,和1楼的用法是一样的。 { mydata: [ [[28604,77,17096869,\'Australia\',1990],[31163,77.4,27662440,\'Canada\',1990],[1516,68,115460........ } ...... var data = json对象.mydata
|