Added a customizeable No Data Available. message to all the charts when they are fed no series, or all series have no points

master-patched
Bob Monteverde 12 years ago
parent b5b36cbeb1
commit bded864229

@ -1035,10 +1035,12 @@ nv.models.bulletChart = function() {
height = 55,
tickFormat = null,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>'
};
},
noData = "No Data Available."
;
var dispatch = d3.dispatch('tooltipShow', 'tooltipHide'),
@ -1067,6 +1069,27 @@ nv.models.bulletChart = function() {
availableHeight = height - margin.top - margin.bottom,
that = this;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var rangez = ranges.call(this, d, i).slice().sort(d3.descending),
markerz = markers.call(this, d, i).slice().sort(d3.descending),
measurez = measures.call(this, d, i).slice().sort(d3.descending);
@ -1297,6 +1320,12 @@ nv.models.bulletChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
};
@ -1321,7 +1350,9 @@ nv.models.cumulativeLineChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
},
x, y; //can be accessed via chart.lines.[x/y]Scale()
x, y, //can be accessed via chart.lines.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -1387,6 +1418,26 @@ nv.models.cumulativeLineChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = lines.xScale();
y = lines.yScale();
@ -1626,6 +1677,11 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
@ -1960,7 +2016,9 @@ nv.models.discreteBarChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + x + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var discretebar = nv.models.discreteBar(),
@ -2002,6 +2060,25 @@ nv.models.discreteBarChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
discretebar
.width(availableWidth)
.height(availableHeight);
@ -2155,6 +2232,12 @@ nv.models.discreteBarChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -3024,7 +3107,10 @@ nv.models.lineChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
},
x, y; //can be accessed via chart.lines.[x/y]Scale()
x,//can be accessed via chart.lines.[x/y]Scale()
y,
noData = "No Data Available."
;
//============================================================
@ -3071,6 +3157,26 @@ nv.models.lineChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = lines.xScale();
y = lines.yScale();
@ -3265,6 +3371,13 @@ nv.models.lineChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -3280,7 +3393,9 @@ nv.models.linePlusBarChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var lines = nv.models.line(),
@ -3317,6 +3432,27 @@ nv.models.linePlusBarChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var dataBars = data.filter(function(d) { return !d.disabled && d.bar });
var dataLines = data.filter(function(d) { return !d.disabled && !d.bar });
@ -3578,7 +3714,14 @@ nv.models.linePlusBarChart = function() {
tooltip = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -3595,7 +3738,9 @@ nv.models.lineWithFocusChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var lines = nv.models.line().clipEdge(true),
lines2 = nv.models.line().interactive(false),
@ -3635,6 +3780,26 @@ nv.models.lineWithFocusChart = function() {
availableHeight2 = height2 - margin2.top - margin2.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
brush.on('brush', onBrush);
@ -4012,6 +4177,13 @@ nv.models.lineWithFocusChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -4388,7 +4560,9 @@ nv.models.multiBarChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' on ' + x + '</p>'
},
x, y; //can be accessed via chart.multibar.[x/y]Scale()
x, y, //can be accessed via chart.multibar.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -4426,6 +4600,27 @@ nv.models.multiBarChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = multibar.xScale();
y = multibar.yScale();
@ -4677,6 +4872,12 @@ nv.models.multiBarChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -5066,7 +5267,9 @@ nv.models.multiBarHorizontalChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + " - " + x + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var multibar = nv.models.multiBarHorizontal().stacked(false),
@ -5108,6 +5311,24 @@ nv.models.multiBarHorizontalChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]);
@ -5324,6 +5545,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -6364,7 +6591,9 @@ nv.models.pieChart = function() {
tooltip = function(key, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var pie = nv.models.pie(),
@ -6394,6 +6623,25 @@ nv.models.pieChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g');
@ -6529,6 +6777,12 @@ nv.models.pieChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}
@ -7029,6 +7283,7 @@ nv.models.scatterChart = function() {
, distX = nv.models.distribution().axis('x')
, distY = nv.models.distribution().axis('y')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, noData = "No Data Available."
;
//============================================================
@ -7078,6 +7333,19 @@ nv.models.scatterChart = function() {
- margin.top - margin.bottom;
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
// Setup Scales
@ -7430,6 +7698,12 @@ nv.models.scatterChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
//============================================================
@ -8052,7 +8326,9 @@ nv.models.stackedAreaChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' on ' + x + '</p>'
},
x, y; //can be accessed via chart.stacked.[x/y]Scale()
x, y, //can be accessed via chart.stacked.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -8094,6 +8370,27 @@ nv.models.stackedAreaChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = stacked.xScale();
y = stacked.yScale();
@ -8330,6 +8627,12 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

8
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -13,10 +13,12 @@ nv.models.bulletChart = function() {
height = 55,
tickFormat = null,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>'
};
},
noData = "No Data Available."
;
var dispatch = d3.dispatch('tooltipShow', 'tooltipHide'),
@ -45,6 +47,27 @@ nv.models.bulletChart = function() {
availableHeight = height - margin.top - margin.bottom,
that = this;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var rangez = ranges.call(this, d, i).slice().sort(d3.descending),
markerz = markers.call(this, d, i).slice().sort(d3.descending),
measurez = measures.call(this, d, i).slice().sort(d3.descending);
@ -275,6 +298,12 @@ nv.models.bulletChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
};

@ -17,7 +17,9 @@ nv.models.cumulativeLineChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
},
x, y; //can be accessed via chart.lines.[x/y]Scale()
x, y, //can be accessed via chart.lines.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -83,6 +85,26 @@ nv.models.cumulativeLineChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = lines.xScale();
y = lines.yScale();
@ -322,6 +344,11 @@ nv.models.cumulativeLineChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};

