Skip to content

Commit 8128622

Browse files
committed
Merge pull request #569 from plotly/float32array-init
Init Float32Array with explicit length of 0
2 parents 3b5178c + 913c9e8 commit 8128622

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/traces/contourgl/convert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Contour(scene, uid) {
3232
this.bounds = [0, 0, 0, 0];
3333

3434
this.contourOptions = {
35-
z: new Float32Array(),
35+
z: new Float32Array(0),
3636
x: [],
3737
y: [],
3838
shape: [0, 0],
@@ -44,7 +44,7 @@ function Contour(scene, uid) {
4444
this.contour._trace = this;
4545

4646
this.heatmapOptions = {
47-
z: new Float32Array(),
47+
z: new Float32Array(0),
4848
x: [],
4949
y: [],
5050
shape: [0, 0],

src/traces/scattergl/convert.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function LineWithMarkers(scene, uid) {
4848

4949
this.hasLines = false;
5050
this.lineOptions = {
51-
positions: new Float32Array(),
51+
positions: new Float32Array(0),
5252
color: [0, 0, 0, 1],
5353
width: 1,
5454
fill: [false, false, false, false],
@@ -64,8 +64,8 @@ function LineWithMarkers(scene, uid) {
6464

6565
this.hasErrorX = false;
6666
this.errorXOptions = {
67-
positions: new Float32Array(),
68-
errors: new Float32Array(),
67+
positions: new Float32Array(0),
68+
errors: new Float32Array(0),
6969
lineWidth: 1,
7070
capSize: 0,
7171
color: [0, 0, 0, 1]
@@ -75,8 +75,8 @@ function LineWithMarkers(scene, uid) {
7575

7676
this.hasErrorY = false;
7777
this.errorYOptions = {
78-
positions: new Float32Array(),
79-
errors: new Float32Array(),
78+
positions: new Float32Array(0),
79+
errors: new Float32Array(0),
8080
lineWidth: 1,
8181
capSize: 0,
8282
color: [0, 0, 0, 1]
@@ -86,7 +86,7 @@ function LineWithMarkers(scene, uid) {
8686

8787
this.hasMarkers = false;
8888
this.scatterOptions = {
89-
positions: new Float32Array(),
89+
positions: new Float32Array(0),
9090
sizes: [],
9191
colors: [],
9292
glyphs: [],
@@ -330,13 +330,13 @@ proto.updateFast = function(options) {
330330
this.scatter.update(this.scatterOptions);
331331
}
332332
else {
333-
this.scatterOptions.positions = new Float32Array();
333+
this.scatterOptions.positions = new Float32Array(0);
334334
this.scatterOptions.glyphs = [];
335335
this.scatter.update(this.scatterOptions);
336336
}
337337

338338
// turn off fancy scatter plot
339-
this.scatterOptions.positions = new Float32Array();
339+
this.scatterOptions.positions = new Float32Array(0);
340340
this.scatterOptions.glyphs = [];
341341
this.fancyScatter.update(this.scatterOptions);
342342

@@ -455,13 +455,13 @@ proto.updateFancy = function(options) {
455455
this.fancyScatter.update(this.scatterOptions);
456456
}
457457
else {
458-
this.scatterOptions.positions = new Float32Array();
458+
this.scatterOptions.positions = new Float32Array(0);
459459
this.scatterOptions.glyphs = [];
460460
this.fancyScatter.update(this.scatterOptions);
461461
}
462462

463463
// turn off fast scatter plot
464-
this.scatterOptions.positions = new Float32Array();
464+
this.scatterOptions.positions = new Float32Array(0);
465465
this.scatterOptions.glyphs = [];
466466
this.scatter.update(this.scatterOptions);
467467

@@ -514,7 +514,7 @@ proto.updateLines = function(options, positions) {
514514
this.lineOptions.fillColor = [fillColor, fillColor, fillColor, fillColor];
515515
}
516516
else {
517-
this.lineOptions.positions = new Float32Array();
517+
this.lineOptions.positions = new Float32Array(0);
518518
}
519519

520520
this.line.update(this.lineOptions);
@@ -537,7 +537,7 @@ proto.updateError = function(axLetter, options, positions, errors) {
537537
errorObjOptions.color = convertColor(errorOptions.color, 1, 1);
538538
}
539539
else {
540-
errorObjOptions.positions = new Float32Array();
540+
errorObjOptions.positions = new Float32Array(0);
541541
}
542542

543543
errorObj.update(errorObjOptions);

0 commit comments

Comments
 (0)