Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ai-qing-hai opened this issue Sep 8, 2023 · 2 comments · Fixed by #5528
Labels

Comments

@ai-qing-hai
Copy link
Collaborator

/**
 * 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();

@pearmini
Copy link
Member

相同的问题:#5250

@pearmini
Copy link
Member

这个问题我深入看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants