Skip to content

Commit ef55084

Browse files
committed
address review: drop superfluous comments, document overlaying domainpad
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.
1 parent a0220ac commit ef55084

13 files changed

Lines changed: 6 additions & 49 deletions

File tree

‎src/components/fx/hover.js‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,10 +2432,6 @@ function cleanPoint(d, hovermode) {
24322432
/**
24332433
* Get the pixel span of a spike with spikemode 'across'.
24342434
*
2435-
* The span covers the plot areas of all counter axes of `ax`. Each plot area is the
2436-
* domain of the counter axis minus its `domainpad`. Thus the spike stops at the edge
2437-
* of the plot area, and the padding stays clear for content such as a subplot title.
2438-
*
24392435
* @param gd - the graph div
24402436
* @param ax - the full axis that shows the spike
24412437
* @param gs - the plot size, `fullLayout._size`
@@ -2457,7 +2453,6 @@ function getAcrossSpikeSpan(gd, ax, gs) {
24572453
start = Math.min(start, gs.l + counterAx.domain[0] * gs.w + padStart);
24582454
end = Math.max(end, gs.l + counterAx.domain[1] * gs.w - padEnd);
24592455
} else {
2460-
// SVG measures y from the top, so the top edge of the domain comes first
24612456
start = Math.min(start, gs.t + (1 - counterAx.domain[1]) * gs.h + padStart);
24622457
end = Math.max(end, gs.t + (1 - counterAx.domain[0]) * gs.h - padEnd);
24632458
}

‎src/plots/cartesian/axes.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4683,8 +4683,6 @@ function swapAxisGroup(gd, xIds, yIds) {
46834683
var allAxKeys = Object.keys(axAttrs);
46844684

46854685
var noSwapAttrs = [
4686-
// domainpad stays with domain: its keys name screen edges, so a swap of x and y
4687-
// would need to map left and right to top and bottom
46884686
'anchor', 'domain', 'domainpad', 'overlaying', 'position', 'side',
46894687
'tickangle', 'editType'
46904688
];

‎src/plots/cartesian/constraints.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,6 @@ exports.clean = function clean(gd, ax) {
633633
}
634634
};
635635

636-
// Get the `domainpad` of an axis as a fraction of the plot size.
637-
// The constraint solver works in domain fractions, not in pixels.
638636
function domainPadFraction(ax, fullLayout) {
639637
const pad = ax.domainpad;
640638
if(!pad) return 0;
@@ -650,11 +648,6 @@ function updateDomain(ax, factor, fullLayout) {
650648
var centerFraction = FROM_BL[ax.constraintoward];
651649
var center = inputDomain[0] + (inputDomain[1] - inputDomain[0]) * centerFraction;
652650

653-
// The constraint divides the drawn length of the axis by `factor`. Without padding,
654-
// the drawn length is the domain span. `domainpad` removes a fixed number of pixels
655-
// from the ends, so the drawn length is (span - padding), and only that part scales.
656-
// Thus divide that part, then add the padding back. If the padding covers the full
657-
// domain, nothing remains to scale, so divide the full span and let setScale clamp the padding.
658651
let divisor = factor;
659652
const padFraction = domainPadFraction(ax, fullLayout);
660653
if(padFraction > 0) {

‎src/plots/cartesian/layout_attributes.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,9 @@ module.exports = {
12021202
'so it can hold content with a fixed size, such as a subplot title.',
12031203
'x axes use `left` and `right`. y axes use `top` and `bottom`.',
12041204
'If the padding needs more room than the domain has, the two pads shrink by the same factor,',
1205-
'and the plot area keeps a length of at least 2 pixels.'
1205+
'and the plot area keeps a length of at least 2 pixels.',
1206+
'An axis that sets `overlaying` ignores its own `domainpad` and uses the `domainpad`',
1207+
'of the axis it overlays, so that both axes share the same plot area.'
12061208
].join(' ')
12071209
},
12081210
position: {

‎src/plots/cartesian/position_defaults.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer
8484
if(domain[0] > domain[1] - 1 / 4096) containerOut.domain = dfltDomain;
8585
Lib.noneOrAll(containerIn.domain, containerOut.domain, dfltDomain);
8686

87-
// Only the two sides along this axis have an effect. Do not coerce the other two,
88-
// so that a value with no effect never gets into fullLayout.
8987
if(letter === 'x') {
9088
coerce('domainpad.left');
9189
coerce('domainpad.right');

‎src/plots/cartesian/set_convert.js‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,11 @@ function isValidCategory(v) {
3535
return v !== null && v !== undefined;
3636
}
3737

38-
// The smallest plot area in pixels that `domainpad` can leave. `doAutoMargin` keeps
39-
// the same floor for margins. A floor of 0 is not sufficient: setScale rejects only
40-
// negative lengths, so a length of 0 gives a slope of 0 and the subplot collapses with no error.
4138
const MIN_PADDED_LENGTH = 2;
4239

4340
/**
4441
* Get the part of the requested `domainpad` that fits in a domain band.
4542
*
46-
* `domain` is a fraction of the plot area, so its band shrinks with the figure but the
47-
* padding does not. If the two pads need more room than the band has, the two pads
48-
* get the same scale factor. `doAutoMargin` uses the same method for margins.
49-
*
5043
* @param wanted - the total padding of the two edges, in pixels
5144
* @param bandLength - the length of the domain band, in pixels
5245
* @returns the factor from 0 to 1 to multiply each pad by
@@ -584,8 +577,6 @@ module.exports = function setConvert(ax, fullLayout) {
584577
if(ax.overlaying) {
585578
var ax2 = axisIds.getFromId({ _fullLayout: fullLayout }, ax.overlaying);
586579
ax.domain = ax2.domain;
587-
// an overlaying axis has to sit on exactly the same plot area as the axis
588-
// underneath it, so it takes that axis' padding along with its domain
589580
ax.domainpad = ax2.domainpad;
590581
}
591582

@@ -604,8 +595,6 @@ module.exports = function setConvert(ax, fullLayout) {
604595
// the length in pixels of the domain band, before `domainpad`
605596
const bandLength = (isY ? gs.h : gs.w) * (ax.domain[1] - ax.domain[0]);
606597
const pad = ax.domainpad;
607-
// _offset counts from the top for y and from the left for x,
608-
// so padStart moves the plot area in from that edge
609598
let padStart = 0;
610599
let padEnd = 0;
611600

@@ -619,9 +608,6 @@ module.exports = function setConvert(ax, fullLayout) {
619608
}
620609

621610
ax._length = bandLength - padStart - padEnd;
622-
// Keep the padding after the fit. scattergl, splom and hover spikes add these
623-
// values to their `domain` math. A rebuild from _offset and _length would change
624-
// the last bits of the result, also for an axis with no padding.
625611
ax._padStart = padStart;
626612
ax._padEnd = padEnd;
627613

‎src/traces/scattergl/plot.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ function getViewport(fullLayout, xaxis, yaxis, plotGlPixelRatio) {
2929
var w = gs.w * plotGlPixelRatio;
3030
var h = gs.h * plotGlPixelRatio;
3131

32-
// `domain` does not include `domainpad`, so add the padding to the rect here.
33-
// A rebuild from _offset and _length would move the rect by a fraction of a pixel,
34-
// also for an axis with no padding.
3532
const padL = (xaxis._padStart || 0) * plotGlPixelRatio;
3633
const padR = (xaxis._padEnd || 0) * plotGlPixelRatio;
3734
const padT = (yaxis._padStart || 0) * plotGlPixelRatio;

‎src/traces/splom/base_plot.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ function makeGridData(gd) {
137137

138138
// ya.l2p assumes top-to-bottom coordinate system (a la SVG),
139139
// we need to compute bottom-to-top offsets and slopes:
140-
// add the bottom `domainpad` to the domain math, because a read of _offset
141-
// would move an axis with no padding by a fraction of a pixel
142140
const yOffset = gs.b + ya.domain[0] * gs.h + (ya._padEnd || 0);
143141
var ym = -ya._m;
144142
var yb = -ym * ya.r2l(ya.range[0], ya.calendar);

‎src/traces/splom/plot.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ function plotOne(gd, cd0) {
4141
viewOpts.ranges = new Array(visibleLength);
4242
viewOpts.domains = new Array(visibleLength);
4343

44-
// regl-splom places each cell as a fraction of the full plot area. Convert `domainpad`
45-
// to the same fractions, or the cells keep their size while the axes move. Add the
46-
// padding to `domain` here, because a rebuild from _offset and _length moves every
47-
// cell a little, also for an axis with no padding.
4844
const padFrac = (px, total) => (px || 0) / total;
4945

5046
for(k = 0; k < visibleDims.length; k++) {

‎src/types/generated/schema.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12199,7 +12199,7 @@ export interface LayoutAxis {
1219912199
* @default [0,1]
1220012200
*/
1220112201
domain?: [number, number];
12202-
/** Sets the space in pixels to reserve inside the edges of `domain`. Because `domain` is a fraction of the plot area, the gap between subplots changes with the figure size. `domainpad` keeps the same size in pixels at all figure sizes, so it can hold content with a fixed size, such as a subplot title. x axes use `left` and `right`. y axes use `top` and `bottom`. If the padding needs more room than the domain has, the two pads shrink by the same factor, and the plot area keeps a length of at least 2 pixels. */
12202+
/** Sets the space in pixels to reserve inside the edges of `domain`. Because `domain` is a fraction of the plot area, the gap between subplots changes with the figure size. `domainpad` keeps the same size in pixels at all figure sizes, so it can hold content with a fixed size, such as a subplot title. x axes use `left` and `right`. y axes use `top` and `bottom`. If the padding needs more room than the domain has, the two pads shrink by the same factor, and the plot area keeps a length of at least 2 pixels. An axis that sets `overlaying` ignores its own `domainpad` and uses the `domainpad` of the axis it overlays, so that both axes share the same plot area. */
1220312203
domainpad?: {
1220412204
/**
1220512205
* Sets the space in pixels to reserve inside the bottom edge of `domain`. Applies to y axes only.

0 commit comments

Comments
 (0)