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

fix(dual): set series of line to band scale #5528

Merged
merged 1 commit into from
Sep 11, 2023
Merged

fix(dual): set series of line to band scale #5528

merged 1 commit into from
Sep 11, 2023

Conversation

pearmini
Copy link
Member

折柱双轴图

存在问题

line 和 area series 的比例尺是 identity,但是 interval 的比例尺是 band,同时存在比例尺会冲突。

解决办法

设置 line 和 area series 的比例尺类型也是 band,因为这个通道时用来分组的,只要保证映射结果不同即可,而 band 比例尺其实也满足这个特性。

结果

import { G2Spec } from '../../../src';

export function mockIntervalLine(): G2Spec {
  return {
    type: 'view',
    children: [
      {
        type: 'interval',
        data: [
          { 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' },
        ],
        encode: { x: 'time', y: 'value', color: 'type' },
        transform: [{ type: 'dodgeX' }],
        axis: { y: { labelFormatter: '.0%' } },
      },
      {
        type: 'line',
        data: [
          { 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 },
        ],
        encode: { x: 'time', y: 'count', color: () => 'line' },
        axis: { y: { labelFormatter: '.0%' } },
      },
    ],
  };
}

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6145717993

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 88.476%

Totals Coverage Status
Change from base Build 6144031489: -0.003%
Covered Lines: 9850
Relevant Lines: 10777

💛 - Coveralls

@pearmini pearmini merged commit 1446b1a into v5 Sep 11, 2023
2 checks passed
@pearmini pearmini deleted the fix/line-interval branch September 11, 2023 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants