重绘究竟能做什么? [英] What does redraw exactly do?

查看:104
本文介绍了重绘究竟能做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改图表上的内容时,例如myChart.addSeries(mySeriesObj)

When changing somthing on the chart, like myChart.addSeries(mySeriesObj) or

myChart.get("myPointId').update(50);的默认行为是调用重绘函数.

myChart.get("myPointId').update(50); the default behavior is calling the redraw function.

现在,假设我在该图表上有3个系列(A系列,B系列,C系列),而我刚刚更新了A系列中的 1点.它会很快重绘所有图表(系列A,系列B,系列C,轴,标签等)还是只是重新绘制新点?

now, suppose i have 3 series on that chart (seriesA, seriesB, seriesC), and i just updated 1 point in seriesA. would it redraw all the chart (seriesA, seriesB, seriesC, axises, labels, etc...) very fast, or just the new point?

Highchart是否可以与图层一起使用,还是可以在同一框架"中使用?

我之所以这样问是因为我要处理大于1000点的序列,并且我知道在Highchart上使用大数据时性能可能会有些问题. > marker.states.hover 选项或 tooltip 选项)

I am asking this because i am going to work with serieses larger then 1,000 points and i know that there can be some issues with performence when using large data on Highchart.( i already saw that the performance slows when enabling the marker.states.hover option or the tooltip option )

推荐答案

据我所知,Highcharts很可能只会重画脏的组件(在您的情况下,该组件属于该系列).

To my understanding, Highcharts would most likely only redraw the dirty components (in your case the series to which that point belongs to).

chart.redraw()源的某些片段看起来像

Some bits and pieces of the chart.redraw() source looks like

// redraw affected series
each(series, function (serie) {
    if (serie.isDirty && serie.visible &&
            (!serie.isCartesian || serie.xAxis)) { // issue #153
        serie.redraw();
    }
});

调用point.update()时,只有该点所属的系列标记为脏.因此,将在下一个chart.redraw()调用中重画,而其他未更新点的系列将不会重画.

When you call the point.update(), only the serie that the point belongs to is marked dirty. Hence is redrawn on the next chart.redraw() call, whereas other series whose points haven't been updated won't be redrawn.

话虽这么说,chart.redraw()中除上述内容外,还有其他零碎的代码.主要用于重绘轴和图例等内容.似乎其中大多数也是基于类似的isDirty逻辑重绘的,因此不应影响性能.但是,如果性能确实是关键因素,则可以使用第二个参数false调用point.update(),这将跳过隐式的chart.redraw()调用,从而跳过其中的所有内容.然后,您可以在要更新的特定序列(该点所属的序列)上显式调用series.redraw()方法. 警告:这不会重绘轴(和其他填充物),如果点的更新值超出当前轴的极限,则可能需要重绘.此外,文档中未列出series.redraw(),可能表明不鼓励使用它,并且可能会产生意外的结果.
我会在99%的情况下采用chart.redraw()方式,因为大多数情况下性能都是可以接受的.

Having said that, there are other bits and pieces of code in chart.redraw() apart from the above. Mainly for redrawing axes and legends and other stuff. Appears that most of those are also redrawn based on a similar isDirty logic, and hence should not be performance deterrents. But if performance is really a critical factor you can call the point.update() with a second parameter as false, this would skip the implicit chart.redraw() call and hence everything inside it. Then you can explicitly make a call to the series.redraw() method on the particular serie that you wish to update (the one that the point belongs to).
Caution: This won't redraw the axes (and other stuffs), which may need to be redrawn if the updated value of the point is outside the extremes of the current axes. Also the series.redraw() is not listed in the documentation, possibly indicating that using it is discouraged and may produce unexpected results.
I would go with the chart.redraw() way in 99% of cases, as the performance is highly acceptable most of the time.

参考文献:
point.update() api参考
演示@ JsFiddle

References:
point.update() api reference
Demo @ JsFiddle

这篇关于重绘究竟能做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