Skip to content

Commit 06af109

Browse files
authored
Merge pull request #850 from monfera/pointcloud-squashed
Adding pointcloud
2 parents a0bfe09 + 8105955 commit 06af109

14 files changed

+752
-15
lines changed

lib/index-gl2d.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var Plotly = require('./core');
1212

1313
Plotly.register([
1414
require('./scattergl'),
15+
require('./pointcloud'),
1516
require('./heatmapgl'),
1617
require('./contourgl')
1718
]);

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Plotly.register([
2525
require('./scattergeo'),
2626
require('./choropleth'),
2727
require('./scattergl'),
28+
require('./pointcloud'),
2829
require('./scatterternary'),
2930
require('./scattermapbox')
3031
]);

lib/pointcloud.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Copyright 2012-2016, 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+
module.exports = require('../src/traces/pointcloud');

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"gl-plot3d": "^1.5.0",
6969
"gl-scatter2d": "^1.0.5",
7070
"gl-scatter2d-fancy": "^1.1.1",
71+
"gl-pointcloud2d": "^1.0.0",
7172
"gl-scatter3d": "^1.0.4",
7273
"gl-select-box": "^1.0.1",
7374
"gl-spikes2d": "^1.0.1",

src/.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"Promise": true,
88
"Float32Array": true,
99
"Uint8Array": true,
10+
"Int32Array": true,
1011
"ArrayBuffer": true
1112
},
1213
"rules": {

src/lib/float32_truncate.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2012-2016, 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+
/**
12+
* Truncate a Float32Array to some length. A wrapper to support environments
13+
* (e.g. node-webkit) that do not implement Float32Array.prototype.slice
14+
*/
15+
module.exports = function truncate(float32ArrayIn, len) {
16+
// for some reason, ES2015 Float32Array.prototype.slice takes 2x as long...
17+
// therefore we aren't checking for its existence
18+
var float32ArrayOut = new Float32Array(len);
19+
for(var i = 0; i < len; i++) float32ArrayOut[i] = float32ArrayIn[i];
20+
return float32ArrayOut;
21+
};

src/traces/pointcloud/attributes.js

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

0 commit comments

Comments
 (0)