Skip to content

Commit ff6c910

Browse files
committed
Merge branch 'master' into gradient-fill
2 parents 541460a + e54d009 commit ff6c910

37 files changed

+460
-64
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"gl-plot3d": "^1.5.4",
7575
"gl-pointcloud2d": "^1.0.0",
7676
"gl-scatter2d": "^1.2.2",
77-
"gl-scatter2d-sdf": "1.3.4",
77+
"gl-scatter2d-sdf": "^1.3.9",
7878
"gl-scatter3d": "^1.0.4",
7979
"gl-select-box": "^1.0.1",
8080
"gl-shader": "4.2.0",

src/components/drawing/index.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ drawing.makeTester = function(gd) {
573573
// always returns a copy of the bbox, so the caller can modify it safely
574574
var savedBBoxes = [],
575575
maxSavedBBoxes = 10000;
576+
576577
drawing.bBox = function(node) {
577578
// cache elements we've already measured so we don't have to
578579
// remeasure the same thing many times
@@ -581,32 +582,36 @@ drawing.bBox = function(node) {
581582
return Lib.extendFlat({}, savedBBoxes[saveNum.value]);
582583
}
583584

584-
var test3 = d3.select('#js-plotly-tester'),
585-
tester = test3.node();
585+
if(!drawing.test3) {
586+
drawing.test3 = d3.select('#js-plotly-tester');
587+
drawing.tester = drawing.test3.node();
588+
}
586589

587590
// copy the node to test into the tester
588591
var testNode = node.cloneNode(true);
589-
tester.appendChild(testNode);
592+
drawing.tester.appendChild(testNode);
590593
// standardize its position... do we really want to do this?
591594
d3.select(testNode).attr({
592595
x: 0,
593596
y: 0,
594597
transform: ''
595598
});
596599

597-
var testRect = testNode.getBoundingClientRect(),
598-
refRect = test3.select('.js-reference-point')
600+
var testRect = testNode.getBoundingClientRect();
601+
if(!drawing.refRect) {
602+
drawing.refRect = drawing.test3.select('.js-reference-point')
599603
.node().getBoundingClientRect();
604+
}
600605

601-
tester.removeChild(testNode);
606+
drawing.tester.removeChild(testNode);
602607

603608
var bb = {
604609
height: testRect.height,
605610
width: testRect.width,
606-
left: testRect.left - refRect.left,
607-
top: testRect.top - refRect.top,
608-
right: testRect.right - refRect.left,
609-
bottom: testRect.bottom - refRect.top
611+
left: testRect.left - drawing.refRect.left,
612+
top: testRect.top - drawing.refRect.top,
613+
right: testRect.right - drawing.refRect.left,
614+
bottom: testRect.bottom - drawing.refRect.top
610615
};
611616

612617
// make sure we don't have too many saved boxes,

src/components/legend/draw.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ function handleClick(g, gd, numClicks) {
514514
allTraces.push(i);
515515
// Allow the legendonly state through for *all* trace types (including
516516
// carpet for which it's overridden with true/false in supplyDefaults)
517-
traceVisibility.push('legendonly');
517+
traceVisibility.push(
518+
Registry.traceIs(fullData[i], 'notLegendIsolatable') ? true : 'legendonly'
519+
);
518520
}
519521

520522
if(legendgroup === '') {

src/lib/svg_text_utils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ var stringMappings = require('../constants/string_mappings');
1919

2020
// Append SVG
2121

22+
var parser = new DOMParser();
23+
2224
d3.selection.prototype.appendSVG = function(_svgString) {
2325
var skeleton = [
2426
'<svg xmlns="', xmlnsNamespaces.svg, '" ',
@@ -27,7 +29,7 @@ d3.selection.prototype.appendSVG = function(_svgString) {
2729
'</svg>'
2830
].join('');
2931

30-
var dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
32+
var dom = parser.parseFromString(skeleton, 'application/xml'),
3133
childNode = dom.documentElement.firstChild;
3234

3335
while(childNode) {

src/plot_api/manage_arrays.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var nestedProperty = require('../lib/nested_property');
1313
var isPlainObject = require('../lib/is_plain_object');
1414
var noop = require('../lib/noop');
1515
var Loggers = require('../lib/loggers');
16+
var sorterAsc = require('../lib/search').sorterAsc;
1617
var Registry = require('../registry');
1718

1819

@@ -101,7 +102,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np,
101102
return true;
102103
}
103104

104-
var componentNums = Object.keys(edits).map(Number).sort(),
105+
var componentNums = Object.keys(edits).map(Number).sort(sorterAsc),
105106
componentArrayIn = np.get(),
106107
componentArray = componentArrayIn || [],
107108
// componentArrayFull is used just to keep splices in line between

src/plot_api/plot_api.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ Plotly.plot = function(gd, data, layout, config) {
288288
// Now plot the data
289289
function drawData() {
290290
var calcdata = gd.calcdata,
291-
i;
291+
i,
292+
rangesliderContainers = fullLayout._infolayer.selectAll('g.rangeslider-container');
292293

293294
// in case of traces that were heatmaps or contour maps
294295
// previously, remove them and their colorbars explicitly
@@ -308,7 +309,7 @@ Plotly.plot = function(gd, data, layout, config) {
308309
.selectAll(query)
309310
.remove();
310311

311-
fullLayout._infolayer.selectAll('g.rangeslider-container')
312+
rangesliderContainers
312313
.selectAll(query)
313314
.remove();
314315
}

src/plots/gl2d/camera.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function createCamera(scene) {
110110
result.boxEnd[1] = dataY;
111111

112112
// we need to mark the box as initialized right away
113-
// so that we can tell the start and end pionts apart
113+
// so that we can tell the start and end points apart
114114
result.boxInited = true;
115115

116116
// but don't actually enable the box until the cursor moves
@@ -189,6 +189,10 @@ function createCamera(scene) {
189189
result.boxEnabled = false;
190190
result.boxInited = false;
191191
}
192+
// if box was inited but button released then - reset the box
193+
else if(result.boxInited) {
194+
result.boxInited = false;
195+
}
192196
break;
193197

194198
case 'pan':

src/traces/scatter/plot.js

+1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
463463
});
464464

465465
join.selectAll('text')
466+
.classed('textpoint', true)
466467
.call(Drawing.textPointStyle, trace)
467468
.each(function(d) {
468469

src/traces/scattercarpet/calc.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
var isNumeric = require('fast-isnumeric');
1313

1414
var Axes = require('../../plots/cartesian/axes');
15-
var Lib = require('../../lib');
1615

1716
var subTypes = require('../scatter/subtypes');
1817
var calcColorscale = require('../scatter/colorscale_calc');
18+
var arraysToCalcdata = require('../scatter/arrays_to_calcdata');
1919
var lookupCarpet = require('../carpet/lookup_carpetid');
2020

2121
module.exports = function calc(gd, trace) {
@@ -68,8 +68,7 @@ module.exports = function calc(gd, trace) {
6868

6969
calcColorscale(trace);
7070

71-
// this has migrated up from arraysToCalcdata as we have a reference to 's' here
72-
if(typeof s !== 'undefined') Lib.mergeArray(s, cd, 'ms');
71+
arraysToCalcdata(cd, trace);
7372

7473
return cd;
7574
};

src/transforms/filter.js

+61-32
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var axisIds = require('../plots/cartesian/axis_ids');
1515
var autoType = require('../plots/cartesian/axis_autotype');
1616
var setConvert = require('../plots/cartesian/set_convert');
1717

18-
var INEQUALITY_OPS = ['=', '<', '>=', '>', '<='];
18+
var COMPARISON_OPS = ['=', '!=', '<', '>=', '>', '<='];
1919
var INTERVAL_OPS = ['[]', '()', '[)', '(]', '][', ')(', '](', ')['];
2020
var SET_OPS = ['{}', '}{'];
2121

@@ -51,12 +51,16 @@ exports.attributes = {
5151
},
5252
operation: {
5353
valType: 'enumerated',
54-
values: [].concat(INEQUALITY_OPS).concat(INTERVAL_OPS).concat(SET_OPS),
54+
values: []
55+
.concat(COMPARISON_OPS)
56+
.concat(INTERVAL_OPS)
57+
.concat(SET_OPS),
5558
dflt: '=',
5659
description: [
5760
'Sets the filter operation.',
5861

5962
'*=* keeps items equal to `value`',
63+
'*!=* keeps items not equal to `value`',
6064

6165
'*<* keeps items less than `value`',
6266
'*<=* keeps items less than or equal to `value`',
@@ -87,21 +91,31 @@ exports.attributes = {
8791
'Values are expected to be in the same type as the data linked',
8892
'to *target*.',
8993

90-
'When `operation` is set to one of the inequality values',
91-
'(' + INEQUALITY_OPS + ')',
94+
'When `operation` is set to one of',
95+
'the comparison values (' + COMPARISON_OPS + ')',
9296
'*value* is expected to be a number or a string.',
9397

94-
'When `operation` is set to one of the interval value',
98+
'When `operation` is set to one of the interval values',
9599
'(' + INTERVAL_OPS + ')',
96100
'*value* is expected to be 2-item array where the first item',
97101
'is the lower bound and the second item is the upper bound.',
98102

99-
'When `operation`, is set to one of the set value',
103+
'When `operation`, is set to one of the set values',
100104
'(' + SET_OPS + ')',
101105
'*value* is expected to be an array with as many items as',
102106
'the desired set elements.'
103107
].join(' ')
104-
}
108+
},
109+
preservegaps: {
110+
valType: 'boolean',
111+
dflt: false,
112+
description: [
113+
'Determines whether or not gaps in data arrays produced by the filter operation',
114+
'are preserved.',
115+
'Setting this to *true* might be useful when plotting a line chart',
116+
'with `connectgaps` set to *false*.'
117+
].join(' ')
118+
},
105119
};
106120

107121
exports.supplyDefaults = function(transformIn) {
@@ -114,6 +128,7 @@ exports.supplyDefaults = function(transformIn) {
114128
var enabled = coerce('enabled');
115129

116130
if(enabled) {
131+
coerce('preservegaps');
117132
coerce('operation');
118133
coerce('value');
119134
coerce('target');
@@ -149,36 +164,47 @@ exports.calcTransform = function(gd, trace, opts) {
149164
var d2cTarget = (target === 'x' || target === 'y' || target === 'z') ?
150165
target : filterArray;
151166

152-
var dataToCoord = getDataToCoordFunc(gd, trace, d2cTarget),
153-
filterFunc = getFilterFunc(opts, dataToCoord, targetCalendar),
154-
arrayAttrs = PlotSchema.findArrayAttributes(trace),
155-
originalArrays = {};
156-
157-
// copy all original array attribute values,
158-
// and clear arrays in trace
159-
for(var k = 0; k < arrayAttrs.length; k++) {
160-
var attr = arrayAttrs[k],
161-
np = Lib.nestedProperty(trace, attr);
167+
var dataToCoord = getDataToCoordFunc(gd, trace, d2cTarget);
168+
var filterFunc = getFilterFunc(opts, dataToCoord, targetCalendar);
169+
var arrayAttrs = PlotSchema.findArrayAttributes(trace);
170+
var originalArrays = {};
162171

163-
originalArrays[attr] = Lib.extendDeep([], np.get());
164-
np.set([]);
172+
function forAllAttrs(fn, index) {
173+
for(var j = 0; j < arrayAttrs.length; j++) {
174+
var np = Lib.nestedProperty(trace, arrayAttrs[j]);
175+
fn(np, index);
176+
}
165177
}
166178

167-
function fill(attr, i) {
168-
var oldArr = originalArrays[attr],
169-
newArr = Lib.nestedProperty(trace, attr).get();
170-
171-
newArr.push(oldArr[i]);
179+
var initFn;
180+
var fillFn;
181+
if(opts.preservegaps) {
182+
initFn = function(np) {
183+
originalArrays[np.astr] = Lib.extendDeep([], np.get());
184+
np.set(new Array(len));
185+
};
186+
fillFn = function(np, index) {
187+
var val = originalArrays[np.astr][index];
188+
np.get()[index] = val;
189+
};
190+
} else {
191+
initFn = function(np) {
192+
originalArrays[np.astr] = Lib.extendDeep([], np.get());
193+
np.set([]);
194+
};
195+
fillFn = function(np, index) {
196+
var val = originalArrays[np.astr][index];
197+
np.get().push(val);
198+
};
172199
}
173200

174-
for(var i = 0; i < len; i++) {
175-
var v = filterArray[i];
176-
177-
if(!filterFunc(v)) continue;
201+
// copy all original array attribute values, and clear arrays in trace
202+
forAllAttrs(initFn);
178203

179-
for(var j = 0; j < arrayAttrs.length; j++) {
180-
fill(arrayAttrs[j], i);
181-
}
204+
// loop through filter array, fill trace arrays if passed
205+
for(var i = 0; i < len; i++) {
206+
var passed = filterFunc(filterArray[i]);
207+
if(passed) forAllAttrs(fillFn, i);
182208
}
183209
};
184210

@@ -245,7 +271,7 @@ function getFilterFunc(opts, d2c, targetCalendar) {
245271

246272
var coercedValue;
247273

248-
if(isOperationIn(INEQUALITY_OPS)) {
274+
if(isOperationIn(COMPARISON_OPS)) {
249275
coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value);
250276
}
251277
else if(isOperationIn(INTERVAL_OPS)) {
@@ -262,6 +288,9 @@ function getFilterFunc(opts, d2c, targetCalendar) {
262288
case '=':
263289
return function(v) { return d2cTarget(v) === coercedValue; };
264290

291+
case '!=':
292+
return function(v) { return d2cTarget(v) !== coercedValue; };
293+
265294
case '<':
266295
return function(v) { return d2cTarget(v) < coercedValue; };
267296

test/image/baselines/gl2d_10.png

-65 Bytes
Loading

test/image/baselines/gl2d_12.png

-587 Bytes
Loading

test/image/baselines/gl2d_14.png

600 Bytes
Loading

test/image/baselines/gl2d_17.png

199 Bytes
Loading
-641 Bytes
Loading
-233 Bytes
Loading
-333 Bytes
Loading
-81 Bytes
Loading
16 Bytes
Loading
-356 Bytes
Loading
-99 Bytes
Loading
-151 Bytes
Loading
13.2 KB
Loading
-113 Bytes
Loading
Loading
Loading
-105 Bytes
Loading
-130 Bytes
Loading
Loading
-63 Bytes
Loading
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"data": [
3+
{
4+
"type": "scattergl",
5+
"x": [1, 2, 3, 4, 5, 6, 7],
6+
"y": [1, 1, 1, 1, 1, 1, 1],
7+
"mode": "markers",
8+
"text": [
9+
"marker symbol: 'circle'",
10+
"marker symbol: 'circle-open'",
11+
"marker symbol: 'square'",
12+
"marker symbol: 'square-open'",
13+
"marker symbol: 'diamond'",
14+
"marker symbol: 'diamond-open'",
15+
"marker symbol: 'cross'"
16+
],
17+
"marker": {
18+
"color": "blue",
19+
"size": 20,
20+
"symbol": [
21+
"circle",
22+
"circle-open",
23+
"square",
24+
"square-open",
25+
"diamond",
26+
"diamond-open",
27+
"cross"
28+
],
29+
"line": {
30+
"color": "orange",
31+
"width": 1.5
32+
}
33+
}
34+
}
35+
],
36+
"layout": {
37+
"width": 500,
38+
"height": 500,
39+
"xaxis": {
40+
"zeroline": false,
41+
"showline": false,
42+
"showticklabels": false,
43+
"range": [0, 10]
44+
},
45+
"yaxis": {
46+
"zeroline": false,
47+
"showline": false,
48+
"showticklabels": false,
49+
"range": [0, 6]
50+
},
51+
"hovermode": "closest"
52+
}
53+
}

0 commit comments

Comments
 (0)