apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.17k stars 19.6k forks source link

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

Closed ralph-cheng closed 1 month ago

ralph-cheng commented 6 years ago

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 [版本及环境]

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

Richard-biz commented 5 years ago

@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..

pchaganti commented 5 years ago

👍

fuchunhui commented 5 years ago

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

fuchunhui commented 5 years ago

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

CharlesMoone commented 4 years ago

@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?

maugustosemperfi commented 4 years ago

临时的解决方案是在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.

vkjv commented 3 years ago

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)

eanson023 commented 2 years ago

me too,my echarts version is 4.9.0

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] commented 1 month ago

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!