@ -10,7 +10,9 @@ nv.models.discreteBarChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + x + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var discretebar = nv.models.discreteBar(),
@ -52,6 +54,25 @@ nv.models.discreteBarChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
discretebar
.width(availableWidth)
.height(availableHeight);
@ -205,6 +226,12 @@ nv.models.discreteBarChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -15,7 +15,10 @@ nv.models.lineChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
},
x, y; //can be accessed via chart.lines.[x/y]Scale()
x,//can be accessed via chart.lines.[x/y]Scale()
y,
noData = "No Data Available."
;
//============================================================
@ -62,6 +65,26 @@ nv.models.lineChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = lines.xScale();
y = lines.yScale();
@ -256,5 +279,12 @@ nv.models.lineChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -11,7 +11,9 @@ nv.models.linePlusBarChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var lines = nv.models.line(),
@ -48,6 +50,27 @@ nv.models.linePlusBarChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var dataBars = data.filter(function(d) { return !d.disabled && d.bar });
var dataLines = data.filter(function(d) { return !d.disabled && !d.bar });
@ -309,6 +332,13 @@ nv.models.linePlusBarChart = function() {
tooltip = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -12,7 +12,9 @@ nv.models.lineChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var x = d3.fisheye.scale(d3.scale.linear).distortion(0);
@ -54,6 +56,25 @@ nv.models.lineChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');
@ -291,6 +312,13 @@ nv.models.lineChart = function() {
tooltip = _;
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -12,7 +12,9 @@ nv.models.lineWithFocusChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var lines = nv.models.line().clipEdge(true),
lines2 = nv.models.line().interactive(false),
@ -52,6 +54,26 @@ nv.models.lineWithFocusChart = function() {
availableHeight2 = height2 - margin2.top - margin2.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
brush.on('brush', onBrush);
@ -429,5 +451,12 @@ nv.models.lineWithFocusChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -18,7 +18,9 @@ nv.models.multiBarChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' on ' + x + '</p>'
},
x, y; //can be accessed via chart.multibar.[x/y]Scale()
x, y, //can be accessed via chart.multibar.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -56,6 +58,27 @@ nv.models.multiBarChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = multibar.xScale();
y = multibar.yScale();
@ -307,6 +330,12 @@ nv.models.multiBarChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -10,7 +10,9 @@ nv.models.multiBarHorizontalChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + " - " + x + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var multibar = nv.models.multiBarHorizontal().stacked(false),
@ -52,6 +54,24 @@ nv.models.multiBarHorizontalChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]);
@ -268,6 +288,12 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -9,7 +9,9 @@ nv.models.pieChart = function() {
tooltip = function(key, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
};
},
noData = "No Data Available."
;
var pie = nv.models.pie(),
@ -39,6 +41,25 @@ nv.models.pieChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g');
@ -174,6 +195,12 @@ nv.models.pieChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -32,6 +32,7 @@ nv.models.scatterChart = function() {
, distX = nv.models.distribution().axis('x')
, distY = nv.models.distribution().axis('y')
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
, noData = "No Data Available."
;
//============================================================
@ -81,6 +82,19 @@ nv.models.scatterChart = function() {
- margin.top - margin.bottom;
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
// Setup Scales
@ -433,6 +447,12 @@ nv.models.scatterChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
//============================================================

@ -15,7 +15,9 @@ nv.models.scatterFisheyeChart = function() {
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
};
},
noData = "No Data Available."
;
var x = d3.fisheye.scale(d3.scale.linear).distortion(0),
y = d3.fisheye.scale(d3.scale.linear).distortion(0);
@ -69,6 +71,25 @@ nv.models.scatterFisheyeChart = function() {
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x0 = x0 || scatter.xScale();
y0 = y0 || scatter.yScale();
@ -386,6 +407,12 @@ nv.models.scatterFisheyeChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -17,7 +17,9 @@ nv.models.stackedAreaChart = function() {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' on ' + x + '</p>'
},
x, y; //can be accessed via chart.stacked.[x/y]Scale()
x, y, //can be accessed via chart.stacked.[x/y]Scale()
noData = "No Data Available."
;
//============================================================
@ -59,6 +61,27 @@ nv.models.stackedAreaChart = function() {
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
//------------------------------------------------------------
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
container.append('text')
.attr('class', 'nvd3 nv-noData')
.attr('x', availableWidth / 2)
.attr('y', availableHeight / 2)
.attr('dy', '-.7em')
.style('text-anchor', 'middle')
.text(noData);
return chart;
} else {
container.select('.nv-noData').remove();
}
//------------------------------------------------------------
x = stacked.xScale();
y = stacked.yScale();
@ -295,6 +318,12 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.noData = function(_) {
if (!arguments.length) return noData;
noData = _;
return chart;
};
return chart;
}

@ -102,6 +102,11 @@ svg .title {
*/
}
.nvd3.nv-noData {
font-size: 18px;
font-weight: bolf;
}
/**********
* Brush

Loading…
Cancel
Save