antvis/G2

【v5】 同时存在 Interval transform:[{ type: 'dodgeX' }] 和 Line encode('color') 时,出现冲突 #5523

ai-qing-hai posted onGitHub

/**
 * A recreation of this demo: https://observablehq.com/@d3/bar-chart
 */
import { Chart } from '@antv/g2';

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

  const uvBillData = [
    { time: '2019-03', value: 350, type: 'uv' },
    { time: '2019-04', value: 900, type: 'uv' },
    { time: '2019-05', value: 300, type: 'uv' },
    { time: '2019-06', value: 450, type: 'uv' },
    { time: '2019-07', value: 470, type: 'uv' },
    { time: '2019-03', value: 220, type: 'bill' },
    { time: '2019-04', value: 300, type: 'bill' },
    { time: '2019-05', value: 250, type: 'bill' },
    { time: '2019-06', value: 220, type: 'bill' },
    { time: '2019-07', value: 362, type: 'bill' },
  ];

  const transformData = [
    { time: '2019-03', count: 800 },
    { time: '2019-04', count: 600 },
    { time: '2019-05', count: 400 },
    { time: '2019-06', count: 380 },
    { time: '2019-07', count: 220 },
  ];


chart
  .interval()
  .data(uvBillData)
  .encode('x', 'time')
  .encode('y', 'value')
  .encode('color', 'type')
  .transform([{ type: 'dodgeX' }])
  .axis('y', { labelFormatter: '.0%' });

chart
  .line()
  .data(transformData)
  .encode('x', 'time')
  .encode('y', 'count')
  .encode('color', () => 'line')
  .axis('y', { labelFormatter: '.0%' });

chart.render();

posted by pearmini over 1 year ago

这个问题我深入看看

posted by pearmini over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests