重用 jqplot 对象来加载或重新绘制数据
我正在使用 JqPlot 绘制图表,我的问题是我想在不同的点击事件上加载不同的数据。
但是,一旦图表被创建并第一次加载数据;我不知道如何在另一个事件触发时加载数据,这意味着我想重用图表对象,并希望在事件触发时加载/重新绘制数据,例如...
chartObj.data = [graphData]
I am using JqPlot for charts , my problem is i want to load different data on different click events.
But once the chart is created and loaded with the data for the first time; i don't know then how to load data when another event fires that means i want to reuse the chart object and want to load/replot the data when events get fired something like...
chartObj.data = [graphData]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这似乎可以重新绘制数据。
另外,您还可以检查以下内容:https://groups.google.com/group/jqplot-users /browse_thread/thread/59df82899617242b/77fe0972f88aef6d%3Fq%3D%2522Groups.%2BCom%2522%2377fe0972f88aef6d&ei=iGwTS6eaOpW8Qpmqic0O&sa=t&ct=res&cd=71&源=组&usg=AFQjCHotAa6Z5CIi_-BGTHr_k766ZXXLQ?hl=恩,希望有帮助。
That seems to work to replot data.
Also, you can check this: https://groups.google.com/group/jqplot-users/browse_thread/thread/59df82899617242b/77fe0972f88aef6d%3Fq%3D%2522Groups.%2BCom%2522%2377fe0972f88aef6d&ei=iGwTS6eaOpW8Qpmqic0O&sa=t&ct=res&cd=71&source=groups&usg=AFQjCNHotAa6Z5CIi_-BGTHr_k766ZXXLQ?hl=en, hope it helps.
虽然这是一个老问题了。
由于接受的答案对我不起作用,而且我也无法在 jqPlot 文档中找到解决方案。我找到了这个解决方案
Src:查看
replot
函数。线路
if (ap || !L.isEmptyObject(an)) {
this.reInitialize(ap, an)
}
向我们表明 ap 需要一个真值才能将其作为第一个参数传递给内部重新初始化函数。其定义为 var ap = an.data || null;
就这么简单,但遗憾的是没有记录在我能找到的任何地方。
请注意,如果您想重绘 jqPlot 选项中定义的某些内容(例如图例标签),您可以将任何选项传递给 replot 函数。请记住要重新绘制的实际系列必须命名为“数据”
Though this is an old question.
As the accepted Answer didn't work for me and i couldn't find a solution in the jqPlot docs either. I came to this solution
Src: Taking a look at the
replot
function.The line
if (ap || !L.isEmptyObject(an)) {
this.reInitialize(ap, an)
}
shows us it needs a truthy value for ap to pass it as first parameter to the internal reinitialize function. which is defined as
var ap = an.data || null;
Its as simple as this but unfortunately not documented anywhere i could find it
Note that if you want to redraw some things defined in your jqPlot options, like legend labels, you can just pass any option to the replot function. Just remember the actual series to replot has to be named "data"
jqplot 允许快速动态数据更新。
根据文档(数据部分) ,“不应在选项对象中指定数据...” (fiddle< /a>)
“...但作为 $.jqplot() 函数的第二个参数传递。”
fiddle 表明这可以通过类似的性能来完成。
jqplot allows for a fast dynamic data update.
According to the documentation (data section), "Data should NOT be specified in the options object ..." (fiddle)
"... but be passed in as the second argument to the $.jqplot() function."
The fiddle shows this can be done with similar performance.
在渲染图表之前清空图表 div
Empty graph div, before rendering the graph
API 有一个 replot/redraw 方法
The API has a replot/redraw method