G2 icon indicating copy to clipboard operation
G2 copied to clipboard

【V5】ColorScale设置range为多个值时,只有前两个颜色生效

Open Xiatian-leo opened this issue 1 year ago • 0 comments

问题描述

【版本】:@antv/g2@^5.1.12

【场景描述】:散点图增加自定义的多色图例

【问题】:设置两个以上颜色时,仅前两个颜色生效

【代码示例如下】:

// 示例来源于  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();

效果图如下

image

以上。 谢谢

平台

  • 操作系统: [Windows]
  • 网页浏览器: [Google Chrome, Edge]

Xiatian-leo avatar Jan 24 '24 02:01 Xiatian-leo