有没有推荐的方法来清除jQuery Flot图表?我在API参考中找不到任何信息。
您提到的“clear”是指“清除整个图形”,还是只清除数据?
若要清除整个图形,请使用:$('#canvas_id').empty();
如果只想清除数据,请调用通常的$.plot(placeholder, data, options);
,其中data为空。
var plot = $.plot(placeholder, data, options);
// some other code
//to completely remove flot chart call
plot.destroy(); // remove graph and all bindings
只清除图表,请使用Matt Ball的答案。