Skip to content

fix: moasic chart's crosshair can not render rect shape#4561

Open
kkxxkk2019 wants to merge 1 commit intodevelopfrom
fix/moasic-crosshair
Open

fix: moasic chart's crosshair can not render rect shape#4561
kkxxkk2019 wants to merge 1 commit intodevelopfrom
fix/moasic-crosshair

Conversation

@kkxxkk2019
Copy link
Copy Markdown
Collaborator

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

Copilot AI review requested due to automatic review settings April 16, 2026 03:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes crosshair rect rendering for mosaic-like (reversed start/end) continuous data ranges by normalizing range comparisons and positioning.

Changes:

  • Update getDatumByValue to match values within a range regardless of whether startField is less than or greater than endField.
  • Adjust cartesian crosshair layout logic to anchor coord at the left edge of a continuous range band (using Math.min(posStart, posEnd)).
  • Add unit tests covering reversed-field range lookup and rect crosshair layout behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/vchart/src/component/crosshair/utils/common.ts Makes datum lookup range-direction agnostic via min/max bounds.
packages/vchart/src/component/crosshair/utils/cartesian.ts Fixes continuous range band positioning so rect crosshair spans the expected interval (incl. mosaic).
packages/vchart/__tests__/unit/component/crosshair/crosshair-util.test.ts Adds unit coverage for reversed ranges and rect layout/clamping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +95 to 97
bandSize = Math.abs(posStart - posEnd);
coord = Math.min(posStart, posEnd);
value = `${datum[field1]} ~ ${datum[field2]}`;
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

When field2 exists and the underlying data uses reversed start/end fields (e.g. mosaic where field1 can be the larger bound), the label text ${datum[field1]} ~ ${datum[field2]} will render in reversed order (e.g. 0.6 ~ 0.2). Since coord is normalized with Math.min(posStart, posEnd), consider also normalizing the displayed range to ascending order (based on the datum values) so the crosshair label matches the visual rect direction.

Suggested change
bandSize = Math.abs(posStart - posEnd);
coord = Math.min(posStart, posEnd);
value = `${datum[field1]} ~ ${datum[field2]}`;
const startValue = datum[field1];
const endValue = datum[field2];
const [rangeStartValue, rangeEndValue] =
startValue <= endValue ? [startValue, endValue] : [endValue, startValue];
bandSize = Math.abs(posStart - posEnd);
coord = Math.min(posStart, posEnd);
value = `${rangeStartValue} ~ ${rangeEndValue}`;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@xuefei1313 xuefei1313 left a comment

Choose a reason for hiding this comment

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

自动 Review(机器人):

  • 关注点:本次 PR 为修复 Mosaic 图的 crosshair 渲染(rect 形状)。
  • 建议自查:
    1. 是否新增/更新了对应的 demo 或单测,覆盖 rect/line 等不同形状;
    2. crosshair 在不同主题/缩放/高清屏下的边界与对齐;
    3. 是否影响 tooltip / axis pointer 等相关交互;
  • 请以 CI 结果为准,如 CI 全绿且本地验证通过,可考虑合入。

(本评论为自动化提示,不代替人工 Review)

@xuefei1313 xuefei1313 enabled auto-merge April 17, 2026 08:42
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 this pull request may close these issues.

3 participants