apache / echarts

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

Cannot read property 'getRawIndex' of undefined #9402

Open lolivia opened 5 years ago

lolivia commented 5 years ago

One-line summary [问题简述]

饼图未完全渲染,即饼图动态变化时,鼠标hover到饼图的扇区,报错Cannot read property 'getRawIndex' of undefined, 但不影响渲染以及后续使用

Version & Environment [版本及环境]

Expected behaviour [期望结果]

不输出该错误

ECharts option [ECharts配置项]

option = {
   tooltip: {
      show: true,
      formatter: (params) => {....},
  }
  series: [{
     name: '计数',
      type: 'pie',
      center: ['50%', '50%'],
      data: [{
       .......
       }]
   }]
  }
}

比较特殊的是 我的数据是远程获取,并且数据比较大,当整个饼图渲染完,并没有变化的时候,鼠标hover上去不会有什么错误,但是当数据还在加载的时候,饼图还在变化,这个时候鼠标hover上去会报错。 错误如下

Other comments [其他信息]

dataFormat.js?6c1b:40 Uncaught TypeError: Cannot read property 'getRawIndex' of undefined at ExtendedClass.getDataParams (dataFormat.js?6c1b:40) at Function.superCall (clazz.js?04d6:107) at ExtendedClass.getDataParams (PieSeries.js?fef3:78) at ECharts.eval (echarts.js?21c7:1386) at Handler.trigger (Eventful.js?aa3b:158) at Handler.dispatchToElement (Handler.js?963e:218) at Handler.mouseout (Handler.js?963e:135) at HandlerDomProxy.trigger (Eventful.js?aa3b:158) at HandlerDomProxy.mouseout (HandlerProxy.js?7bcf:107) at HTMLDivElement.eval (HandlerProxy.js?7bcf:245) getDataParams @ dataFormat.js?6c1b:40 superCall @ clazz.js?04d6:107 getDataParams @ PieSeries.js?fef3:78 (anonymous) @ echarts.js?21c7:1386 trigger @ Eventful.js?aa3b:158 dispatchToElement @ Handler.js?963e:218 mouseout @ Handler.js?963e:135 trigger @ Eventful.js?aa3b:158 mouseout @ HandlerProxy.js?7bcf:107 (anonymous) @ HandlerProxy.js?7bcf:245

Ovilia commented 5 years ago

Please provide a full example at jsfiddle or http://gallery.echartsjs.com/editor.html . I tried to add animationDuration: 5000 to slow down the animation and hover on pie before the animation completed and cannot reproduce it.

lolivia commented 5 years ago

不好意思 ,我们的场景比较复杂,不太好描述,如果单纯的写options,也确实不会出现这种问题,我想问下,因为我看到代码出错的地方是 var data = this.getData(dataType);这里为undefined,不知道是不是我姿势用的不对, 一般什么情况下 这里会undefined呢 image

Ovilia commented 5 years ago

I cannot tell from the provided information. Please debug by yourself with ECharts repo node build/build.js.

propakov commented 5 years ago

same for me

Ovilia commented 5 years ago

@Pavel-Ropakov Can you provide your option?

lixueying commented 5 years ago

same for me

braco commented 5 years ago

Getting this also, not sure what the problem is.

j4dream commented 5 years ago

same for me

wustdjf commented 5 years ago

same for me

xushimin commented 5 years ago

same for me

xushimin commented 5 years ago

image e.target.dataType 为undefined

ankushjamdagani commented 5 years ago

Same thing happening for me too. I have debugged it to this function. Task appears to be null here. And this function is returning undefined.

Series.js

  getData: function (dataType) {
    var task = getCurrentTask(this);

    if (task) {
      var data = task.context.data;
      return dataType == null ? data : data.getLinkedData(dataType);
    } else {
      // When series is not alive (that may happen when click toolbox
      // restore or setOption with not merge mode), series data may
      // be still need to judge animation or something when graphic
      // elements want to know whether fade out.
      return inner(this).data;
    }
  }
mechmillan commented 5 years ago

I'm seeing the same on echarts 4.1.0 and 4.3.0 and echarts-for-react 2.0.14, echarts-for-react 2.0.15-beta.0, specifically using a Pie Chart. Can this issue be re-opened?

ankushjamdagani commented 5 years ago

Issue Reason

I was passing every dynamic config toecharts-for-react component as a prop. Config consited of 1...3 number of series. Exception was raised when the new config doesn't consist of a series present previously and moving mouse over that series.

Obvious Solution

Stop the event handling when chart is updating.

Fix 1

Show an overlay over chart when it is updating.

  1. chartInstance.showLoading() when change has started. (I did it as soon as the API call for next data is triggered)
  2. chartInstance.hideLoading() when chartInstance.on('finished') event.

Fix 2

chartInstance.setOption does the update with silent (no-event-listening) mode. https://www.echartsjs.com/en/api.html#echartsInstance.setOption

  1. Pass initial config as prop to Echart component.
  2. For next changes, use chartInstance.setOptions(...) instead of passing new config as prop to the component.

Hope this is of use to you guys.

Ovilia commented 5 years ago

Anyone could provide a demo for this issue?

hujinbo commented 4 years ago

same for me

anachronin commented 4 years ago

I use ReactEcharts and had similar problem with 'scatter' and 'bar' series. Likely because events are being dispatched while the chart is re-rendering. After setting silent: false to the series, the error was eliminated. But this disabled tooltip too.

This works for me: use a React shouldComponentUpdate method to prevent Echarts from re-rendering.

eslambasher commented 3 years ago

I have the same error and the error disappeared when i deleted lazyUpdate from options

I use echarts-for-react v2.0.16

hongdeyuan commented 3 years ago

set : silent: true , maybe it work

a1292999652 commented 2 years ago

setOption(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void; I passed "notMerge" into "true", this problem occurred, changed to "false", the problem was solved

wayward-man commented 2 years ago

setOption(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void; I passed "notMerge" into "true", this problem occurred, changed to "false", the problem was solved

Yes,man. I solved the problem with the same way

ggbond2077 commented 2 years ago

setOption(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void; I passed "notMerge" into "true", this problem occurred, changed to "false", the problem was solved

+1 , i change state in select event which may cause render. caught the same error. and the select action not work. solved by change "notMerge" to "false".

Forever17s commented 1 year ago

setOption(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void; I passed "notMerge" into "true", this problem occurred, changed to "false", the problem was solved

I set 'false' but it still doesn't work well. when hover and switch data still reports an error image

ssjtbcf commented 1 year ago

but If data is frequently changed, change "notMerge" into "false" is reasonable?

hongdeyuan commented 1 year ago

I have received your email, thank you!If there is anything important, I will reply to you as soon as I see it...