How do I pletely destroy a graph and then redraw one from scratch. The reason I need this is because I want to have the option of changing the graph type from let's say a bar graph to a line graph.
I don't think you can do that strait up, so instead I try to destroy the graph pletely and just make a new one.
plot.destroy();
$.jqplot("graph_id", [data], options);
The destroying went fine, but the reinit did not work at all. Any ideas?
How do I pletely destroy a graph and then redraw one from scratch. The reason I need this is because I want to have the option of changing the graph type from let's say a bar graph to a line graph.
I don't think you can do that strait up, so instead I try to destroy the graph pletely and just make a new one.
plot.destroy();
$.jqplot("graph_id", [data], options);
The destroying went fine, but the reinit did not work at all. Any ideas?
Share asked Nov 23, 2011 at 15:21 Bill Software EngineerBill Software Engineer 7,83224 gold badges106 silver badges191 bronze badges 2- Do you get an error? Works for me: jsfiddle/larsenmtl/jAHYc/2 – Mark Commented Nov 23, 2011 at 23:10
- Yea sorry, I just found out that it was my own error. It works fine now :p – Bill Software Engineer Commented Nov 25, 2011 at 18:53
2 Answers
Reset to default 2Do like the following,
var inti = new Array();
inti.push([0, 0, 0]);
var plot2 = $.jqplot('graph_id', inti, null);
plot2.destroy();
plot2 =$.jqplot("graph_id", [data], options);
this will redraw ur jqplot..
It was my own error, the jqplot worked just fine actually.