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
6ec3dee to
e1b9838
Compare
e1b9838 to
e763d55
Compare
…plotband label collision
…two interactive playgrounds
…lveRectsOverlap util
…framework variants
…t fields _applyLabelLayout was referencing transform/textAnchor/dominantBaseline from the old PlotLabelLayout shape; update to rotation/textAlign/verticalAlign. Also fix bbox-clamping sign error in Plotline/Plotband _render (Math.min was returning a large negative for bbox.x > 0), and drop the infos.length < 2 bail so single-label containers still get bounds-checked.
Drop the 'smart' overflow mode and its candidate-loop infrastructure (tryPlaceLabel, totalOverlap, candidates array, PLOTLINE_CLOCKWISE, PLOTBAND_CLOCKWISE). Stack is now the only positional strategy; Hide uses the existing sweep-and-prune resolver. Default overflow changes from Smart to Stack.
…tion Add resolveStackOverflow to the plot-label resolver. Stack labels now shift along the perpendicular axis (y for horizontal, x for rotated) just enough to clear each collision, instead of all landing at the same preferred position.
… findings - Plotline + Plotband: render UnovisText/UnovisText[] via renderTextToSvgTextElement instead of d3 .text() which would coerce objects to '[object Object]' - GroupedBar: cache _getBarStyle() result per element to avoid 4-5 redundant accessor calls per bar per render - React | container: reset isInitialRunRef on cleanup so StrictMode double-mount does not fire a spurious requestRender() on the remount pass
…belOverflow docs Update the Label Overflow section to reflect the two remaining strategies (stack / hide). Rewrite the description to match stack's new behaviour (perpendicular shift) rather than the deleted candidate-loop approach.
1cc6b76 to
f61ef41
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.