[Bug] visualMap.pieces has only one obj and obj has only one gt TypeError
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### Version
4.9.0~5.4.3
### Link to Minimal Reproduction
pieces: [{gt: 0, color: 'red'}]
### Steps to Reproduce
```js
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
```markdown
- 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'
}]
Contributor guide
Assessment
This issue has not been assessed yet.