Component | Plotline | Plotband: Auto-position labels on collision (1.7) - #777
Component | Plotline | Plotband: Auto-position labels on collision (1.7)#77750rayn wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
I'm not sure this is the best place for the test.ts file and the resolver. Personally I think this should go under utils, or even better, as part of the plotband or plotline components? @rokotyan @suryahanumandla thoughts?
There was a problem hiding this comment.
😄 I was thinking a lot about the test location. I was inspired by reka-ui, locating the test near the components themselves. It brings some benefits:
- near the components - comfortable to "find"
- don't need to keep the file tree structure synced with the tests folder with src.
- lower chance of missing a unit test. Or see if the test exists for the component/script.
Personally, if will be decided to move tests to the tests folder, I would like to keep the same folder tree structure. But the chance of breaking this "rule" is big.
c365b00 to
267d5e3
Compare
331b4a8 to
efe24b5
Compare
efe24b5 to
c5ac8a0
Compare
a58cbc5 to
f20cc05
Compare
|
A small related update: I added a few library-wide text overlapping utilities in my latest PR 62f15f9 |
f20cc05 to
6a19b60
Compare
|
@rokotyan good call — plugged them in. The |
729a5cc to
b252eca
Compare
2e84f0f to
6ec3dee
Compare
…plotband label collision
…two interactive playgrounds
…lveRectsOverlap util
…framework variants
6ec3dee to
e1b9838
Compare
Stacking multiple VisPlotlines for a percentile threshold view, every label rendered at the same top-right anchor and they piled on top of each other. Same problem with VisPlotband once two ands overlap. labelPosition was fixed; no way out.
Two new opt-in props on each —
labelAutoPositionandlabelOverflow:Resolver lives in
xy-container/plot-label-resolver.tsand runs once per render after components draw their labels. Components opt in via getLabelLayoutInfo() returning candidate anchors + a computeLayout callback. The container projects each candidate into arect, tracks placedrects, and avoids them.Vertical-orientation labels (
rotate(-90, x, y)) needed special handling —getBBox()returns pre-rotation bounds, so the projector swaps width/height and shifts by text-anchor along the rotated y-axis. isRotatedQuarter keeps the math local to the resolver.Split the old plotband-plotline example into two playgrounds (plotlines-playground, plotbands-playground) with sliders + an labelOverflow dropdown — drag labels into collision and watch each strategy live. Plus a synced-auto-position stress demo (React/Vue/Svelte/Solid/Angular) that drops N plotlines onto the same y-region.
Snapshot tests for every label-position layout under
components/{plotline,plotband}/constants.test.ts; resolver semantics underplot-label-resolver.test.ts.Drive-by: docs/wrappers/base/doc-tabs.tsx — components.find was returning the first match, but
DocWrapperappends the main component last. Reversed the find so the doc preview matches the imported main.