2
我可以在创建时在flot上绘制分段,方法是将其添加到选项中。动态更改flot中的标记
markings: [
{ xaxis: { from: 150, to: 200 }, color: "#ff8888" },
{ xaxis: { from: 500, to: 750 }, color: "#ff8888" }
]
现在我想删除这些标记并通过调用函数添加新的标记。我已经尝试了以下,但它还没有工作。我想我不是以正确的方式访问网格。它在选项中,但不知道如何去实现它。我也不知道如何去除旧的标记。
CustomPlot.prototype.setRibbons = function setRibbons(x1, x2) {
alert("ok"); \\this works
this.plot.getOptions().grid.markings.axis.from = x1;
this.plot.getOptions().grid.markings.axis.to = x2;
this.plot.getOptions().grid.markings.color = "#ff8888";
this.plot.setupGrid();
this.plot.draw();
你有没有[检查你的控制台](http://stackoverflow.com/documentation/javascript/185/hello-world/714/using-console-log)的错误?在你的Plunker中,你似乎没有在'grid.markings'为'null'之前创建标记。 –