gpt4 book ai didi

javascript - 使用 morris 从 json 响应生成动态条形图

转载 作者:行者123 更新时间:2023-12-03 10:43:24 25 4
gpt4 key购买 nike

我有一个网络服务,我可以从中解析数据并绘制条形图。我正在使用 morris.js 库。

问题:我有一个像这样的网络服务:

http://localhost:9999/hellowebservice/search?select=*

在选择查询参数时,我传递要搜索的值,如下所示:

http://localhost:9999/hellowebservice/search?select=x,y

json 响应如下所示:

  "hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_id" : "abcd",
"_score" : 1.0,
"fields" : {
"x" : [ "10" ],
"y : [ "20" ]
}
}]
}
}

下次当我在选择字段中输入x, y, z时,我希望条形图根据输入的字段自动更新

注意:我使用 _id 值位于 x 轴上,并使用输入的任何选择值位于 y 轴上。

最佳答案

找到解决方案:

带有虚拟值的初始化莫里斯图。然后使用morrisChart.setData()方法动态更新图表。

关于javascript - 使用 morris 从 json 响应生成动态条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28668238/

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