Skip to content

Commit 55b17b2

Browse files
committed
Merge branch 'master' into dropline
2 parents 7953488 + 6e547ef commit 55b17b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+834
-514
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Developers are strongly encouraged to first make a PR to their own plotly.js for
44

55
Before opening a pull request, developer should:
66

7-
- `git rebase` their local branch off the latest `master`
8-
- make sure to **not** `git add` the `dist/` folder (the `dist/` is updated only on verion bumps)
9-
- write an overview of what the PR attempts to do.
7+
- `git rebase` their local branch off the latest `master`,
8+
- make sure to **not** `git add` the `dist/` folder (the `dist/` is updated only on verion bumps),
9+
- write an overview of what the PR attempts to do,
10+
- select the _Allow edits from maintainers_ option (see this [article](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) for more details).
1011

1112
Note that it is forbidden to force push (i.e. `git push -f`) to remote branches associated with opened pull requests. Force pushes make it hard for maintainers to keep track of updates. Therefore, if required, please `git merge master` into your PR branch instead of `git rebase master`.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,17 @@
7272
"gl-mat4": "^1.1.2",
7373
"gl-mesh3d": "^1.2.0",
7474
"gl-plot2d": "^1.2.0",
75-
"gl-plot3d": "^1.5.2",
75+
"gl-plot3d": "^1.5.4",
7676
"gl-pointcloud2d": "^1.0.0",
7777
"gl-scatter2d": "^1.2.2",
78-
"gl-scatter2d-sdf": "^1.3.4",
78+
"gl-scatter2d-sdf": "1.3.4",
7979
"gl-scatter3d": "^1.0.4",
8080
"gl-select-box": "^1.0.1",
8181
"gl-shader": "4.2.0",
8282
"gl-spikes2d": "^1.0.1",
8383
"gl-surface3d": "^1.3.0",
8484
"mapbox-gl": "^0.22.0",
85+
"matrix-camera-controller": "^2.1.3",
8586
"mouse-change": "^1.4.0",
8687
"mouse-wheel": "^1.0.2",
8788
"ndarray": "^1.0.18",

src/components/errorbars/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ errorBars.calc = require('./calc');
1919

