The whole concept of specifying a pie.values() function is

not consistent with other charts.  For all pie charts,
the developer needs to make sure to just pass in an array of key-value
pairs.  Nothing more.  The example of nvd3.org is not the proper way of
passing data into pie charts.

Removing pie.values() functionality and putting console error message.
Updated examples. For issue #98, #162, #106
master
Robin Hu 11 years ago
parent e891716b11
commit 2cf5b63c91

@ -71,8 +71,6 @@ nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
//.showLabels(false)
.values(function(d) { return d })
.color(d3.scale.category10().range())
.width(width)
.height(height);
@ -97,7 +95,6 @@ nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
//.y(function(d) { return d.value })
.values(function(d) { return d })
//.labelThreshold(.08)
//.showLabels(false)
.color(d3.scale.category10().range())

@ -7,7 +7,6 @@ nv.models.pie = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0}
, width = 500
, height = 500
, getValues = function(d) { return d.values }
, getX = function(d) { return d.x }
, getY = function(d) { return d.y }
, getDescription = function(d) { return d.description }
@ -42,7 +41,7 @@ nv.models.pie = function() {
// Setup containers and skeleton of chart
//var wrap = container.selectAll('.nv-wrap.nv-pie').data([data]);
var wrap = container.selectAll('.nv-wrap.nv-pie').data([getValues(data[0])]);
var wrap = container.selectAll('.nv-wrap.nv-pie').data(data);
var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id);
var gEnter = wrapEnter.append('g');
var g = wrap.select('g');
@ -285,8 +284,7 @@ nv.models.pie = function() {
};
chart.values = function(_) {
if (!arguments.length) return getValues;
getValues = _;
nv.log("pie.values() is no longer supported.");
return chart;
};

@ -117,7 +117,7 @@ nv.models.pieChart = function() {
.key(pie.x());
wrap.select('.nv-legendWrap')
.datum(pie.values()(data))
.datum(data)
.call(legend);
if ( margin.top != legend.height()) {
@ -159,8 +159,8 @@ nv.models.pieChart = function() {
legend.dispatch.on('legendClick', function(d) {
d.disabled = !d.disabled;
if (!pie.values()(data).filter(function(d) { return !d.disabled }).length) {
pie.values()(data).map(function(d) {
if (!data.filter(function(d) { return !d.disabled }).length) {
data.map(function(d) {
d.disabled = false;
wrap.selectAll('.nv-series').classed('disabled', false);
return d;
@ -175,13 +175,12 @@ nv.models.pieChart = function() {
legend.dispatch.on('legendDblclick', function(d) {
//Double clicking should always enable current series, and disabled all others.
var pieData = pie.values()(data);
pieData.forEach(function(d) {
data.forEach(function(d) {
d.disabled = true;
});
d.disabled = false;
state.disabled = pieData.map(function(d) { return !!d.disabled });
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart.update();
});

@ -104,7 +104,6 @@ function defaultChart(containerId, data) {
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
.values(function(d) { return d })
.color(d3.scale.category10().range())
.width(width)
.height(height);
@ -129,7 +128,6 @@ nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
.values(function(d) { return d })
.color(d3.scale.category10().range())
.width(width)
.height(height)

Loading…
Cancel
Save