【V5】ColorScale设置range为多个值时,只有前两个颜色生效
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### 问题描述
> 【版本】:`@antv/g2@^5.1.12`
>
> 【场景描述】:散点图增加自定义的多色图例
>
> 【问题】:设置两个以上颜色时,仅前两个颜色生效
>
> 【代码示例如下】:
>
```javascript
// 示例来源于 https://g2.antv.antgroup.com/zh/examples/general/point/#point-basic
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart
.point()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/basement_prod/6b4aa721-b039-49b9-99d8-540b3f87d339.json',
})
.encode('x', 'height')
.encode('y', 'weight')
.encode('color', 'height')
.scale({
'color': {
type: 'linear',
// 连续型color的度量range仅前两个有效
range: ['red', '#aaa', 'blue']
}
});
chart.render();
```
### 效果图如下

以上。
谢谢
### 平台
- 操作系统: [Windows]
- 网页浏览器: [Google Chrome, Edge]
Contributor guide
Research direction
Reproduce the issue with the provided G2 point example and its linear color scale using range ['red', '#aaa', 'blue']. Trace the continuous color-scale handling to determine why only two range entries are used. Done means all supplied colors participate in the rendered scatter plot, with regression coverage for the multi-color range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100