虽然这是一个老问题。
由于接受的答案对我不起作用,我也无法在 jqPlot 文档中找到解决方案。我来到了这个解决方案
var series = [[1,2],[2,3]];
chartObj.replot({data:series});
Src:看看replot 函数。
function (am) {
var an = am || {};
var ap = an.data || null;
var al = (an.clear === false) ? false : true;
var ao = an.resetAxes || false;
delete an.data;
delete an.clear;
delete an.resetAxes;
this.target.trigger("jqplotPreReplot");
if (al) {
this.destroy()
}
if (ap || !L.isEmptyObject(an)) {
this.reInitialize(ap, an)
} else {
this.quickInit()
} if (ao) {
this.resetAxesScale(ao, an.axes)
}
this.draw();
this.target.trigger("jqplotPostReplot")
}
线
if (ap || !L.isEmptyObject(an)) {
this.reInitialize(ap, an)
}
向我们展示了 ap 需要一个真实值才能将其作为第一个参数传递给内部重新初始化函数。定义为var ap = an.data || null;
就这么简单,但不幸的是没有记录在我能找到的任何地方
请注意,如果您想重绘 jqPlot 选项中定义的某些内容,例如图例标签,您可以将任何选项传递给 replot 函数。请记住,要重新绘制的实际系列必须命名为“数据”
var options = {
series : [{
label: 'Replotted Series',
linePattern: 'dashed'
}],
//^^^ The options for the plot
data : [[1,2],[2,3]]
//^^^ The actual series which should get reploted
}
chartObj.replot (options)