antvis/G2

[v5] 自定义 color, 图例未能应用上 #4570

visiky posted onGitHub

描述

<img width="1184" alt="image" src="https://user-images.githubusercontent.com/15646325/211745852-d23cf18d-571a-4ecd-87e7-e5eff38a3eb1.png">

通过 scale.relations 来实现自定义颜色,图例部分未能映射上

import { Chart } from '@antv/g2';

const chart = new Chart({
  container: 'container',
  autoFit: true,
  paddingLeft: 50,
});

chart
  .line()
  .data({
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/indices.json',
  })
  .transform({ type: 'normalizeY', basis: 'first', groupBy: 'color' })
  .encode('x', (d) => new Date(d.Date))
  .encode('y', 'Close')
  .encode('color', 'Symbol')
  .scale('y', { type: 'log' })
  .axis('y', { title: '↑ Change in price (%)' })
  .label({
    text: 'Symbol',
    selector: 'last',
    fontSize: 10,
  })
  .scale('color', {
    relations: [['AMZN', 'red']]
  })

chart.render();

Fund this Issue

$0.00
Funded

Pull requests