@@ -196,6 +196,20 @@ function _convertColor(colors, opacities, count) {
196
196
return result ;
197
197
}
198
198
199
+ /**
200
+ * Truncate a Float32Array to some length. A wrapper to support environments
201
+ * (e.g. node-webkit) that do not implement Float32Array.prototype.slice
202
+ */
203
+ function truncate ( float32ArrayIn , len ) {
204
+ if ( Float32Array . slice === undefined ) {
205
+ var float32ArrayOut = new Float32Array ( len ) ;
206
+ for ( var i = 0 ; i < len ; i ++ ) float32ArrayOut [ i ] = float32ArrayIn [ i ] ;
207
+ return float32ArrayOut ;
208
+ }
209
+
210
+ return float32ArrayIn . slice ( 0 , len ) ;
211
+ }
212
+
199
213
/* Order is important here to get the correct laying:
200
214
* - lines
201
215
* - errorX
@@ -266,7 +280,7 @@ proto.updateFast = function(options) {
266
280
bounds [ 3 ] = Math . max ( bounds [ 3 ] , yy ) ;
267
281
}
268
282
269
- positions = positions . slice ( 0 , ptr ) ;
283
+ positions = truncate ( positions , ptr ) ;
270
284
this . idToIndex = idToIndex ;
271
285
272
286
this . updateLines ( options , positions ) ;
@@ -368,7 +382,7 @@ proto.updateFancy = function(options) {
368
382
bounds [ 3 ] = Math . max ( bounds [ 3 ] , yy + ey1 ) ;
369
383
}
370
384
371
- positions = positions . slice ( 0 , ptr ) ;
385
+ positions = truncate ( positions , ptr ) ;
372
386
this . idToIndex = idToIndex ;
373
387
374
388
this . updateLines ( options , positions ) ;
0 commit comments