echarts icon indicating copy to clipboard operation
echarts copied to clipboard

How to avoid all chart component re-rendering of chart on calling setOption to update graphics element

Open amittonge opened this issue 8 years ago • 5 comments

One-line summary [问题简述]

I am calling to setOption to only show/hide graphics element of type image but doing this causes hole chart re-render can we avoid this somehow in echart.

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

myChart.setOption({ graphic: { id: 'image1', left: left, top: top, invisible: false, silent: false } }, false, false, true);

myChart.setOption({ graphic: { id: 'image1', invisible: true, silent: true } }, false, false, true);

Expected behaviour [期望结果]

ECharts option [ECharts配置项]

 myChart.setOption({
                    graphic: {
                        id: 'image1',
                        left: left,
                        top: top,
                        invisible: false,
                        silent: false
                    }
                }, false, false, true);

Other comments [其他信息]

amittonge avatar Aug 08 '18 06:08 amittonge

setOption takes three parameters at most, (option: Object, notMerge?: boolean, lazyUpdate?: boolean). If notMerge is set to be false, it will only update the changed part.

Ovilia avatar Aug 09 '18 03:08 Ovilia

Thanks for reply. I agree with you, if notMerge is set to be false, it will only update the changed part but it re-render whole chart which I want to avoid. In my case, I have render scatter plot which large amount of data and later I just call setOption to show/hide graphics element of type image on some event, But each time I call setOption, it re-render whole chart which I want to avoid in this case. Is their any way to do this.

amittonge avatar Aug 17 '18 06:08 amittonge

In that case, you need to set z of some part to be a different value, so that it will be in a different canvas. And updates will only happen in that canvas.

Ovilia avatar Aug 29 '18 07:08 Ovilia

Hi Ovilia, You mean I should set higher z value for graphics element which I am going to show/hide. Please correct me if I am wrong with example.

amittonge avatar Aug 29 '18 07:08 amittonge

I mean you should put those often change into a different z, so that when you show/hide or change them, the rest will not be re-draw.

Ovilia avatar Aug 30 '18 03:08 Ovilia