echarts [Bug] visualMap.pieces has only one obj and obj has only one gt TypeError

crcmnpdw  于 6个月前  发布在  Echarts
关注(0)|答案(1)|浏览(52)

Version

4.9.0~5.4.3

pieces: [{gt: 0, color: 'red'}]

Steps to Reproduce

const hours = ['17时', '18时', '19时', '20时', '21时', '22时', '24时'];
  const values = [4, 4, 4, 10, 10, 10, 10];
  const colors = [
    {
        gt: 0,
        // lte: 7,
        color: 'blue'
    }
];

option = {
  title: {
      text: 'xxx',
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross'
      }
    },
  xAxis: {
      type: 'category',
      boundaryGap: false,
      // prettier-ignore
      data: hours
    },
    yAxis: {
      type: 'value',
      axisLabel: {
        formatter: '{value} kwh'
      },
      axisPointer: {
        snap: true
      }
    },
    visualMap: {
      show: false,
      dimension: 0,
      pieces: colors
    },
    series: [
      {
        name: '用电量',
        type: 'line',
        data: values,
      }
    ]
};

Current Behavior

TypeError: Cannot read properties of undefined (reading 'coord')
at getVisualGradient (LineView.js:228:1)
at ExtendedClass.render (LineView.js:469:1)
at Task.progress (Chart.js:281:1)
at doProgress (task.js:217:1)
at taskProto.perform (task.js:157:1)
at eval (echarts.js:1474:1)
at ExtendedClass.eval (Global.js:517:1)
at Array.forEach ()
at each (util.js:300:1)
at ExtendedClass.eachSeries (Global.js:514:1)

Expected Behavior

Running successed!

Environment

- OS: Windows 10
- Browser: Edge
- Framework: Vue.js

Any additional comments?

When pieces has only one obj and obj only has gt and color prop, then run with TypeError like 'TypeError: Cannot read properties of undefined (reading 'coord')'. However, it works fine when obj has gt and lte.
pieces: [{
gt: 0,
// lte: 7,
color: 'blue'
}]

y3bcpkx1

y3bcpkx11#

duplicate of #18268 and others ... first reported in 2017 in #5801 ... there is even a stalled PR...
Related to series.type:'line', type:'bar' works fine.

相关问题