2
* @license Highstock JS v1.3.10 (2014-03-10)
3
* Plugin for displaying a message when there is no data visible in chart.
5
* (c) 2010-2014 Highsoft AS
6
* Author: Oystein Moseng
8
* License: www.highcharts.com/license
11
(function (H) { // docs
13
var seriesTypes = H.seriesTypes,
14
chartPrototype = H.Chart.prototype,
15
defaultOptions = H.getOptions(),
18
// Add language option
19
extend(defaultOptions.lang, {
20
noData: 'No data to display'
23
// Add default display options for message
24
defaultOptions.noData = {
29
verticalAlign: 'middle'
41
* Define hasData functions for series. These return true if there are data points on this series within the plot area
43
function hasDataPie() {
44
return !!this.points.length; /* != 0 */
47
if (seriesTypes.pie) {
48
seriesTypes.pie.prototype.hasData = hasDataPie;
51
if (seriesTypes.gauge) {
52
seriesTypes.gauge.prototype.hasData = hasDataPie;
55
if (seriesTypes.waterfall) {
56
seriesTypes.waterfall.prototype.hasData = hasDataPie;
59
H.Series.prototype.hasData = function () {
60
return this.dataMax !== undefined && this.dataMin !== undefined;
64
* Display a no-data message.
66
* @param {String} str An optional message to show in place of the default one
68
chartPrototype.showNoData = function (str) {
70
options = chart.options,
71
text = str || options.lang.noData,
72
noDataOptions = options.noData;
74
if (!chart.noDataLabel) {
75
chart.noDataLabel = chart.renderer.label(text, 0, 0, null, null, null, null, null, 'no-data')
76
.attr(noDataOptions.attr)
77
.css(noDataOptions.style)
79
chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox');
84
* Hide no-data message
86
chartPrototype.hideNoData = function () {
88
if (chart.noDataLabel) {
89
chart.noDataLabel = chart.noDataLabel.destroy();
94
* Returns true if there are data points within the plot area now
96
chartPrototype.hasData = function () {
98
series = chart.series,
102
if (series[i].hasData() && !series[i].options.isInternal) {
111
* Show no-data message if there is no data in sight. Otherwise, hide it.
113
function handleNoData() {
115
if (chart.hasData()) {
123
* Add event listener to handle automatic display of no-data message
125
chartPrototype.callbacks.push(function (chart) {
126
H.addEvent(chart, 'load', handleNoData);
127
H.addEvent(chart, 'redraw', handleNoData);