gpt4 book ai didi

javascript - 将 JSON 文件加载到 highcharts 中以绘制折线图

转载 作者:行者123 更新时间:2023-11-28 09:07:28 24 4
gpt4 key购买 nike

我想将 JSON 文件加载到 highcharts 中。但是,我无法理解该怎么做。 y 轴标签是从 2046 年开始的年份值。

JSON文件如下:

{
"year":[2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068],
"bus":[4159,458,413,606,1168,850,486,608,899,872,494,1203,868,432,732,753,1528,1564,1419,1843,1888,1610,1016],
"mini_bus":[2064,226,148,185,77,83,82,175,130,19,122,250,475,298,237,285,663,806,1179,593,780,1370,602],
"crane":[8969,800,1524,1491,1740,1629,1151,907,1291,978,829,1271,1798,1212,1477,1592,2263,3278,3594,3643,4524,1969,593],
"car":[24050,1893,2115,2266,3049,3043,5261,2993,4139,2507,3647,5152,4374,2906,7079,4781,5114,5156,4741,6857,12268,8510,5403],
"pick_up":[0,0,0,0,0,0,0,0,0,0,0,0,0,581,478,0,36,736,1588,1287,1975,3087,1208],
"micro":[0,0,0,0,0,0,0,0,0,0,0,0,0,232,884,584,66,138,31,128,145,115,61],
"tempo":[2359,856,1207,62,154,241,117,185,344,388,789,232,248,17,16,48,60,12,18,20,9,2,6],
"motorcycle":[35776,4954,8154,7608,8653,9401,13855,12633,12306,17090,19755,29291,38522,29404,26547,31093,45410,72568,69666,83334,168707,138907,90305],
"tractor":[6769,788,548,262,1396,1814,2183,1257,1265,2248,2542,3519,3189,2485,2191,1374,635,2942,3297,4663,11460,7937,2512],
"others":[102,1549,358,381,372,353,58,352,51,37,102,77,86,43,58,21,0,1535,206,202,31,133,73],
"total":[84248,11524,14467,12861,16609,17414,23193,19110,20425,24139,28280,40995,49560,37610,39699,40531,55775,88735,85739,102570,201787,163640,101779],
"cumulative_total":[84248,95772,110239,123100,139709,157123,180316,199426,219851,243990,272270,313265,362825,400435,440134,480665,536440,625175,710914,813484,1015271,1178911,1280690]
}

请帮忙!

最佳答案

是系列还是数据 JSON?因为您的 JSON 数据不正确,请看看系列对象应该是什么样子:

http://jsfiddle.net/QQDWG/

如果您无法修改 JSON,则应将其转换为正确的形式。

series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]

你的源代码是什么样的?

关于javascript - 将 JSON 文件加载到 highcharts 中以绘制折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16820230/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com