Skip to content
1 change: 1 addition & 0 deletions lib/index-gl2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var Plotly = require('./core');

Plotly.register([
require('./scattergl'),
require('./pointcloud'),
require('./heatmapgl'),
require('./contourgl')
]);
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Plotly.register([
require('./scattergeo'),
require('./choropleth'),
require('./scattergl'),
require('./pointcloud'),
require('./scatterternary'),
require('./scattermapbox')
]);
Expand Down
9 changes: 9 additions & 0 deletions lib/pointcloud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright 2012-2016, 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.
*/

module.exports = require('../src/traces/pointcloud');
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"gl-plot3d": "^1.5.0",
"gl-scatter2d": "^1.0.5",
"gl-scatter2d-fancy": "^1.1.1",
"gl-pointcloud2d": "^1.0.0",
"gl-scatter3d": "^1.0.4",
"gl-select-box": "^1.0.1",
"gl-spikes2d": "^1.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Promise": true,
"Float32Array": true,
"Uint8Array": true,
"Int32Array": true,
"ArrayBuffer": true
},
"rules": {
Expand Down
21 changes: 21 additions & 0 deletions src/lib/float32_truncate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2012-2016, 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';

/**
* Truncate a Float32Array to some length. A wrapper to support environments
* (e.g. node-webkit) that do not implement Float32Array.prototype.slice
*/
module.exports = function truncate(float32ArrayIn, len) {
// for some reason, ES2015 Float32Array.prototype.slice takes 2x as long...
// therefore we aren't checking for its existence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting comment. Thanks for checking!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All too often, 'recently' added language elements (as in: the last few years) are slower even if intuitively they should be faster. Back in 2014, untyped arrays were faster than typed arrays even for plain calculations; same with Map.

var float32ArrayOut = new Float32Array(len);
for(var i = 0; i < len; i++) float32ArrayOut[i] = float32ArrayIn[i];
return float32ArrayOut;
};
132 changes: 132 additions & 0 deletions src/traces/pointcloud/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* Copyright 2012-2016, 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('../scattergl/attributes');

module.exports = {
x: scatterglAttrs.x,
y: scatterglAttrs.y,
xy: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a dream come true

valType: 'data_array',
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',
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',
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',
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,
role: 'style',
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,
role: 'style',
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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🎉

valType: 'boolean',
dflt: false,
role: 'style',
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,
role: 'style',
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,
role: 'style',
description: [
'Sets the maximum size (in px) of the rendered marker points.',
'Effective when the `pointcloud` shows only few points.'
].join(' ')
},
border: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, marker.border is different enough from marker.line to deserve its own name 👍

color: {
valType: 'color',
arrayOk: false,
role: 'style',
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,
role: 'style',
description: [
'Specifies what fraction of the marker area is covered with the',
'border.'
].join(' ')
}
}
}
};
Loading