Skip to content

Commit 6b2b63b

Browse files
committed
Merge branch 'master' into legend-horizontal-computed-dims-fix
2 parents 6b0befe + b5f0316 commit 6b2b63b

38 files changed

+911
-404
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ and import plotly.js as `import Plotly from 'plotly.js-dist';` or `var Plotly =
5555

5656
and use the `Plotly` object in the window scope.
5757

58+
Fastly supports Plotly.js with free CDN service. Read more at https://www.fastly.com/open-source
59+
5860
### Download the latest release
5961

6062
[Latest Release on GitHub](https://github.com/plotly/plotly.js/releases/)

package-lock.json

Lines changed: 137 additions & 147 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@
119119
},
120120
"devDependencies": {
121121
"brfs": "^2.0.2",
122-
"browserify": "^16.3.0",
122+
"browserify": "^16.5.0",
123123
"browserify-transform-tools": "^1.7.0",
124124
"check-node-version": "^3.3.0",
125125
"chttps": "^1.0.6",
126126
"deep-equal": "^1.0.1",
127127
"derequire": "^2.0.6",
128128
"ecstatic": "^3.3.2",
129-
"eslint": "^6.1.0",
129+
"eslint": "^6.3.0",
130130
"falafel": "^2.1.0",
131131
"fs-extra": "^2.0.0",
132132
"fuse.js": "^3.4.5",
@@ -136,10 +136,10 @@
136136
"into-stream": "^4.0.0",
137137
"jasmine-core": "^3.4.0",
138138
"jsdom": "^11.12.0",
139-
"karma": "^4.2.0",
139+
"karma": "^4.3.0",
140140
"karma-browserify": "^6.1.0",
141-
"karma-chrome-launcher": "^3.0.0",
142-
"karma-firefox-launcher": "^1.0.1",
141+
"karma-chrome-launcher": "^3.1.0",
142+
"karma-firefox-launcher": "^1.2.0",
143143
"karma-ie-launcher": "^1.0.0",
144144
"karma-jasmine": "^2.0.1",
145145
"karma-jasmine-spec-tags": "^1.1.0",

src/components/annotations/draw.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
392392
options['_' + axLetter + 'shift'] = textShift;
393393
}
394394

395-
// We have everything we need for calcAutorange at this point,
396-
// we can safely exit - unless we're currently dragging the plot
397-
if(!gd._dragging && annotationIsOffscreen) {
395+
if(annotationIsOffscreen) {
398396
annTextGroupInner.remove();
399397
return;
400398
}

src/components/fx/hover.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
605605
var result = dragElement.unhoverRaw(gd, evt);
606606
if(hasCartesian && ((spikePoints.hLinePoint !== null) || (spikePoints.vLinePoint !== null))) {
607607
if(spikesChanged(oldspikepoints)) {
608-
createSpikelines(spikePoints, spikelineOpts);
608+
createSpikelines(gd, spikePoints, spikelineOpts);
609609
}
610610
}
611611
return result;
612612
}
613613

614614
if(hasCartesian) {
615615
if(spikesChanged(oldspikepoints)) {
616-
createSpikelines(spikePoints, spikelineOpts);
616+
createSpikelines(gd, spikePoints, spikelineOpts);
617617
}
618618
}
619619

@@ -1396,9 +1396,10 @@ function cleanPoint(d, hovermode) {
13961396
return d;
13971397
}
13981398

1399-
function createSpikelines(closestPoints, opts) {
1399+
function createSpikelines(gd, closestPoints, opts) {
14001400
var container = opts.container;
14011401
var fullLayout = opts.fullLayout;
1402+
var gs = fullLayout._size;
14021403
var evt = opts.event;
14031404
var showY = !!closestPoints.hLinePoint;
14041405
var showX = !!closestPoints.vLinePoint;
@@ -1433,8 +1434,7 @@ function createSpikelines(closestPoints, opts) {
14331434
var yMode = ya.spikemode;
14341435
var yThickness = ya.spikethickness;
14351436
var yColor = ya.spikecolor || dfltHLineColor;
1436-
var yBB = ya._boundingBox;
1437-
var xEdge = ((yBB.left + yBB.right) / 2) < hLinePointX ? yBB.right : yBB.left;
1437+
var xEdge = Axes.getPxPosition(gd, ya);
14381438
var xBase, xEndSpike;
14391439

14401440
if(yMode.indexOf('toaxis') !== -1 || yMode.indexOf('across') !== -1) {
@@ -1443,8 +1443,14 @@ function createSpikelines(closestPoints, opts) {
14431443
xEndSpike = hLinePointX;
14441444
}
14451445
if(yMode.indexOf('across') !== -1) {
1446-
xBase = ya._counterSpan[0];
1447-
xEndSpike = ya._counterSpan[1];
1446+
var xAcross0 = ya._counterDomainMin;
1447+
var xAcross1 = ya._counterDomainMax;
1448+
if(ya.anchor === 'free') {
1449+
xAcross0 = Math.min(xAcross0, ya.position);
1450+
xAcross1 = Math.max(xAcross1, ya.position);
1451+
}
1452+
xBase = gs.l + xAcross0 * gs.w;
1453+
xEndSpike = gs.l + xAcross1 * gs.w;
14481454
}
14491455

14501456
// Foreground horizontal line (to y-axis)
@@ -1507,8 +1513,7 @@ function createSpikelines(closestPoints, opts) {
15071513
var xMode = xa.spikemode;
15081514
var xThickness = xa.spikethickness;
15091515
var xColor = xa.spikecolor || dfltVLineColor;
1510-
var xBB = xa._boundingBox;
1511-
var yEdge = ((xBB.top + xBB.bottom) / 2) < vLinePointY ? xBB.bottom : xBB.top;
1516+
var yEdge = Axes.getPxPosition(gd, xa);
15121517
var yBase, yEndSpike;
15131518

15141519
if(xMode.indexOf('toaxis') !== -1 || xMode.indexOf('across') !== -1) {
@@ -1517,8 +1522,14 @@ function createSpikelines(closestPoints, opts) {
15171522
yEndSpike = vLinePointY;
15181523
}
15191524
if(xMode.indexOf('across') !== -1) {
1520-
yBase = xa._counterSpan[0];
1521-
yEndSpike = xa._counterSpan[1];
1525+
var yAcross0 = xa._counterDomainMin;
1526+
var yAcross1 = xa._counterDomainMax;
1527+
if(xa.anchor === 'free') {
1528+
yAcross0 = Math.min(yAcross0, xa.position);
1529+
yAcross1 = Math.max(yAcross1, xa.position);
1530+
}
1531+
yBase = gs.t + (1 - yAcross1) * gs.h;
1532+
yEndSpike = gs.t + (1 - yAcross0) * gs.h;
15221533
}
15231534

15241535
// Foreground vertical line (to x-axis)

src/components/rangeslider/draw.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,14 @@ module.exports = function(gd) {
108108

109109
var gs = fullLayout._size;
110110
var domain = axisOpts.domain;
111-
var tickHeight = opts._tickHeight;
112-
113-
var oppBottom = opts._oppBottom;
114111

115112
opts._width = gs.w * (domain[1] - domain[0]);
116113

117114
var x = Math.round(gs.l + (gs.w * domain[0]));
118115

119116
var y = Math.round(
120-
gs.t + gs.h * (1 - oppBottom) +
121-
tickHeight +
117+
gs.t + gs.h * (1 - axisOpts._counterDomainMin) +
118+
(axisOpts.side === 'bottom' ? axisOpts._depth : 0) +
122119
opts._offsetShift + constants.extraPad
123120
);
124121

src/components/rangeslider/helpers.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
'use strict';
1010

1111
var axisIDs = require('../../plots/cartesian/axis_ids');
12+
var svgTextUtils = require('../../lib/svg_text_utils');
1213
var constants = require('./constants');
14+
var LINE_SPACING = require('../../constants/alignment').LINE_SPACING;
1315
var name = constants.name;
1416

1517
function isVisible(ax) {
@@ -42,27 +44,30 @@ exports.makeData = function(fullLayout) {
4244
};
4345

4446
exports.autoMarginOpts = function(gd, ax) {
47+
var fullLayout = gd._fullLayout;
4548
var opts = ax[name];
49+
var axLetter = ax._id.charAt(0);
4650

47-
var oppBottom = Infinity;
48-
var counterAxes = ax._counterAxes;
49-
for(var j = 0; j < counterAxes.length; j++) {
50-
var counterId = counterAxes[j];
51-
var oppAxis = axisIDs.getFromId(gd, counterId);
52-
oppBottom = Math.min(oppBottom, oppAxis.domain[0]);
51+
var bottomDepth = 0;
52+
var titleHeight = 0;
53+
if(ax.side === 'bottom') {
54+
bottomDepth = ax._depth;
55+
if(ax.title.text !== fullLayout._dfltTitle[axLetter]) {
56+
// as in rangeslider/draw.js
57+
titleHeight = 1.5 * ax.title.font.size + 10 + opts._offsetShift;
58+
// multi-line extra bump
59+
var extraLines = (ax.title.text.match(svgTextUtils.BR_TAG_ALL) || []).length;
60+
titleHeight += extraLines * ax.title.font.size * LINE_SPACING;
61+
}
5362
}
54-
opts._oppBottom = oppBottom;
55-
56-
var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0;
57-
opts._tickHeight = tickHeight;
5863

5964
return {
6065
x: 0,
61-
y: oppBottom,
66+
y: ax._counterDomainMin,
6267
l: 0,
6368
r: 0,
6469
t: 0,
65-
b: opts._height + gd._fullLayout.margin.b + tickHeight,
70+
b: opts._height + bottomDepth + Math.max(fullLayout.margin.b, titleHeight),
6671
pad: constants.extraPad + opts._offsetShift * 2
6772
};
6873
};

src/lib/svg_text_utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ var SPLIT_TAGS = /(<[^<>]*>)/;
266266
var ONE_TAG = /<(\/?)([^ >]*)(\s+(.*))?>/i;
267267

268268
var BR_TAG = /<br(\s+.*)?>/i;
269+
exports.BR_TAG_ALL = /<br(\s+.*)?>/gi;
269270

270271
/*
271272
* style and href: pull them out of either single or double quotes. Also

src/plot_api/subroutines.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function lsInner(gd) {
7272
// can still get here because it makes some of the SVG structure
7373
// for shared features like selections.
7474
if(!fullLayout._has('cartesian')) {
75-
return gd._promises.length && Promise.all(gd._promises);
75+
return Plots.previousPromises(gd);
7676
}
7777

7878
function getLinePosition(ax, counterAx, side) {
@@ -347,7 +347,7 @@ function lsInner(gd) {
347347

348348
Axes.makeClipPaths(gd);
349349

350-
return gd._promises.length && Promise.all(gd._promises);
350+
return Plots.previousPromises(gd);
351351
}
352352

353353
function shouldShowLinesOrTicks(ax, subplot) {
@@ -599,9 +599,11 @@ exports.drawData = function(gd) {
599599
// styling separate from drawing
600600
Plots.style(gd);
601601

602-
// show annotations and shapes
602+
// draw components that can be drawn on axes,
603+
// and that do not push the margins
603604
Registry.getComponentMethod('shapes', 'draw')(gd);
604605
Registry.getComponentMethod('annotations', 'draw')(gd);
606+
Registry.getComponentMethod('images', 'draw')(gd);
605607

606608
// Mark the first render as complete
607609
fullLayout._replotting = false;
@@ -717,9 +719,6 @@ exports.doAutoRangeAndConstraints = function(gd) {
717719
// correctly sized and the whole plot re-margined. fullLayout._replotting must
718720
// be set to false before these will work properly.
719721
exports.finalDraw = function(gd) {
720-
Registry.getComponentMethod('shapes', 'draw')(gd);
721-
Registry.getComponentMethod('images', 'draw')(gd);
722-
Registry.getComponentMethod('annotations', 'draw')(gd);
723722
// TODO: rangesliders really belong in marginPushers but they need to be
724723
// drawn after data - can we at least get the margin pushing part separated
725724
// out and done earlier?

0 commit comments

Comments
 (0)