Incubator-echarts: TypeError: Cannot read property getWidth of null↵ at ZRender.getWidth

Created on 5 Oct 2018  ·  4Comments  ·  Source: apache/incubator-echarts

One-line summary

TypeError: Cannot read property getWidth of null↵ at ZRender.getWidth

Version & Environment [版本及环境]

  • ECharts version 4.1.0:
  • Browser version Chrome
  • OS Version Windows 10

Expected behaviour [期望结果]

no exception

When calling echarts.getWidth() where echarts is an instance returned from onChartReady callback.

Stack trace:

"TypeError: Cannot read property 'getWidth' of null
    at ZRender.getWidth (http://localhost:3000/assets/vendors~dashboard.chunk.js:132736:25)
    at ECharts.push../node_modules/echarts/lib/echarts.js.echartsProto.getWidth (http://localhost:3000/assets/vendors~dashboard.chunk.js:59885:19)
    at makeData (http://localhost:3000/assets/dashboard.chunk.js:1500:52)
missing-demo support

Most helpful comment

@damiangreen hello~I have met the same problem. Have you solve it ? Would you mind provide some advices? thanks~~

All 4 comments

Container should have width and height when init. Please provide minimum full code including HTML part.

@damiangreen hello~I have met the same problem. Have you solve it ? Would you mind provide some advices? thanks~~

Noticing same thing despite setting a width to the closest parent / container.

I'm not sure if i got to the bottom of it but i did somehting like this

if (echarts) {
    try {
      const greaterValue = min(echarts.getWidth(), echarts.getHeight())
      largestSymbolSize = greaterValue / 4
      smallestSymbolSize = greaterValue / 16
      symbolSizeDelta = largestSymbolSize - smallestSymbolSize
    } catch (err) {
      // tslint:disable-next-line:no-empty
    }
  }
Was this page helpful?
0 / 5 - 0 ratings