| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sorry, something went wrong.
📝 Walkthrough
WalkthroughThe PR replaces even vertical distribution with a positioning pipeline for colliding last-datapoint labels: sort by Y, clamp into bounds, enforce minimum vertical separation, correct overflow, compute connectorX from max label X, and render connectors/text using adjusted labelY. Tests updated to match new positions and ordering. ChangesLabel collision and stacking algorithm
Possibly related PRs
Suggested reviewers
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches 🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
📢 Thoughts on this report? Let us know! |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)shared/utils/download-chart-last-label.ts (2)1-5: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Update the JSDoc to describe the new collision-handling algorithm.
The comment still describes labels as "evenly distributed vertically", but the implementation now uses a different approach: labels are sorted by Y position, clamped to bounds, vertically separated by labelHeight, with overflow correction applied when the stack exceeds the drawing area.
📝 Suggested JSDoc update🤖 Prompt for AI Agents/** * Utility to be used in vue-data-ui line charts (`VueUiXy`) using the `#svg` slot to display the last value as data label. - * In case of mutliple series, if label collisions are detected, labels are evenly distributed vertically, - * and linked to the last datapoint with an elbowed marker + * In case of multiple series, if label collisions are detected, labels are positioned as close as possible to their datapoints, + * vertically separated to prevent overlaps, and linked to the datapoint with an elbowed connector. */Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shared/utils/download-chart-last-label.ts` around lines 1 - 5, Update the file-level JSDoc in shared/utils/download-chart-last-label.ts to describe the current collision-handling algorithm: state that last-point labels are first sorted by their computed Y position, each label Y is clamped to the drawing bounds, adjacent labels are separated by a fixed vertical gap equal to labelHeight, and if the stacked labels overflow the drawing area an overflow-correction step shifts the whole stack to fit within the bounds; mention that elbowed markers link labels to their datapoints and that these adjustments run only when multiple series collide. Use the actual symbol names used in the module (e.g., the function that computes positions) when referring to the algorithm to make the docstring traceable.
1-5: ⚠️ Potential issue | 🟡 Minor
Update the “evenly distributed vertically” wording to match the actual last-label collision layout
app/components/Package/TrendsChart.vue still documents “labels are evenly distributed vertically”, but shared/utils/download-chart-last-label.ts:createLastDatapointLabelsSvg resolves collisions by sorting labels by their original y, clamping them to the drawing area, then stacking them to maintain at least labelHeight spacing (and shifting up if there’s overflow). Update the JSDoc in TrendsChart.vue (and ideally the shared utility) to describe this behaviour instead of “evenly distributed vertically”.
🤖 Prompt for AI AgentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shared/utils/download-chart-last-label.ts` around lines 1 - 5, Update the JSDoc in app/components/Package/TrendsChart.vue (and the comment in shared/utils/download-chart-last-label.ts) to replace “evenly distributed vertically” with a precise description of the actual layout: state that createLastDatapointLabelsSvg sorts labels by their original y, clamps them to the drawing area, stacks them to maintain at least labelHeight spacing, and shifts the stack upward if it overflows, and that each label is linked to its last datapoint with an elbowed marker; mention the min-spacing/stack-and-shift behaviour rather than claiming even vertical distribution.
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@shared/utils/download-chart-last-label.ts`: - Line 114: The expression using positionedLabels.at(-1)! is unsafe; update the access to the last item of positionedLabels in the overflow calculation to be type-safe by checking bounds or using optional chaining and a fallback: retrieve the last element via positionedLabels[positionedLabels.length - 1] (or positionedLabels.at(-1)?), guard against undefined, and then read .labelY (or provide a sensible default or early-return/error) so overflow = lastLabelY - maximumLabelY never uses a non-null assertion; update the overflow computation and any downstream logic in this module (the positionedLabels/overflow usage) accordingly. - Around line 106-107: The code uses non-null assertions for positionedLabels[index - 1] and positionedLabels[index] which breaks TypeScript safety; update the logic in the function that iterates over positionedLabels (the variables previousLabel, currentLabel and the loop using index) to perform explicit bounds/undefined checks before using those elements (e.g., guard when index === 0 or verify both positionedLabels[index - 1] and positionedLabels[index] are defined) and handle the missing-case early (skip, continue, or throw a clear error) so no non-null assertions (!) are required. --- Outside diff comments: In `@shared/utils/download-chart-last-label.ts`: - Around line 1-5: Update the file-level JSDoc in shared/utils/download-chart-last-label.ts to describe the current collision-handling algorithm: state that last-point labels are first sorted by their computed Y position, each label Y is clamped to the drawing bounds, adjacent labels are separated by a fixed vertical gap equal to labelHeight, and if the stacked labels overflow the drawing area an overflow-correction step shifts the whole stack to fit within the bounds; mention that elbowed markers link labels to their datapoints and that these adjustments run only when multiple series collide. Use the actual symbol names used in the module (e.g., the function that computes positions) when referring to the algorithm to make the docstring traceable. - Around line 1-5: Update the JSDoc in app/components/Package/TrendsChart.vue (and the comment in shared/utils/download-chart-last-label.ts) to replace “evenly distributed vertically” with a precise description of the actual layout: state that createLastDatapointLabelsSvg sorts labels by their original y, clamps them to the drawing area, stacks them to maintain at least labelHeight spacing, and shifts the stack upward if it overflows, and that each label is linked to its last datapoint with an elbowed marker; mention the min-spacing/stack-and-shift behaviour rather than claiming even vertical distribution.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9148771b-a4f6-446b-b8bd-795b2ce2c2cb
📥 CommitsReviewing files that changed from the base of the PR and between 0ad3d62 and 915b7f6.
📒 Files selected for processing (2)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Follow up to #2870
This improves the placement algo of the labels in case of collisions.
Labels are placed as close as possible to their relative datapoint, and shifted to prevent overlaps with other labels.