Repository navigation
Fix O(n²) bar draw from per-bar getZeroBarDir - #1
Open
short-int-ali wants to merge 37 commits into
Open
short-int-ali wants to merge 37 commits into
short-int-ali wants to merge 37 commits into
Conversation
`domain` is a plot fraction, so the gap it leaves between subplots grows and shrinks with the figure while a subplot title does not. domainpad reserves a fixed number of pixels inside the domain edges instead, resolved at draw time. Applied in ax.setScale to _offset and _length rather than to ax.domain, so the domain keeps meaning what the user typed and anything referenced to `<axis> domain` follows the padded area without new drawing code. Along with it: - scattergl, splom and the rangeslider rebuilt the plot rect from `domain` and so did not see the pad; they now read _offset and _length - pads that do not fit are backed off together, since setScale already throws on a negative length - updateDomain scales the padded length rather than the raw span, so a scaleanchor ratio stays exact when the constraint shrinks a padded axis Refs plotly#7835
Removed attribution from the commit message.
The three places that build the plot rect from `domain` were changed to read _offset and _length instead. That round trips through pixel space, and the result is not exactly the value it started from: splom cell domains came back about one ulp out, which moved rasterised markers enough to fail the splom_*-nodiag image baselines even though no padding was involved. Add the resolved padding to the original expressions instead, and expose it as ax._padStart / ax._padEnd for those callers. Adding a literal zero is exact, so an unpadded plot now produces the same numbers it always did. Also list domainpad in swapAxisGroup's noSwapAttrs, next to domain: its keys are named for screen edges, so swapping x and y would need them remapped.
updateDomain multiplied the domain by (newSpan / inputSpan). Without padding, that ratio is 1 / factor, but the multiply can change the last bit of the result, so a plot with no domainpad could move by a tiny amount. Divide by `factor` as main does, and change the divisor only when the axis has padding. Without domainpad, the result is now the same as on main.
… and types The comments and attribute descriptions now follow the Simplified Technical English rules in AGENTS.md. Lines that this PR touches now use const, let and arrow functions. There is no change in behavior. The regenerated schema.d.ts and plot-schema.json fix the generated-types-drift check, which failed because the types did not include domainpad.
Spikes with spikemode 'across' got their span from the counter axis domains, so with domainpad they crossed the reserved space, for example a subplot title. Get the span from the domain minus the padding of each counter axis. Without domainpad the span is the same as before. A free axis still extends the span to its position. The new test fails without this fix.
scattergl and splom build their regl viewports from `domain`, so they add the padding in their own code. These tests make sure that the viewport, the splom cells and the regl grid match the padded plot area.
The mock shows four subplots with different domainpad sides, so a change in the padded plot area shows in the image tests. The baseline image must come from the baselines-default-diff CI artifact.
An earlier commit removed the "with thanks to" credit by mistake. The draftlog convention includes it.
# Conflicts: # test/jasmine/tests/hover_spikeline_test.js
…ct sets a new range On a constrain:'domain' axis, constraints.enforce compares the range with _inputRange and puts _inputRange back when the range is smaller. Plotly.react and Plotly.relayout with a whole axis object kept the old _inputRange, so a new range drew as the previous one. diffLayout now clears it the way it clears _inputDomain, and the whole axis object case does what the dotted range keys already do.
Per-bar scans of same-sign calcdata made bar draw quadratic. One call per trace keeps outside zero-label direction and drops that cost to linear. Co-authored-by: i242576 <[email protected]>
…ange fix: Clear a stale _inputRange when Plotly.react or a whole axis object sets a new range
…ffix Fix tick prefixes and suffixes with explicit tick values
Remove the inline comments flagged in review, and describe in the domainpad attribute that an overlaying axis uses the domainpad of the axis it overlays. Regenerate the plot schema and the generated types.
Give the overlaying axis in the domainpad test a conflicting domainpad, so the test covers the behavior that the attribute description now documents.
domainpad: pixel spacing inside axis domains
…protect-prototype Bugfix: fix potential prototype pollution when expanding/merging object paths
Chore: v4.3.0
Pick up v4.3.0 so the pull request targets current plotly/plotly.js main. Co-authored-by: i242576 <[email protected]>
Rename this file and the PR link after the change opens against plotly/plotly.js. Co-authored-by: i242576 <[email protected]>
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.
Compute
getZeroBarDironce per bar trace instead of once per bar.Closes plotly#8157 once this change lands on
plotly/plotly.js(this PR is on the fork; the agent token cannot open a cross-repo PR against upstream).Same-sign traces scanned all calcdata for every bar. That made draw time quadratic. The cached value keeps the same outside-label side for zero-extent bars (plotly#7872).
Tests
test/jasmine/tests/bar_test.jsshould keep zero-value outside labels on the same side as negative barsxvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" npm run test-jasmine -- bar --nowatch --report-specChrome 157.0.0.0 (Linux 0.0.0): Executed 151 of 151 SUCCESS(1.939 s)Also passed locally:
npm run lint,npm run typecheck,npm run test-syntax.Perf
Headless Chromium on this agent host. One warm-up
newPlot, then one timednewPlotfor a single all-positive bar trace (same data shape as plotly#8157). Parent tip without the fix vs this branch:Before: 30k→60k grows about 3.6× (quadratic). After: about 1.7× (near linear). At 60k bars, draw time drops from 5,707 ms to 702 ms.
Upstream open
Compare URL for a maintainer or the branch owner:
https://github.com/plotly/plotly.js/compare/main...short-int-ali:plotly.js:cursor/bar-zero-bar-dir-once-da7b?expand=1
After that PR opens, rename
draftlogs/1_fix.mdtodraftlogs/<upstream#>_fix.mdand fix the PR link.No API, schema, mock, or baseline change.
🐦