Skip to content

Cannot read properties of undefined (reading 'coordinateSystem') #616

@jdupont22

Description

@jdupont22

Moving from 3.0.2 to 3.0.3 or higher, I have this error

wind-turbine-dashboard-charts.tsx:109 TypeError: Cannot read properties of undefined (reading 'coordinateSystem')
    at layout2 (chunk-6WVG2MFA.js?v=11d67010:37677:24)
    at CartesianAxisView2.render (chunk-6WVG2MFA.js?v=11d67010:39034:21)
    at chunk-6WVG2MFA.js?v=11d67010:24068:25
    at Array.forEach (<anonymous>)
    at each (chunk-6WVG2MFA.js?v=11d67010:487:9)
    at renderComponents (chunk-6WVG2MFA.js?v=11d67010:24065:9)
    at render (chunk-6WVG2MFA.js?v=11d67010:24053:9)
    at ECharts2.update (chunk-6WVG2MFA.js?v=11d67010:23730:11)
    at ECharts2.setOption (chunk-6WVG2MFA.js?v=11d67010:23082:32)
    at wind-turbine-dashboard-charts.tsx:355:46

Any idea ?

Minimal reproduction code, work with 3.0.2, don't with >= 3.0.3

import ReactECharts from 'echarts-for-react'
import {useEffect, useMemo, useRef} from 'react'
import dayjs from 'dayjs'
import {EChartsOption} from 'echarts-for-react/src/types.ts'

export function TestEcharts() {
  const echartRef = useRef<InstanceType<typeof ReactECharts>>(null)

const option = useMemo<EChartsOption>(() => {
    return {
      xAxis: [
        {
          type: 'time',
          scale: true,
          axisLine: {onZero: true},
          min: dayjs().subtract(1, 'hour').toISOString(),
        },
      ],
      yAxis: [
        {
          type: 'value',
          scale: true,
          name: 'kW',
          min: 0,
        },
      ],
      series: [
        {
          name: 'Test',
          type: 'line',
          showSymbol: false,
          data: [],
        },
      ],
    }
  }, [])

  useEffect(() => {
    if (!echartRef.current) return
    const mergeOptions: EChartsOption = {
      xAxis: [
        {
          max: dayjs().toISOString(),
        },
      ],
    }
    echartRef.current?.getEchartsInstance()?.setOption(mergeOptions)
  }, [echartRef])

  return <ReactECharts ref={echartRef} option={option} style={{height: 200}} />
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions