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(line): use curveMonotone #5751

Merged
merged 1 commit into from
Nov 7, 2023
Merged

fix(line): use curveMonotone #5751

merged 1 commit into from
Nov 7, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Nov 7, 2023

Smooth Line

close: #5541

当 y 方向的数据连续为 0 的时候,曲线超出坐标轴。

解决办法

使用 curveMonotoneXcurveMonotoneY 作为默认的曲线生成器。

案例

export function mockLineCloseX(): G2Spec {
  return {
    type: 'line',
    data: [
      { x: 0, y: 0 },
      { x: 0.02, y: 0.8 },
      { x: 1, y: 1 },
    ],
    encode: { x: 'x', y: 'y' },
    style: { shape: 'smooth' },
  };
}
export function mockLineZeroY(): G2Spec {
  return {
    type: 'line',
    coordinate: { transform: [{ type: 'transpose' }] },
    data: [
      { date: '2-1', close: 1 },
      { date: '2-2', close: 10 },
      { date: '2-3', close: 0 },
      { date: '2-4', close: 0 },
      { date: '2-5', close: 12 },
    ],
    encode: { x: 'date', y: 'close' },
    style: { shape: 'smooth' },
  };
}
export function mockLineCloseX(): G2Spec {
  return {
    type: 'line',
    data: [
      { x: 0, y: 0 },
      { x: 0.02, y: 0.8 },
      { x: 1, y: 1 },
    ],
    encode: { x: 'x', y: 'y' },
    style: { shape: 'smooth' },
  };
}

Copy link
Collaborator

@ai-qing-hai ai-qing-hai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line close curveCatmullRom , use curveMonotoneY/curveMonotoneX

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6779796068

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 88.237%

Totals Coverage Status
Change from base Build 6769567652: 0.001%
Covered Lines: 10021
Relevant Lines: 10992

💛 - Coveralls

@pearmini pearmini merged commit 2bedfba into v5 Nov 7, 2023
3 checks passed
@pearmini pearmini deleted the fix-zero-line branch November 7, 2023 06:25
Exlau pushed a commit to Exlau/G2 that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

g2 v5版本折线图(line) 设置shape为smooth(曲线)后,对于中间出现连续0的场景画线异常
4 participants