Skip to content

Commit 8d7db15

Browse files
authored
Merge pull request #5438 from plotly/reimplement-pointcloud
Keep pointcloud trace type in v2 API
2 parents b854d61 + 7405557 commit 8d7db15

26 files changed

+829
-26
lines changed

Diff for: lib/index-gl2d.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var Plotly = require('./core');
1313
Plotly.register([
1414
require('./scattergl'),
1515
require('./splom'),
16+
require('./pointcloud'),
1617
require('./heatmapgl'),
1718
require('./parcoords')
1819
]);

Diff for: lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Plotly.register([
4444
require('./scattergl'),
4545
require('./splom'),
4646

47+
require('./pointcloud'),
4748
require('./heatmapgl'),
4849

4950
require('./parcoords'),

Diff for: lib/pointcloud.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2021, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = require('../src/traces/pointcloud');

Diff for: package-lock.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"gl-mesh3d": "^2.3.1",
8989
"gl-plot2d": "^1.4.5",
9090
"gl-plot3d": "^2.4.7",
91+
"gl-pointcloud2d": "^1.0.3",
9192
"gl-scatter3d": "^1.2.3",
9293
"gl-select-box": "^1.0.4",
9394
"gl-spikes2d": "^1.0.2",

Diff for: src/components/images/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ module.exports = function draw(gd) {
237237
var subplotObj = fullLayout._plots[subplot];
238238

239239
// filter out overlaid plots (which have their images on the main plot)
240-
// and heatmapgl plots (which don't support below images, at least not yet)
240+
// and gl2d plots (which don't support below images, at least not yet)
241241
if(!subplotObj.imagelayer) continue;
242242

243243
var imagesOnSubplot = subplotObj.imagelayer.selectAll('image')

Diff for: src/components/modebar/manage.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function getButtonGroups(gd) {
8989
var hasGeo = fullLayout._has('geo');
9090
var hasPie = fullLayout._has('pie');
9191
var hasFunnelarea = fullLayout._has('funnelarea');
92-
var hasHeatmapgl = fullLayout._has('gl2d');
92+
var hasGL2D = fullLayout._has('gl2d');
9393
var hasTernary = fullLayout._has('ternary');
9494
var hasMapbox = fullLayout._has('mapbox');
9595
var hasPolar = fullLayout._has('polar');
@@ -124,7 +124,7 @@ function getButtonGroups(gd) {
124124
var resetGroup = [];
125125
var dragModeGroup = [];
126126

127-
if((hasCartesian || hasHeatmapgl || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) {
127+
if((hasCartesian || hasGL2D || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) {
128128
// graphs with more than one plot types get 'union buttons'
129129
// which reset the view or toggle hover labels across all subplots.
130130
hoverGroup = ['toggleHover'];
@@ -140,7 +140,7 @@ function getButtonGroups(gd) {
140140
zoomGroup = ['zoomInMapbox', 'zoomOutMapbox'];
141141
hoverGroup = ['toggleHover'];
142142
resetGroup = ['resetViewMapbox'];
143-
} else if(hasHeatmapgl) {
143+
} else if(hasGL2D) {
144144
hoverGroup = ['hoverClosestGl2d'];
145145
} else if(hasPie) {
146146
hoverGroup = ['hoverClosestPie'];
@@ -161,14 +161,14 @@ function getButtonGroups(gd) {
161161
hoverGroup = [];
162162
}
163163

164-
if((hasCartesian || hasHeatmapgl) && !allAxesFixed) {
164+
if((hasCartesian || hasGL2D) && !allAxesFixed) {
165165
zoomGroup = ['zoomIn2d', 'zoomOut2d', 'autoScale2d'];
166166
if(resetGroup[0] !== 'resetViews') resetGroup = ['resetScale2d'];
167167
}
168168

169169
if(hasGL3D) {
170170
dragModeGroup = ['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'];
171-
} else if(((hasCartesian || hasHeatmapgl) && !allAxesFixed) || hasTernary) {
171+
} else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) {
172172
dragModeGroup = ['zoom2d', 'pan2d'];
173173
} else if(hasMapbox || hasGeo) {
174174
dragModeGroup = ['pan2d'];

Diff for: src/plot_api/plot_schema.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ function layoutHeadAttr(fullLayout, head) {
332332
_module = basePlotModules[i];
333333
if(_module.attrRegex && _module.attrRegex.test(head)) {
334334
// if a module defines overrides, these take precedence
335-
// initially this was to allow heatmapgl different editTypes from svg cartesian
335+
// initially this is to allow gl2d different editTypes from svg cartesian
336336
if(_module.layoutAttrOverrides) return _module.layoutAttrOverrides;
337337

338338
// otherwise take the first attributes we find
339339
if(!out && _module.layoutAttributes) out = _module.layoutAttributes;
340340
}
341341

342342
// a module can also override the behavior of base (and component) module layout attrs
343-
// again see heatmapgl for initial use case
343+
// again see gl2d for initial use case
344344
var baseOverrides = _module.baseLayoutAttrOverrides;
345345
if(baseOverrides && head in baseOverrides) return baseOverrides[head];
346346
}

Diff for: src/plot_api/subroutines.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function lsInner(gd) {
6868
exports.drawMainTitle(gd);
6969
ModeBar.manage(gd);
7070

71-
// _has('cartesian') means SVG specifically, not heatmapgl - but heatmapgl
71+
// _has('cartesian') means SVG specifically, not GL2D - but GL2D
7272
// can still get here because it makes some of the SVG structure
7373
// for shared features like selections.
7474
if(!fullLayout._has('cartesian')) {

Diff for: src/plots/cartesian/axes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption
102102
if(!extraOption) extraOption = dflt;
103103
axlist = axlist.concat(axlist.map(function(x) { return x + ' domain'; }));
104104

105-
// data-ref annotations are not supported in heatmapgl yet
105+
// data-ref annotations are not supported in gl2d yet
106106

107107
attrDef[refAttr] = {
108108
valType: 'enumerated',

Diff for: src/plots/cartesian/include_components.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = function makeIncludeComponents(containerArrayName) {
3535
var xaList = subplots.xaxis;
3636
var yaList = subplots.yaxis;
3737
var cartesianList = subplots.cartesian;
38-
var hasCartesianOrHeatmapgl = layoutOut._has('cartesian') || layoutOut._has('gl2d');
38+
var hasCartesianOrGL2D = layoutOut._has('cartesian') || layoutOut._has('gl2d');
3939

4040
for(var i = 0; i < array.length; i++) {
4141
var itemi = array[i];
@@ -49,7 +49,7 @@ module.exports = function makeIncludeComponents(containerArrayName) {
4949
var hasXref = idRegex.x.test(xref);
5050
var hasYref = idRegex.y.test(yref);
5151
if(hasXref || hasYref) {
52-
if(!hasCartesianOrHeatmapgl) Lib.pushUnique(layoutOut._basePlotModules, Cartesian);
52+
if(!hasCartesianOrGL2D) Lib.pushUnique(layoutOut._basePlotModules, Cartesian);
5353

5454
var newAxis = false;
5555
if(hasXref && xaList.indexOf(xref) === -1) {

Diff for: src/plots/plots.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ plots.supplyDefaults = function(gd, opts) {
467467
// clean subplots and other artifacts from previous plot calls
468468
plots.cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout);
469469

470-
var hadHeatmapgl = !!(oldFullLayout._has && oldFullLayout._has('gl2d'));
471-
var hasHeatmapgl = !!(newFullLayout._has && newFullLayout._has('gl2d'));
470+
var hadGL2D = !!(oldFullLayout._has && oldFullLayout._has('gl2d'));
471+
var hasGL2D = !!(newFullLayout._has && newFullLayout._has('gl2d'));
472472
var hadCartesian = !!(oldFullLayout._has && oldFullLayout._has('cartesian'));
473473
var hasCartesian = !!(newFullLayout._has && newFullLayout._has('cartesian'));
474-
var hadBgLayer = hadCartesian || hadHeatmapgl;
475-
var hasBgLayer = hasCartesian || hasHeatmapgl;
474+
var hadBgLayer = hadCartesian || hadGL2D;
475+
var hasBgLayer = hasCartesian || hasGL2D;
476476
if(hadBgLayer && !hasBgLayer) {
477477
// remove bgLayer
478478
oldFullLayout._bgLayer.remove();

Diff for: src/traces/heatmap/make_bound_array.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
1515
var arrayOut = [];
1616
var isContour = Registry.traceIs(trace, 'contour');
1717
var isHist = Registry.traceIs(trace, 'histogram');
18-
var isHeatmapgl = Registry.traceIs(trace, 'gl2d');
18+
var isGL2D = Registry.traceIs(trace, 'gl2d');
1919
var v0;
2020
var dv;
2121
var i;
@@ -30,7 +30,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
3030
// and extend it linearly based on the last two points
3131
if(len <= numbricks) {
3232
// contour plots only want the centers
33-
if(isContour || isHeatmapgl) arrayOut = arrayIn.slice(0, numbricks);
33+
if(isContour || isGL2D) arrayOut = arrayIn.slice(0, numbricks);
3434
else if(numbricks === 1) {
3535
arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5];
3636
} else {
@@ -77,7 +77,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
7777

7878
dv = dvIn || 1;
7979

80-
for(i = (isContour || isHeatmapgl) ? 0 : -0.5; i < numbricks; i++) {
80+
for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) {
8181
arrayOut.push(v0 + dv * i);
8282
}
8383
}

Diff for: src/traces/pointcloud/attributes.js

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/**
2+
* Copyright 2012-2021, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var scatterglAttrs = require('../scatter/attributes');
12+
13+
module.exports = {
14+
x: scatterglAttrs.x,
15+
y: scatterglAttrs.y,
16+
xy: {
17+
valType: 'data_array',
18+
editType: 'calc',
19+
description: [
20+
'Faster alternative to specifying `x` and `y` separately.',
21+
'If supplied, it must be a typed `Float32Array` array that',
22+
'represents points such that `xy[i * 2] = x[i]` and `xy[i * 2 + 1] = y[i]`'
23+
].join(' ')
24+
},
25+
indices: {
26+
valType: 'data_array',
27+
editType: 'calc',
28+
description: [
29+
'A sequential value, 0..n, supply it to avoid creating this array inside plotting.',
30+
'If specified, it must be a typed `Int32Array` array.',
31+
'Its length must be equal to or greater than the number of points.',
32+
'For the best performance and memory use, create one large `indices` typed array',
33+
'that is guaranteed to be at least as long as the largest number of points during',
34+
'use, and reuse it on each `Plotly.restyle()` call.'
35+
].join(' ')
36+
},
37+
xbounds: {
38+
valType: 'data_array',
39+
editType: 'calc',
40+
description: [
41+
'Specify `xbounds` in the shape of `[xMin, xMax] to avoid looping through',
42+
'the `xy` typed array. Use it in conjunction with `xy` and `ybounds` for the performance benefits.'
43+
].join(' ')
44+
},
45+
ybounds: {
46+
valType: 'data_array',
47+
editType: 'calc',
48+
description: [
49+
'Specify `ybounds` in the shape of `[yMin, yMax] to avoid looping through',
50+
'the `xy` typed array. Use it in conjunction with `xy` and `xbounds` for the performance benefits.'
51+
].join(' ')
52+
},
53+
text: scatterglAttrs.text,
54+
marker: {
55+
color: {
56+
valType: 'color',
57+
arrayOk: false,
58+
59+
editType: 'calc',
60+
description: [
61+
'Sets the marker fill color. It accepts a specific color.',
62+
'If the color is not fully opaque and there are hundreds of thousands',
63+
'of points, it may cause slower zooming and panning.'
64+
].join('')
65+
},
66+
opacity: {
67+
valType: 'number',
68+
min: 0,
69+
max: 1,
70+
dflt: 1,
71+
arrayOk: false,
72+
73+
editType: 'calc',
74+
description: [
75+
'Sets the marker opacity. The default value is `1` (fully opaque).',
76+
'If the markers are not fully opaque and there are hundreds of thousands',
77+
'of points, it may cause slower zooming and panning.',
78+
'Opacity fades the color even if `blend` is left on `false` even if there',
79+
'is no translucency effect in that case.'
80+
].join(' ')
81+
},
82+
blend: {
83+
valType: 'boolean',
84+
dflt: null,
85+
86+
editType: 'calc',
87+
description: [
88+
'Determines if colors are blended together for a translucency effect',
89+
'in case `opacity` is specified as a value less then `1`.',
90+
'Setting `blend` to `true` reduces zoom/pan',
91+
'speed if used with large numbers of points.'
92+
].join(' ')
93+
},
94+
sizemin: {
95+
valType: 'number',
96+
min: 0.1,
97+
max: 2,
98+
dflt: 0.5,
99+
100+
editType: 'calc',
101+
description: [
102+
'Sets the minimum size (in px) of the rendered marker points, effective when',
103+
'the `pointcloud` shows a million or more points.'
104+
].join(' ')
105+
},
106+
sizemax: {
107+
valType: 'number',
108+
min: 0.1,
109+
dflt: 20,
110+
111+
editType: 'calc',
112+
description: [
113+
'Sets the maximum size (in px) of the rendered marker points.',
114+
'Effective when the `pointcloud` shows only few points.'
115+
].join(' ')
116+
},
117+
border: {
118+
color: {
119+
valType: 'color',
120+
arrayOk: false,
121+
122+
editType: 'calc',
123+
description: [
124+
'Sets the stroke color. It accepts a specific color.',
125+
'If the color is not fully opaque and there are hundreds of thousands',
126+
'of points, it may cause slower zooming and panning.'
127+
].join(' ')
128+
},
129+
arearatio: {
130+
valType: 'number',
131+
min: 0,
132+
max: 1,
133+
dflt: 0,
134+
135+
editType: 'calc',
136+
description: [
137+
'Specifies what fraction of the marker area is covered with the',
138+
'border.'
139+
].join(' ')
140+
},
141+
editType: 'calc'
142+
},
143+
editType: 'calc'
144+
},
145+
transforms: undefined
146+
};

0 commit comments

Comments
 (0)