pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/plotly/plotly.js/commit/0f99934a2ebddabe4cbca237ccd5c3a43e4ce195

a60c69660fa.css" /> protect against non-numerics in change function · plotly/plotly.js@0f99934 · GitHub
Skip to content

Commit 0f99934

Browse files
committed
protect against non-numerics in change function
1 parent c172bf7 commit 0f99934

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

src/transforms/aggregate.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ function getAggregateFunction(opts, conversions) {
299299
return first;
300300
case 'last':
301301
return last;
302-
case 'change':
303-
return change;
304302

305303
case 'sum':
306304
// This will produce output in all cases even though it's nonsensical
@@ -350,17 +348,24 @@ function getAggregateFunction(opts, conversions) {
350348
};
351349

352350
case 'range':
353-
return function(array, indices) {
354-
var min = Infinity;
355-
var max = -Infinity;
356-
for(var i = 0; i < indices.length; i++) {
357-
var vi = d2c(array[indices[i]]);
358-
if(vi !== BADNUM) {
359-
min = Math.min(min, vi);
360-
max = Math.max(max, vi);
361-
};
351+
return function(array, indices) {
352+
var min = Infinity;
353+
var max = -Infinity;
354+
for(var i = 0; i < indices.length; i++) {
355+
var vi = d2c(array[indices[i]]);
356+
if(vi !== BADNUM) {
357+
min = Math.min(min, vi);
358+
max = Math.max(max, vi);
362359
}
363-
return (max === -Infinity || min === Infinity) ? BADNUM : c2d(max - min);
360+
}
361+
return (max === -Infinity || min === Infinity) ? BADNUM : c2d(max - min);
362+
};
363+
364+
case 'change':
365+
return function(array, indices) {
366+
var first = d2c(array[indices[0]]);
367+
var last = d2c(array[indices[indices.length - 1]]);
368+
return (first === BADNUM || last === BADNUM) ? BADNUM : c2d(last - first);
364369
};
365370

366371
case 'median':
@@ -459,7 +464,3 @@ function first(array, indices) {
459464
function last(array, indices) {
460465
return array[indices[indices.length - 1]];
461466
}
462-
463-
function change(array, indices) {
464-
return last(array, indices) - first(array, indices);
465-
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy