开发者

jqPlot .replot() not updating series

开发者 https://www.devze.com 2023-04-12 04:22 出处:网络
This issue is so deceptively simple that I\'m having trouble getting my head around what the problem is.

This issue is so deceptively simple that I'm having trouble getting my head around what the problem is.

I have a jqPlot line chart ("plot1") with a single series and a legend. I've bound the .click event of an anchor on my page to call the following function:

fu开发者_如何学Gonction changeSeriesColor() {
    plot1.series[0].color = "#33ff66";
    plot1.replot();
}

The event fires and calls the function without errors. The series color on the LEGEND is updated to the new color but the LINE color is unchanged. The jqPlot docs don't have much to say about this sort of thing (I wish there were more, and more diverse, examples) and I can't find anything on stackoverflow or anywhere else that addresses this.

This behavior is consistent in Chrome 12.0.742.112, Firefox 6.0.2 and IE 9.0.8112.16421 so I'm pretty sure it's not some weird browser-specific quirk.

I'm at a loss on this one. Help?!


I am late but for any others who come across this problem, this may be of use? (from https://bitbucket.org/cleonello/jqplot/issue/358/replot-ignoring-seriescolor)

Unfortunately, modifying plot options post plot initialization has no effect for replot/redraw. This isn't a bug. those options are used only at initialization to set properties on the renderers. Changing them after the plot is initialized has no effect.

What you can do is change the relevant properties on the rendereres. In your case, this would be:

  this._jqChart.series[0].renderer.shapeRenderer.strokeStyle = colors[0];
  this._jqChart.series[0].markerRenderer.shapeRenderer.strokeStyle = colors[0];  // if markers not filled.
  this._jqChart.series[0].markerRenderer.shapeRenderer.fillStyle = colors[0];
0

精彩评论

暂无评论...
验证码 换一张
取 消