Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep pointcloud trace type in v2 API #5438

Merged
merged 2 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index-gl2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Plotly = require('./core');
Plotly.register([
require('./scattergl'),
require('./splom'),
require('./pointcloud'),
require('./heatmapgl'),
require('./parcoords')
]);
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Plotly.register([
require('./scattergl'),
require('./splom'),

require('./pointcloud'),
require('./heatmapgl'),

require('./parcoords'),
Expand Down
11 changes: 11 additions & 0 deletions lib/pointcloud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2021, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/traces/pointcloud');
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"gl-mesh3d": "^2.3.1",
"gl-plot2d": "^1.4.5",
"gl-plot3d": "^2.4.7",
"gl-pointcloud2d": "^1.0.3",
"gl-scatter3d": "^1.2.3",
"gl-select-box": "^1.0.4",
"gl-spikes2d": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/images/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ module.exports = function draw(gd) {
var subplotObj = fullLayout._plots[subplot];

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

var imagesOnSubplot = subplotObj.imagelayer.selectAll('image')
Expand Down
10 changes: 5 additions & 5 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function getButtonGroups(gd) {
var hasGeo = fullLayout._has('geo');
var hasPie = fullLayout._has('pie');
var hasFunnelarea = fullLayout._has('funnelarea');
var hasHeatmapgl = fullLayout._has('gl2d');
var hasGL2D = fullLayout._has('gl2d');
var hasTernary = fullLayout._has('ternary');
var hasMapbox = fullLayout._has('mapbox');
var hasPolar = fullLayout._has('polar');
Expand Down Expand Up @@ -124,7 +124,7 @@ function getButtonGroups(gd) {
var resetGroup = [];
var dragModeGroup = [];

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

if((hasCartesian || hasHeatmapgl) && !allAxesFixed) {
if((hasCartesian || hasGL2D) && !allAxesFixed) {
zoomGroup = ['zoomIn2d', 'zoomOut2d', 'autoScale2d'];
if(resetGroup[0] !== 'resetViews') resetGroup = ['resetScale2d'];
}

if(hasGL3D) {
dragModeGroup = ['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'];
} else if(((hasCartesian || hasHeatmapgl) && !allAxesFixed) || hasTernary) {
} else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) {
dragModeGroup = ['zoom2d', 'pan2d'];
} else if(hasMapbox || hasGeo) {
dragModeGroup = ['pan2d'];
Expand Down
4 changes: 2 additions & 2 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ function layoutHeadAttr(fullLayout, head) {
_module = basePlotModules[i];
if(_module.attrRegex && _module.attrRegex.test(head)) {
// if a module defines overrides, these take precedence
// initially this was to allow heatmapgl different editTypes from svg cartesian
// initially this is to allow gl2d different editTypes from svg cartesian
if(_module.layoutAttrOverrides) return _module.layoutAttrOverrides;

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

// a module can also override the behavior of base (and component) module layout attrs
// again see heatmapgl for initial use case
// again see gl2d for initial use case
var baseOverrides = _module.baseLayoutAttrOverrides;
if(baseOverrides && head in baseOverrides) return baseOverrides[head];
}
Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function lsInner(gd) {
exports.drawMainTitle(gd);
ModeBar.manage(gd);

// _has('cartesian') means SVG specifically, not heatmapgl - but heatmapgl
// _has('cartesian') means SVG specifically, not GL2D - but GL2D
// can still get here because it makes some of the SVG structure
// for shared features like selections.
if(!fullLayout._has('cartesian')) {
Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption
if(!extraOption) extraOption = dflt;
axlist = axlist.concat(axlist.map(function(x) { return x + ' domain'; }));

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

attrDef[refAttr] = {
valType: 'enumerated',
Expand Down
4 changes: 2 additions & 2 deletions src/plots/cartesian/include_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function makeIncludeComponents(containerArrayName) {
var xaList = subplots.xaxis;
var yaList = subplots.yaxis;
var cartesianList = subplots.cartesian;
var hasCartesianOrHeatmapgl = layoutOut._has('cartesian') || layoutOut._has('gl2d');
var hasCartesianOrGL2D = layoutOut._has('cartesian') || layoutOut._has('gl2d');

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

var newAxis = false;
if(hasXref && xaList.indexOf(xref) === -1) {
Expand Down
8 changes: 4 additions & 4 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ plots.supplyDefaults = function(gd, opts) {
// clean subplots and other artifacts from previous plot calls
plots.cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout);

var hadHeatmapgl = !!(oldFullLayout._has && oldFullLayout._has('gl2d'));
var hasHeatmapgl = !!(newFullLayout._has && newFullLayout._has('gl2d'));
var hadGL2D = !!(oldFullLayout._has && oldFullLayout._has('gl2d'));
var hasGL2D = !!(newFullLayout._has && newFullLayout._has('gl2d'));
var hadCartesian = !!(oldFullLayout._has && oldFullLayout._has('cartesian'));
var hasCartesian = !!(newFullLayout._has && newFullLayout._has('cartesian'));
var hadBgLayer = hadCartesian || hadHeatmapgl;
var hasBgLayer = hasCartesian || hasHeatmapgl;
var hadBgLayer = hadCartesian || hadGL2D;
var hasBgLayer = hasCartesian || hasGL2D;
if(hadBgLayer && !hasBgLayer) {
// remove bgLayer
oldFullLayout._bgLayer.remove();
Expand Down
6 changes: 3 additions & 3 deletions src/traces/heatmap/make_bound_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
var arrayOut = [];
var isContour = Registry.traceIs(trace, 'contour');
var isHist = Registry.traceIs(trace, 'histogram');
var isHeatmapgl = Registry.traceIs(trace, 'gl2d');
var isGL2D = Registry.traceIs(trace, 'gl2d');
var v0;
var dv;
var i;
Expand All @@ -30,7 +30,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
// and extend it linearly based on the last two points
if(len <= numbricks) {
// contour plots only want the centers
if(isContour || isHeatmapgl) arrayOut = arrayIn.slice(0, numbricks);
if(isContour || isGL2D) arrayOut = arrayIn.slice(0, numbricks);
else if(numbricks === 1) {
arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5];
} else {
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,

dv = dvIn || 1;

for(i = (isContour || isHeatmapgl) ? 0 : -0.5; i < numbricks; i++) {
for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) {
arrayOut.push(v0 + dv * i);
}
}
Expand Down
146 changes: 146 additions & 0 deletions src/traces/pointcloud/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* Copyright 2012-2021, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var scatterglAttrs = require('../scatter/attributes');

module.exports = {
x: scatterglAttrs.x,
y: scatterglAttrs.y,
xy: {
valType: 'data_array',
editType: 'calc',
description: [
'Faster alternative to specifying `x` and `y` separately.',
'If supplied, it must be a typed `Float32Array` array that',
'represents points such that `xy[i * 2] = x[i]` and `xy[i * 2 + 1] = y[i]`'
].join(' ')
},
indices: {
valType: 'data_array',
editType: 'calc',
description: [
'A sequential value, 0..n, supply it to avoid creating this array inside plotting.',
'If specified, it must be a typed `Int32Array` array.',
'Its length must be equal to or greater than the number of points.',
'For the best performance and memory use, create one large `indices` typed array',
'that is guaranteed to be at least as long as the largest number of points during',
'use, and reuse it on each `Plotly.restyle()` call.'
].join(' ')
},
xbounds: {
valType: 'data_array',
editType: 'calc',
description: [
'Specify `xbounds` in the shape of `[xMin, xMax] to avoid looping through',
'the `xy` typed array. Use it in conjunction with `xy` and `ybounds` for the performance benefits.'
].join(' ')
},
ybounds: {
valType: 'data_array',
editType: 'calc',
description: [
'Specify `ybounds` in the shape of `[yMin, yMax] to avoid looping through',
'the `xy` typed array. Use it in conjunction with `xy` and `xbounds` for the performance benefits.'
].join(' ')
},
text: scatterglAttrs.text,
marker: {
color: {
valType: 'color',
arrayOk: false,

editType: 'calc',
description: [
'Sets the marker fill color. It accepts a specific color.',
'If the color is not fully opaque and there are hundreds of thousands',
'of points, it may cause slower zooming and panning.'
].join('')
},
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 1,
arrayOk: false,

editType: 'calc',
description: [
'Sets the marker opacity. The default value is `1` (fully opaque).',
'If the markers are not fully opaque and there are hundreds of thousands',
'of points, it may cause slower zooming and panning.',
'Opacity fades the color even if `blend` is left on `false` even if there',
'is no translucency effect in that case.'
].join(' ')
},
blend: {
valType: 'boolean',
dflt: null,

editType: 'calc',
description: [
'Determines if colors are blended together for a translucency effect',
'in case `opacity` is specified as a value less then `1`.',
'Setting `blend` to `true` reduces zoom/pan',
'speed if used with large numbers of points.'
].join(' ')
},
sizemin: {
valType: 'number',
min: 0.1,
max: 2,
dflt: 0.5,

editType: 'calc',
description: [
'Sets the minimum size (in px) of the rendered marker points, effective when',
'the `pointcloud` shows a million or more points.'
].join(' ')
},
sizemax: {
valType: 'number',
min: 0.1,
dflt: 20,

editType: 'calc',
description: [
'Sets the maximum size (in px) of the rendered marker points.',
'Effective when the `pointcloud` shows only few points.'
].join(' ')
},
border: {
color: {
valType: 'color',
arrayOk: false,

editType: 'calc',
description: [
'Sets the stroke color. It accepts a specific color.',
'If the color is not fully opaque and there are hundreds of thousands',
'of points, it may cause slower zooming and panning.'
].join(' ')
},
arearatio: {
valType: 'number',
min: 0,
max: 1,
dflt: 0,

editType: 'calc',
description: [
'Specifies what fraction of the marker area is covered with the',
'border.'
].join(' ')
},
editType: 'calc'
},
editType: 'calc'
},
transforms: undefined
};
Loading