Basically, I want the user to be able to change the type of the graph by clicking a drop down menu: BarRenderer, PieRenderer, etc. The data is the same. I know I can call $.jqplot() again on the same element, but then I'll have to pass all the setting again. And my page have a variable number of graphs, which makes that option a very bad choice.
基本上,我希望用户能够通过单击下拉菜单来更改图形的类型:BarRenderer、PieRenderer等。数据是相同的。我知道我可以在相同的元素上再次调用$.jqplot(),但是我必须再次通过所有设置。我的页面有很多不同的图形,这使得这个选项很糟糕。
I found a link about this: http://groups.google.com/group/jqplot-users/browse_thread/thread/efe6511cd9496f16/5c625baf78d3b0ae but it seems I still have to call $.jqplot() again.
我找到了一个关于这个的链接:http://groups.google.com/group/jqplot- users/browse_thread/efe6511cd9496f16 /5c625baf78d3b0ae,但似乎我仍然需要再次调用$.jqplot()。
Is there a better way to do this? And one more small question: is it just me, or the documentation on jqplot is bad? I have to look through multiple places to find a option I want (and sometimes, the option isn't documented, or I couldn't find it somehow). How do you learn how to use jqplot?
有更好的方法吗?还有一个小问题:是只有我,还是jqplot的文档不好?我必须遍历多个地方才能找到一个我想要的选项(有时候,这个选项没有文档记录,或者我以某种方式找不到)。如何学习使用jqplot?
1 个解决方案
#1
5
I think the docs are ok, but you will find hidden features inside of it or quirks that aren't documented. IIRC (it's been a while) you will have to call $.jqplot() again but you first need to .empty() your target or you'll get extra / messed up canvases.
我认为文档是可以的,但是你会发现其中隐藏的特性或者没有文档记载的怪癖。IIRC(已经有一段时间了)您将不得不再次调用$.jqplot(),但是首先需要.empty()您的目标,否则您将获得额外的/混乱的画布。
What you really need to do is save your data and allow it to be called later:
您真正需要做的是保存您的数据,并允许稍后调用它:
//This isn't real jqplot syntax but it should give you a good idea of what I'm explaining
var charts = [{name:"chart1",renderer:"pie",data:[[1,2],[2,3]]}]
$('#graph').jqplot(charts[0]);
//later
charts[0].renderer = "bar";
$('#graph').empty().jqplot(charts[0]);
#1
5
I think the docs are ok, but you will find hidden features inside of it or quirks that aren't documented. IIRC (it's been a while) you will have to call $.jqplot() again but you first need to .empty() your target or you'll get extra / messed up canvases.
我认为文档是可以的,但是你会发现其中隐藏的特性或者没有文档记载的怪癖。IIRC(已经有一段时间了)您将不得不再次调用$.jqplot(),但是首先需要.empty()您的目标,否则您将获得额外的/混乱的画布。
What you really need to do is save your data and allow it to be called later:
您真正需要做的是保存您的数据,并允许稍后调用它:
//This isn't real jqplot syntax but it should give you a good idea of what I'm explaining
var charts = [{name:"chart1",renderer:"pie",data:[[1,2],[2,3]]}]
$('#graph').jqplot(charts[0]);
//later
charts[0].renderer = "bar";
$('#graph').empty().jqplot(charts[0]);