apache / apache/echarts

[Bug] visualMap error

Open
#21,174 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

5.6.0

### Link to Minimal Reproduction

https://codesandbox.io/p/devbox/xian-duan-yan-se-qu-fen-forked-dxnh2h?workspaceId=ws_RKzSXtsFcB8woe76BxuF7N

### Steps to Reproduce

if i set visualMap as follows, everything is fine:
```js
visualMap: [
{
type: 'piecewise',
show: true,
dimension: 1,
pieces: [
{
lte: 100,
color: 'green'
},
{
gt: 100,
lte: 200,
color: 'red'
},
{
gt: 200,
lte: 300,
color: 'green'
},
{
gt: 300,
lte: 400,
color: 'red'
},
{
gt: 400,
color: '#f00'
}
]
}
],
```

but if i change it as follows, something went wrong: Cannot read properties of undefined (reading 'coord')

```js
visualMap: [
{
type: 'piecewise',
show: true,
dimension: 1,
pieces: [
{
lte: 400,
color: 'green'
},
{
gt: 400,
color: '#f00'
}
]
}
]
```

here is the series and xAxis config:

```js
xAxis: {
boundaryGap: false,
data: ['岳阳', '长沙', '株洲', '湘潭', '怀化']
},
series: [
{
name: '总人口',
type: 'line',
itemStyle: {
shadowColor: 'rgba(0, 0, 0, 0.40)'
},
lineStyle: {
shadowColor: 'rgba(0, 0, 0, 0.40)'
},
data: [320, 530, 230, 550, 220]
}
]
```

### Current Behavior

there is no clue how we should write `pieces` area, it looks like if the length of pieces is less than 3, then the error above comes out.

### Expected Behavior

it should work and the official document should tell users whether there are any restrictions to enable it

### Environment

```markdown
- OS: Windows 11
- Browser: Google Chrome 130+
- Framework: React 17+
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.