Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/traces/pie/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function calc(gd, trace) {
v = vals[i];
if(!isNumeric(v)) continue;
v = +v;
if(v < 0) continue;
} else v = 1;

label = labels[i];
Expand Down Expand Up @@ -76,6 +75,9 @@ function calc(gd, trace) {
}
}

// Drop aggregate sums of value 0 or less
cd = cd.filter(function(elem) { return elem.v > 0; });

var shouldSort = (trace.type === 'funnelarea') ? isAggregated : trace.sort;
if(shouldSort) cd.sort(function(a, b) { return b.v - a.v; });

Expand Down
42 changes: 42 additions & 0 deletions test/image/mocks/pie_negative_values.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"data": [
{
"labels": [
"Apples",
"Apples",
"Bananas",
"Oranges",
"Pears",
"Pears",
"Apples",
"Pears"
],
"type": "pie",
"domain": {"x": [0, 0.4]}
},
{
"labels": [
"Apples",
"Apples",
"Bananas",
"Oranges",
"Pears",
"Pears",
"Apples",
"Pears"
],
"values": [
10, -20, 20, 40, 10, -20, 70, 5
],
"marker": {"colors": ["", "", "#ccc"]},
"type": "pie",
"domain": {"x": [0.5, 1]},
"textinfo": "label+value+percent"
}
],
"layout": {
"height": 300,
"width": 500
}
}