-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix relayout constrained axes + various multi-subplot perf improvements #2628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a12a22b
23964ca
abd4bcf
09d5dd0
5557d7b
73b354b
e69b7dd
c947b2c
6fa8ffd
455ff4d
72b6558
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1498,28 +1498,50 @@ axes.makeClipPaths = function(gd) { | |
| }); | ||
| }; | ||
|
|
||
| // doTicks: draw ticks, grids, and tick labels | ||
| // axid: 'x', 'y', 'x2' etc, | ||
| // blank to do all, | ||
| // 'redraw' to force full redraw, and reset: | ||
| // ax._r (stored range for use by zoom/pan) | ||
| // ax._rl (stored linearized range for use by zoom/pan) | ||
| // or can pass in an axis object directly | ||
| axes.doTicks = function(gd, axid, skipTitle) { | ||
| /** Main axis drawing routine! | ||
| * | ||
| * This routine draws axis ticks and much more (... grids, labels, title etc.) | ||
| * Supports multiple argument signatures. | ||
| * N.B. this thing is async in general (because of MathJax rendering) | ||
| * | ||
| * @param {DOM element} gd : graph div | ||
| * @param {object or string or array of strings} arg : polymorphic argument | ||
| * @param {boolean} skipTitle : optional flag to skip axis title draw/update | ||
| * @return {promise} | ||
| * | ||
| * Signature 1: Axes.doTicks(gd, ax) | ||
| * where ax is an axis object as in fullLayout | ||
| * | ||
| * Signature 2: Axes.doTicks(gd, axId) | ||
| * where axId is a axis id string | ||
| * | ||
| * Signature 3: Axes.doTicks(gd, 'redraw') | ||
| * use this to clear and redraw all axes on graph | ||
| * | ||
| * Signature 4: Axes.doTicks(gd, '') | ||
| * use this to draw all axes on graph w/o the selectAll().remove() | ||
| * of the 'redraw' signature | ||
| * | ||
| * Signature 5: Axes.doTicks(gd, [axId, axId2, ...]) | ||
| * where the items are axis id string, | ||
| * use this to update multiple axes in one call | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already a bit out of control, do we really want to add another signature? Can we perhaps break it into 2 separate functions, one for signatures 1 & 2 and a second for 3, 4, 5? That's how it functions anyway - 3,4,5 just map into a bunch of calls to signature 2 (ignoring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure that would be nice. But since But if you insist, than I'm thinking of making On |
||
| * | ||
| * N.B signatures 3, 4 and 5 reset: | ||
| * - ax._r (stored range for use by zoom/pan) | ||
| * - ax._rl (stored linearized range for use by zoom/pan) | ||
| */ | ||
| axes.doTicks = function(gd, arg, skipTitle) { | ||
| var fullLayout = gd._fullLayout; | ||
| var ax; | ||
| var independent = false; | ||
| var ax; | ||
|
|
||
| // allow passing an independent axis object instead of id | ||
| if(typeof axid === 'object') { | ||
| ax = axid; | ||
| axid = ax._id; | ||
| if(Lib.isPlainObject(arg)) { | ||
| ax = arg; | ||
| independent = true; | ||
| } | ||
| else { | ||
| ax = axes.getFromId(gd, axid); | ||
| } else if(!arg || arg === 'redraw' || Array.isArray(arg)) { | ||
| var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; | ||
|
|
||
| if(axid === 'redraw') { | ||
| if(arg === 'redraw') { | ||
| fullLayout._paper.selectAll('g.subplot').each(function(subplot) { | ||
| var plotinfo = fullLayout._plots[subplot]; | ||
| var xa = plotinfo.xaxis; | ||
|
|
@@ -1534,22 +1556,24 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
| }); | ||
| } | ||
|
|
||
| if(!axid || axid === 'redraw') { | ||
| return Lib.syncOrAsync(axes.list(gd, '', true).map(function(ax) { | ||
| return function() { | ||
| if(!ax._id) return; | ||
| var axDone = axes.doTicks(gd, ax._id); | ||
| ax._r = ax.range.slice(); | ||
| ax._rl = Lib.simpleMap(ax._r, ax.r2l); | ||
| return axDone; | ||
| }; | ||
| })); | ||
| } | ||
| return Lib.syncOrAsync(axList.map(function(a) { | ||
| return function() { | ||
| if(!a) return; | ||
| var axDone = axes.doTicks(gd, a); | ||
| var ax = axes.getFromId(gd, a); | ||
| ax._r = ax.range.slice(); | ||
| ax._rl = Lib.simpleMap(ax._r, ax.r2l); | ||
| return axDone; | ||
| }; | ||
| })); | ||
| } else { | ||
| ax = axes.getFromId(gd, arg); | ||
| } | ||
|
|
||
| // set scaling to pixels | ||
| ax.setScale(); | ||
|
|
||
| var axid = ax._id; | ||
| var axLetter = axid.charAt(0); | ||
| var counterLetter = axes.counterLetter(axid); | ||
| var vals = ax._vals = axes.calcTicks(ax); | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N.B. @alexcjohnson I didn't implement per-axis "axrange" edit for
Plotly.react. My main concern was improvement perf on dragend axis range relayout calls. I didn't think adding an exception to the react diffing algo was worth it for this case.