diff --git a/src/models/pie.js b/src/models/pie.js index ac58c00..475a78f 100644 --- a/src/models/pie.js +++ b/src/models/pie.js @@ -339,6 +339,7 @@ nv.models.pie = function() { chart.labelType = function(_) { if (!arguments.length) return labelType; labelType = _; + labelType = labelType || "key"; return chart; }; diff --git a/test/pieChartTest.html b/test/pieChartTest.html index cd70359..42ddd39 100644 --- a/test/pieChartTest.html +++ b/test/pieChartTest.html @@ -38,6 +38,11 @@ text { +
+

Pie chart with percent label type

+ +
+

Empty array passed in

@@ -103,7 +108,7 @@ function thirtySeries() { return data; } -function defaultChart(containerId, data) { +function defaultChart(containerId, data, labelType) { nv.addGraph(function() { var width = 500, height = 500; @@ -113,7 +118,9 @@ function defaultChart(containerId, data) { .y(function(d) { return d.y }) .color(d3.scale.category10().range()) .width(width) - .height(height); + .height(height) + .labelType(labelType) + ; d3.select("#" + containerId + " svg") .datum(data) @@ -164,4 +171,6 @@ defaultChart("test6", [ {key: "null", y: null}, {key: "zero", y: 0} ]) + +defaultChart("test7",testdata, "percent");