echarts 4.0.2里当dataZoom打开并且series为空时,setOption notMerge抛出异常

mitkmikd  于 2022-10-23  发布在  Echarts
关注(0)|答案(8)|浏览(381)

One-line summary [问题简述]

更新已有chart数据时,调用 echartInstance.setOptions({dataZoom: [{show: true}], series: []}, true) 抛出异常。

echarts.min.js:1 Uncaught TypeError: Cannot read property 'getDataPercentWindow' of undefined
    at echarts.min.js:1
    at Array.forEach (<anonymous>)
    at c (echarts.min.js:1)
    at i.eachComponent (echarts.min.js:1)
    at Object.func (echarts.min.js:1)
    at echarts.min.js:1
    at Array.forEach (<anonymous>)
    at c (echarts.min.js:1)
    at Oa.Wa (echarts.min.js:1)
    at Oa.update (echarts.min.js:1)

Version & Environment [版本及环境]

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

Expected behaviour [期望结果]

空白的chart,有没有dataZoom没关系,不应该有异常抛出。

ECharts option [ECharts配置项]

myChart.setOption({
    "dataZoom": [{
        "show": true
    }],
    "legend": {
        "data": [{
            "name": "北京温度"
        }, {
            "name": "上海温度"
        }]
    },
    "xAxis": {
        "type": "time",
        "show": true
    },
    "yAxis": {
        "show": true
    },
    "series": [{
        "type": "line",
        "name": "北京温度",
        "data": [{
            "value": [1503474810837, 33]
        }, {
            "value": [1503474820837, 33]
        }]
    }, {
        "type": "line",
        "name": "上海温度",
        "data": [{
            "value": [1503474810837, 35]
        }, {
            "value": [1503474820837, 35]
        }]
    }]
});

setTimeout(function() {
   // 这句会抛出异常
    myChart.setOption({
        "dataZoom": [{
            "show": true
        }],
        "series": []
    }, true)
}, 3000);

Other comments [其他信息]

重现示例见 http://gallery.echartsjs.com/editor.html?c=xrJW6oI-fG&v=2

wpx232ag

wpx232ag1#

@pissang@LonHon@deqingli@100pah Any Update in this issue, I am also facing this issue in Sankey chart DataZoom level function, And if the DataZoom consider without xAxis and yAxis values binding ,How can we give Zoom in and Zoom out in Sankey Chart , Could you anyone help me out in this issue..

kq0g1dla

kq0g1dla3#

v4.2.1.rc1版本里仍有这个问题,4.1.0里似乎修复了。

求解决

qqrboqgw

qqrboqgw4#

临时的解决方案是在dataZoom设置生效前,判断series是否为空。

nxagd54h

nxagd54h5#

@pissang@LonHon@deqingli@100pah Any Update in this issue, I am also facing this issue in Sankey chart DataZoom level function, And if the DataZoom consider without xAxis and yAxis values binding ,How can we give Zoom in and Zoom out in Sankey Chart , Could you anyone help me out in this issue..

我也遇到了这个问题,我在使用桑基图的时候,因为数据量的问题需要做横向滚动。请问有好的解决方案吗?

I also encountered this problem. When I was using Sankey, I had to do horizontal scrolling because of the amount of data. Is there a good solution?

gab6jxml

gab6jxml6#

临时的解决方案是在dataZoom设置生效前,判断series是否为空。

It definitely works. Grateful for your help.

English version: you should try to set dataZoom after series has been set.

Maybe i can take a look on that a make a pull request later.

m0rkklqb

m0rkklqb7#

Hi, I also encountered the same issue. I tried setting datazoom options after series has been set. No use. Here is my option for dataZoom.
this.spec.dataZoom = [{
type: 'inside',
zoomOnMouseWheel: false,
moveOnMouseMove: true,
moveOnMouseWheel: false,
preventDefaultMouseMove: false
}];

Below is the error that I am getting in browser console.

core.js:4127 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getDataPercentWindow' of undefined
TypeError: Cannot read property 'getDataPercentWindow' of undefined
at dataZoomProcessor.js:96
at Array.forEach ()
at each (util.js:300)
at ExtendedClass.eachComponent (Global.js:449)
at Object.overallReset (dataZoomProcessor.js:92)
at Task.overallTaskReset [as _reset] (Scheduler.js:453)
at reset (task.js:232)
at Task.push.../../node_modules/echarts/lib/stream/task.js.taskProto.perform (task.js:129)
at Scheduler.js:276
at Array.forEach ()
at resolvePromise (zone.js:832)
at zone.js:898
at ZoneDelegate.push.../../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:28173)
at ZoneDelegate.push.../../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push.../../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push.../../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:507)
at invokeTask (zone.js:1671)
at XMLHttpRequest.globalZoneAwareCallback (zone.js:1708)

hkmswyz6

hkmswyz68#

me too,my echarts version is 4.9.0

相关问题