Skip to content

Commit 0586248

Browse files
authored
Merge pull request #5 from wp-cloud/js-fix
fix Uncaught TypeError: Cannot read property 'filter' of undefined
2 parents b670621 + 523fb3f commit 0586248

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

opcache.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -620,22 +620,23 @@ function set_text(t) {
620620
}
621621

622622
function change() {
623-
// Filter out any zero values to see if there is anything left
624-
var remove_zero_values = dataset[this.value].filter(function(value) {
625-
return value > 0;
626-
});
627-
628623
// Skip if the value is undefined for some reason
629-
if (typeof dataset[this.value] !== 'undefined' && remove_zero_values.length > 0) {
630-
$('#graph').find('> svg').show();
631-
path = path.data(pie(dataset[this.value])); // update the data
632-
path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs
633-
// Hide the graph if we can't draw it correctly, not ideal but this works
634-
} else {
635-
$('#graph').find('> svg').hide();
636-
}
624+
if (typeof dataset[this.value] !== 'undefined') {
625+
// Filter out any zero values to see if there is anything left
626+
var remove_zero_values = dataset[this.value].filter(function(value) {
627+
return value > 0;
628+
});
629+
if (remove_zero_values.length > 0) {
630+
$('#graph').find('> svg').show();
631+
path = path.data(pie(dataset[this.value])); // update the data
632+
path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs
633+
// Hide the graph if we can't draw it correctly, not ideal but this works
634+
} else {
635+
$('#graph').find('> svg').hide();
636+
}
637637

638-
set_text(this.value);
638+
set_text(this.value);
639+
}
639640
}
640641

641642
function arcTween(a) {

0 commit comments

Comments
 (0)