2020
errorBars.calcFromTrace = function(trace, layout) {
2121
var x = trace.x || [],
22-
y = trace.y,
22+
y = trace.y || [],
2323
len = x.length || y.length;
2424

2525
var calcdataMock = new Array(len);

src/lib/geojson_utils.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
'use strict';
1111

12+
var BADNUM = require('../constants/numerical').BADNUM;
13+
1214
/**
1315
* Convert calcTrace to GeoJSON 'MultiLineString' coordinate arrays
1416
*
@@ -21,18 +23,19 @@
2123
*
2224
*/
2325
exports.calcTraceToLineCoords = function(calcTrace) {
24-
var trace = calcTrace[0].trace,
25-
connectgaps = trace.connectgaps;
26+
var trace = calcTrace[0].trace;
27+
var connectgaps = trace.connectgaps;
2628

27-
var coords = [],
28-
lineString = [];
29+
var coords = [];
30+
var lineString = [];
2931

3032
for(var i = 0; i < calcTrace.length; i++) {
3133
var calcPt = calcTrace[i];
34+
var lonlat = calcPt.lonlat;
3235

33-
lineString.push(calcPt.lonlat);
34-
35-
if(!connectgaps && calcPt.gapAfter && lineString.length > 0) {
36+
if(lonlat[0] !== BADNUM) {
37+
lineString.push(lonlat);
38+
} else if(!connectgaps && lineString.length > 0) {
3639
coords.push(lineString);
3740
lineString = [];
3841
}

src/plots/mapbox/mapbox.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
111111
});
112112

113113
// clear navigation container
114-
var className = constants.controlContainerClassName,
115-
controlContainer = self.div.getElementsByClassName(className)[0];
114+
var className = constants.controlContainerClassName;
115+
var controlContainer = self.div.getElementsByClassName(className)[0];
116116
self.div.removeChild(controlContainer);
117117

118+
// make sure canvas does not inherit left and top css
119+
map._canvas.canvas.style.left = '0px';
120+
map._canvas.canvas.style.top = '0px';
121+
118122
self.rejectOnError(reject);
119123

120124
map.once('load', function() {
@@ -176,7 +180,6 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
176180

177181
map.on('dragstart', unhover);
178182
map.on('zoomstart', unhover);
179-
180183
};
181184

182185
proto.updateMap = function(calcData, fullLayout, resolve, reject) {

src/plots/plots.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var Plotly = require('../plotly');
1616
var Registry = require('../registry');
1717
var Lib = require('../lib');
1818
var Color = require('../components/color');
19+
var BADNUM = require('../constants/numerical').BADNUM;
1920

2021
var plots = module.exports = {};
2122

@@ -257,6 +258,9 @@ plots.previousPromises = function(gd) {
257258
* Add source links to your graph inside the 'showSources' config argument.
258259
*/
259260
plots.addLinks = function(gd) {
261+
// Do not do anything if showLink and showSources are not set to true in config
262+
if(!gd._context.showLink && !gd._context.showSources) return;
263+
260264
var fullLayout = gd._fullLayout;
261265

262266
var linkContainer = fullLayout._paper
@@ -824,14 +828,15 @@ plots.supplyTraceDefaults = function(traceIn, traceOutIndex, layout, traceInInde
824828
coerce('legendgroup');
825829
}
826830

827-
supplyTransformDefaults(traceIn, traceOut, layout);
831+
plots.supplyTransformDefaults(traceIn, traceOut, layout);
828832
}
829833

830834
return traceOut;
831835
};
832836

833-
function supplyTransformDefaults(traceIn, traceOut, layout) {
837+
plots.supplyTransformDefaults = function(traceIn, traceOut, layout) {
834838
var globalTransforms = layout._globalTransforms || [];
839+
var transformModules = layout._transformModules || [];
835840

836841
if(!Array.isArray(traceIn.transforms) && globalTransforms.length === 0) return;
837842

@@ -852,15 +857,15 @@ function supplyTransformDefaults(traceIn, traceOut, layout) {
852857
transformOut.type = type;
853858
transformOut._module = _module;
854859

855-
Lib.pushUnique(layout._transformModules, _module);
860+
Lib.pushUnique(transformModules, _module);
856861
}
857862
else {
858863
transformOut = Lib.extendFlat({}, transformIn);
859864
}
860865

861866
containerOut.push(transformOut);
862867
}
863-
}
868+
};
864869

865870
function applyTransforms(fullTrace, fullData, layout, fullLayout) {
866871
var container = fullTrace.transforms,
@@ -2012,11 +2017,8 @@ plots.doCalcdata = function(gd, traces) {
20122017
//
20132018
// This ensures there is a calcdata item for every trace,
20142019
// even if cartesian logic doesn't handle it (for things like legends).
2015-
//
2016-
// Tag this artificial calc point with 'placeholder: true',
2017-
// to make it easier to skip over them in during the plot and hover step.
20182020
if(!Array.isArray(cd) || !cd[0]) {
2019-
cd = [{x: false, y: false, placeholder: true}];
2021+
cd = [{x: BADNUM, y: BADNUM}];
20202022
}
20212023

20222024
// add the trace-wide properties to the first point,

src/traces/bar/arrays_to_calcdata.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var mergeArray = require('../../lib').mergeArray;
1515
// arrayOk attributes, merge them into calcdata array
1616
module.exports = function arraysToCalcdata(cd, trace) {
1717
mergeArray(trace.text, cd, 'tx');
18+
mergeArray(trace.hovertext, cd, 'htx');
1819

1920
var marker = trace.marker;
2021
if(marker) {

src/traces/bar/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module.exports = {
4949
dy: scatterAttrs.dy,
5050

5151
text: scatterAttrs.text,
52+
hovertext: scatterAttrs.hovertext,
5253

5354
textposition: {
5455
valType: 'enumerated',

src/traces/bar/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3737
coerce('width');
3838

3939
coerce('text');
40+
coerce('hovertext');
4041

4142
var textPosition = coerce('textposition');
4243

src/traces/bar/hover.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
9999
pointData.xLabelVal = di.p;
100100
}
101101

102-
if(di.tx) pointData.text = di.tx;
102+
if(di.htx) pointData.text = di.htx;
103+
else if(trace.hovertext) pointData.text = trace.hovertext;
104+
else if(di.tx) pointData.text = di.tx;
105+
else if(trace.text) pointData.text = trace.text;
103106

104107
ErrorBars.hoverInfo(di, trace, pointData);
105108

src/traces/pie/attributes.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,27 @@ module.exports = {
7979

8080
text: {
8181
valType: 'data_array',
82-
description: 'Sets text elements associated with each sector.'
82+
description: [
83+
'Sets text elements associated with each sector.',
84+
'If trace `textinfo` contains a *text* flag, these elements will seen',
85+
'on the chart.',
86+
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
87+
'these elements will be seen in the hover labels.'
88+
].join(' ')
89+
},
90+
hovertext: {
91+
valType: 'string',
92+
role: 'info',
93+
dflt: '',
94+
arrayOk: true,
95+
description: [
96+
'Sets hover text elements associated with each sector.',
97+
'If a single string, the same string appears for',
98+
'all data points.',
99+
'If an array of string, the items are mapped in order of',
100+
'this trace\'s sectors.',
101+
'To be seen, trace `hoverinfo` must contain a *text* flag.'
102+
].join(' ')
83103
},
84104

85105
// 'see eg:'

src/traces/pie/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4545

4646
var textData = coerce('text');
4747
var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent');
48+
coerce('hovertext');
4849

4950
coerce('hoverinfo', (layout._dataLength === 1) ? 'label+text+value+percent' : undefined);
5051

src/traces/pie/plot.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,16 @@ module.exports = function plot(gd, cdpie) {
110110
thisText = [];
111111

112112
if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label);
113-
if(trace2.text && trace2.text[pt.i] && hoverinfo.indexOf('text') !== -1) {
114-
thisText.push(trace2.text[pt.i]);
113+
if(hoverinfo.indexOf('text') !== -1) {
114+
if(trace2.hovertext) {
115+
thisText.push(
116+
Array.isArray(trace2.hovertext) ?
117+
trace2.hovertext[pt.i] :
118+
trace2.hovertext
119+
);
120+
} else if(trace2.text && trace2.text[pt.i]) {
121+
thisText.push(trace2.text[pt.i]);
122+
}
115123
}
116124
if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators));
117125
if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators));

src/traces/scatter/arrays_to_calcdata.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var Lib = require('../../lib');
1616
module.exports = function arraysToCalcdata(cd, trace) {
1717

1818
Lib.mergeArray(trace.text, cd, 'tx');
19+
Lib.mergeArray(trace.hovertext, cd, 'htx');
1920
Lib.mergeArray(trace.customdata, cd, 'data');
2021
Lib.mergeArray(trace.textposition, cd, 'tp');
2122
if(trace.textfont) {

src/traces/scatter/attributes.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,23 @@ module.exports = {
8383
'If a single string, the same string appears over',
8484
'all the data points.',
8585
'If an array of string, the items are mapped in order to the',
86-
'this trace\'s (x,y) coordinates.'
86+
'this trace\'s (x,y) coordinates.',
87+
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
88+
'these elements will be seen in the hover labels.'
89+
].join(' ')
90+
},
91+
hovertext: {
92+
valType: 'string',
93+
role: 'info',
94+
dflt: '',
95+
arrayOk: true,
96+
description: [
97+
'Sets hover text elements associated with each (x,y) pair.',
98+
'If a single string, the same string appears over',
99+
'all the data points.',
100+
'If an array of string, the items are mapped in order to the',
101+
'this trace\'s (x,y) coordinates.',
102+
'To be seen, trace `hoverinfo` must contain a *text* flag.'
87103
].join(' ')
88104
},
89105
mode: {

src/traces/scatter/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3838

3939
coerce('customdata');
4040
coerce('text');
41+
coerce('hovertext');
4142
coerce('mode', defaultMode);
4243
coerce('ids');
4344

src/traces/scatter/hover.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
7272
yLabelVal: di.y
7373
});
7474

75-
if(di.tx) pointData.text = di.tx;
75+
if(di.htx) pointData.text = di.htx;
76+
else if(trace.hovertext) pointData.text = trace.hovertext;
77+
else if(di.tx) pointData.text = di.tx;
7678
else if(trace.text) pointData.text = trace.text;
7779

7880
ErrorBars.hoverInfo(di, trace, pointData);

src/traces/scatter/plot.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ module.exports = function plot(gd, plotinfo, cdscatter, transitionOpts, makeOnCo
5151
// Sort the traces, once created, so that the ordering is preserved even when traces
5252
// are shown and hidden. This is needed since we're not just wiping everything out
5353
// and recreating on every update.
54-
for(i = 0, uids = []; i < cdscatter.length; i++) {
55-
uids[i] = cdscatter[i][0].trace.uid;
54+
for(i = 0, uids = {}; i < cdscatter.length; i++) {
55+
uids[cdscatter[i][0].trace.uid] = i;
5656
}
5757

5858
scatterlayer.selectAll('g.trace').sort(function(a, b) {
59-
var idx1 = uids.indexOf(a[0].trace.uid);
60-
var idx2 = uids.indexOf(b[0].trace.uid);
59+
var idx1 = uids[a[0].trace.uid];
60+
var idx2 = uids[b[0].trace.uid];
6161
return idx1 > idx2 ? 1 : -1;
6262
});
6363

src/traces/scatter3d/attributes.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,22 @@ module.exports = {
7272
'If a single string, the same string appears over',
7373
'all the data points.',
7474
'If an array of string, the items are mapped in order to the',
75-
'this trace\'s (x,y,z) coordinates.'
75+
'this trace\'s (x,y,z) coordinates.',
76+
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
77+
'these elements will be seen in the hover labels.'
7678
].join(' ')
7779
}),
80+
hovertext: extendFlat({}, scatterAttrs.hovertext, {
81+
description: [
82+
'Sets text elements associated with each (x,y,z) triplet.',
83+
'If a single string, the same string appears over',
84+
'all the data points.',
85+
'If an array of string, the items are mapped in order to the',
86+
'this trace\'s (x,y,z) coordinates.',
87+
'To be seen, trace `hoverinfo` must contain a *text* flag.'
88+
].join(' ')
89+
}),
90+
7891
mode: extendFlat({}, scatterAttrs.mode, // shouldn't this be on-par with 2D?
7992
{dflt: 'lines+markers'}),
8093
surfaceaxis: {

src/traces/scatter3d/convert.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ proto.handlePick = function(selection) {
5858
selection.object = this.scatterPlot;
5959
this.scatterPlot.highlight(selection.data);
6060
}
61-
if(this.textLabels && this.textLabels[selection.data.index] !== undefined) {
62-
selection.textLabel = this.textLabels[selection.data.index];
61+
if(this.textLabels) {
62+
if(this.textLabels[selection.data.index] !== undefined) {
63+
selection.textLabel = this.textLabels[selection.data.index];
64+
} else {
65+
selection.textLabel = this.textLabels;
66+
}
6367
}
6468
else selection.textLabel = '';
6569

@@ -371,7 +375,7 @@ proto.update = function(data) {
371375
opacity: data.opacity
372376
};
373377

374-
this.textLabels = options.text;
378+
this.textLabels = data.hovertext || data.text;
375379

376380
if(this.mode.indexOf('text') !== -1) {
377381
if(this.textMarkers) this.textMarkers.update(textOptions);

src/traces/scatter3d/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3434
}
3535

3636
coerce('text');
37+
coerce('hovertext');
3738
coerce('mode');
3839

3940
if(subTypes.hasLines(traceOut)) {

0 commit comments

Comments
 (0)