question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

echarts.js:3066 Uncaught Error: `setOption` should not be called during main process

See original GitHub issue

One-line summary [问题简述]

用socket.io接收数据并更新option,setoption刷新,有时候会出现错误:echarts.js:3066 Uncaught Error: setOption should not be called during main process。

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: “version”: “3.2.3”,
  • Browser version [浏览器类型和版本]:Google chrome 版本 54.0.2840.71 m (64-bit)
  • OS Version [操作系统类型和版本]:windows 7 61bit

Expected behaviour [期望结果]

了解原因及解决办法。

ECharts option [ECharts配置项]

option = {
               title: {
                    text: '位移'
                },
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    data:[]/* data.map(function (item) {
                        return item[0];
                    })*/
                },
                yAxis: {
                    splitLine: {
                        show: false
                    },
                    // max:100
                },
                toolbox: {
                    left: 'center',
                    feature: {
                        dataZoom: {
                            yAxisIndex: 'none'
                        },
                        restore: {},
                        saveAsImage: {}
                    }
                },
                // dataZoom: [{
                //     startValue: '2014-06-01'
                // }, {
                //     type: 'inside'
                // }],
                visualMap: [{
                    top: 10,
                    right: 10,
                    pieces: [{
                        // gt: 0,
                        lte: 60,
                        color: '#096'
                    }, {
                        gt: 60,
                        lte: 70,
                        color: '#ffde33'
                    }, {
                        gt: 70,
                        lte: 80,
                        color: '#E9967A'
                    },{
                        gt: 80,
                        color: '#EE0000'
                    }],
                    outOfRange: {
                        color: '#999'
                    }
                }
                ],
                series: {
                    name: 'displacement',
                    type: 'bar',
                    data:[],/* data.map(function (item) {
                        return item[1];
                    }),*/
                    markLine: {
                        silent: false,
                        data: [{
                            yAxis: 60
                        }, {
                            yAxis: 70
                        }, {
                            yAxis: 80
                        }]
                    }
                }
}

Other comments [其他信息]

default

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:28 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
shyangscommented, Nov 14, 2017

我也遇到這個報錯

不知道跟我用了 window.setTimeout(function(){ }); 有沒關係.

看了上面的討論, 暫時這樣繞過.(不知道是不是好方法)

echartsInstance.clear();
echartsInstance.setOption(option);

#3806 , #6281 也是這樣的報錯訊息.

4reactions
pissangcommented, Dec 16, 2021

vue 会对所有 data 下挂的对象下的所有属性做深度的 proxy,所以不建议把 echarts 或者其它库的实例挂在 data 下,第一是产生不必要的性能损耗,第二是可能会产生未知的 bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: `setOption` should not be called during main process ...
Version 5.1.2 Steps to reproduce setOption(option with some error), Error: setOption should not be called during main process. when I fixed ...
Read more >
echarts.js:3066 Uncaught Error: `setOption` should not be ...
[GitHub] [echarts] tianzhen123 commented on issue #5093: ... Uncaught Error: `setOption` should not be called during main process.
Read more >
Uncaught Error: `setOption` should not be called during main ...
ECharts : Uncaught Error: `setOption` should not be called during main process_第一段代码的博客-CSDN博客
Read more >
javascript - How to fix the 'setOption' does not exist on type ...
A div does not have properties like resize() and setOption() . ... to store the chart because it is mutable const chart =...
Read more >
`setOption` should not be called during main process._百度知道
其中遇到Echart在最后SetOption()方法的时候,报错如下: echarts.js:3066 Uncaught Error: `setOption` should not be called during main process
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found