Skip to content

Commit

Permalink
Merge pull request #47 from benpickles/zero-sum-pies
Browse files Browse the repository at this point in the history
Don’t blow up if a pie/donut’s sum is less than zero.
  • Loading branch information
benpickles committed Oct 22, 2014
2 parents 5fe8a9e + 9bdc79c commit d99db2c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jquery.peity.js
Expand Up @@ -124,6 +124,12 @@
sum += values[i]
}

if (!sum) {
length = 2
sum = 1
values = [0, 1]
}

var diameter = opts.radius * 2
, width = opts.width || diameter
, height = opts.height || diameter
Expand Down
12 changes: 12 additions & 0 deletions test/charts.json
Expand Up @@ -175,6 +175,12 @@
"width": 16,
"height": 16
},
"donut12": {
"type": "donut",
"text": "0,0,0,0,0",
"width": 16,
"height": 16
},
"line1": {
"type": "line",
"text": "5,3,9,6,5,9,7,3,5,2",
Expand Down Expand Up @@ -328,5 +334,11 @@
"text": "-2/3",
"width": 16,
"height": 16
},
"pie11": {
"type": "pie",
"text": "0,0,0,0,0",
"width": 16,
"height": 16
}
}
Binary file added test/fixtures/donut12.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/fixtures/pie11.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d99db2c

Please sign in to comment.