Skip to content

Commit

Permalink
Merge pull request wp-cloud#5 from wp-cloud/js-fix
Browse files Browse the repository at this point in the history
fix Uncaught TypeError: Cannot read property 'filter' of undefined
  • Loading branch information
cfoellmann authored Oct 11, 2016
2 parents b670621 + 523fb3f commit 0586248
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions opcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,22 +620,23 @@ function set_text(t) {
}

function change() {
// Filter out any zero values to see if there is anything left
var remove_zero_values = dataset[this.value].filter(function(value) {
return value > 0;
});

// Skip if the value is undefined for some reason
if (typeof dataset[this.value] !== 'undefined' && remove_zero_values.length > 0) {
$('#graph').find('> svg').show();
path = path.data(pie(dataset[this.value])); // update the data
path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs
// Hide the graph if we can't draw it correctly, not ideal but this works
} else {
$('#graph').find('> svg').hide();
}
if (typeof dataset[this.value] !== 'undefined') {
// Filter out any zero values to see if there is anything left
var remove_zero_values = dataset[this.value].filter(function(value) {
return value > 0;
});
if (remove_zero_values.length > 0) {
$('#graph').find('> svg').show();
path = path.data(pie(dataset[this.value])); // update the data
path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs
// Hide the graph if we can't draw it correctly, not ideal but this works
} else {
$('#graph').find('> svg').hide();
}

set_text(this.value);
set_text(this.value);
}
}

function arcTween(a) {
Expand Down

0 comments on commit 0586248

Please sign in to comment.