fix(xychart): auto-flip point labels to avoid line collision#2
Closed
DominicBurkart wants to merge 2 commits intoclaude/add-xychart-point-labels-NYGcCfrom
Closed
fix(xychart): auto-flip point labels to avoid line collision#2DominicBurkart wants to merge 2 commits intoclaude/add-xychart-point-labels-NYGcCfrom
DominicBurkart wants to merge 2 commits intoclaude/add-xychart-point-labels-NYGcCfrom
Conversation
Visual QA evidence for the per-point text labels feature, rendered with Playwright using the forest theme. https://claude.ai/code/session_01CgvREhkQ3tVYCagq1mHmjV
Owner
Author
QA Results v2: Label-Line Collision Avoidance1. Steep Descent — MMLU Real-World ExamplePASS — "LLaMA-65B", "Llama 2 34B", "Mistral 7B", "Phi-3-mini" flipped below their points, away from the descending line. "PaLM" stays above. 2. Gentle Slope — No Collision (regression check)PASS — All labels ("Start", "Mid", "End") remain above. No false positives. 3. Zigzag Pattern — Mixed Collision (previously broken, now fixed)PASS — Valley points ("Low" at P2, "Bottom" at P4) now correctly flip labels below. Peak points ("High" at P1, "Peak" at P3) stay above. Summary
Automated tests: 4008/4008 vitest unit tests pass, 0 regressions. Generated by Claude Code |
4 tasks
0096b5b to
24dcee6
Compare
When a line segment has a steep slope, labels placed above a data point can collide with the line. This adds collision detection that estimates each label's bounding box and checks for intersection with adjacent line segments using y-range overlap. When a collision is detected, the label is flipped to the opposite side of the point (below for vertical charts, left for horizontal charts). https://claude.ai/code/session_01UCV1QCaRsRtQjRspaVrqUp
b085228 to
8c36d1d
Compare
Owner
Author
|
Superseded by mermaid-js#7551 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Stacked on #1.
Approach
For each labeled point, the algorithm:
fontSize * label.length * 0.7(same heuristic as bar label renderer)Before (PR #1)
Labels always above — line cuts through "LLaMA-65B":
Changes
linePlot.tslineYAtX(),doesSegmentIntersectBox(),shouldFlipLabelVertical(),shouldFlipLabelHorizontal()helpers; modified label loop to use conditional positioningxyChart.spec.jsdemos/xychart.htmlTest plan
demos/xychart.htmland verify the MMLU steep-descent demohttps://claude.ai/code/session_01UCV1QCaRsRtQjRspaVrqUp