corrade-nucleus-nucleons – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | /** |
2 | * @license Highcharts JS v5.0.12 (2017-05-24) |
||
3 | * Plugin for displaying a message when there is no data visible in chart. |
||
4 | * |
||
5 | * (c) 2010-2017 Highsoft AS |
||
6 | * Author: Oystein Moseng |
||
7 | * |
||
8 | * License: www.highcharts.com/license |
||
9 | */ |
||
10 | 'use strict'; |
||
11 | (function(factory) { |
||
12 | if (typeof module === 'object' && module.exports) { |
||
13 | module.exports = factory; |
||
14 | } else { |
||
15 | factory(Highcharts); |
||
16 | } |
||
17 | }(function(Highcharts) { |
||
18 | (function(H) { |
||
19 | /** |
||
20 | * Plugin for displaying a message when there is no data visible in chart. |
||
21 | * |
||
22 | * (c) 2010-2017 Highsoft AS |
||
23 | * Author: Oystein Moseng |
||
24 | * |
||
25 | * License: www.highcharts.com/license |
||
26 | */ |
||
27 | |||
28 | var seriesTypes = H.seriesTypes, |
||
29 | chartPrototype = H.Chart.prototype, |
||
30 | defaultOptions = H.getOptions(), |
||
31 | extend = H.extend, |
||
32 | each = H.each; |
||
33 | |||
34 | // Add language option |
||
35 | extend(defaultOptions.lang, { |
||
36 | noData: 'No data to display' |
||
37 | }); |
||
38 | |||
39 | // Add default display options for message |
||
40 | defaultOptions.noData = { |
||
41 | position: { |
||
42 | x: 0, |
||
43 | y: 0, |
||
44 | align: 'center', |
||
45 | verticalAlign: 'middle' |
||
46 | } |
||
47 | // useHTML: false |
||
48 | }; |
||
49 | |||
50 | |||
51 | // Presentational |
||
52 | defaultOptions.noData.style = { |
||
53 | fontWeight: 'bold', |
||
54 | fontSize: '12px', |
||
55 | color: '#666666' |
||
56 | }; |
||
57 | |||
58 | |||
59 | |||
60 | // Define hasData function for non-cartesian seris. Returns true if the series |
||
61 | // has points at all. |
||
62 | each([ |
||
63 | 'bubble', |
||
64 | 'gauge', |
||
65 | 'heatmap', |
||
66 | 'pie', |
||
67 | 'treemap', |
||
68 | 'waterfall' |
||
69 | ], function(type) { |
||
70 | if (seriesTypes[type]) { |
||
71 | seriesTypes[type].prototype.hasData = function() { |
||
72 | return !!this.points.length; /* != 0 */ |
||
73 | }; |
||
74 | } |
||
75 | }); |
||
76 | |||
77 | /** |
||
78 | * Define hasData functions for series. These return true if there are data |
||
79 | * points on this series within the plot area. |
||
80 | */ |
||
81 | H.Series.prototype.hasData = function() { |
||
82 | return this.visible && this.dataMax !== undefined && this.dataMin !== undefined; // #3703 |
||
83 | }; |
||
84 | |||
85 | /** |
||
86 | * Display a no-data message. |
||
87 | * |
||
88 | * @param {String} str An optional message to show in place of the default one |
||
89 | */ |
||
90 | chartPrototype.showNoData = function(str) { |
||
91 | var chart = this, |
||
92 | options = chart.options, |
||
93 | text = str || options.lang.noData, |
||
94 | noDataOptions = options.noData; |
||
95 | |||
96 | if (!chart.noDataLabel) { |
||
97 | chart.noDataLabel = chart.renderer |
||
98 | .label( |
||
99 | text, |
||
100 | 0, |
||
101 | 0, |
||
102 | null, |
||
103 | null, |
||
104 | null, |
||
105 | noDataOptions.useHTML, |
||
106 | null, |
||
107 | 'no-data' |
||
108 | ); |
||
109 | |||
110 | |||
111 | chart.noDataLabel |
||
112 | .attr(noDataOptions.attr) |
||
113 | .css(noDataOptions.style); |
||
114 | |||
115 | |||
116 | chart.noDataLabel.add(); |
||
117 | |||
118 | chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox'); |
||
119 | } |
||
120 | }; |
||
121 | |||
122 | /** |
||
123 | * Hide no-data message |
||
124 | */ |
||
125 | chartPrototype.hideNoData = function() { |
||
126 | var chart = this; |
||
127 | if (chart.noDataLabel) { |
||
128 | chart.noDataLabel = chart.noDataLabel.destroy(); |
||
129 | } |
||
130 | }; |
||
131 | |||
132 | /** |
||
133 | * Returns true if there are data points within the plot area now |
||
134 | */ |
||
135 | chartPrototype.hasData = function() { |
||
136 | var chart = this, |
||
137 | series = chart.series, |
||
138 | i = series.length; |
||
139 | |||
140 | while (i--) { |
||
141 | if (series[i].hasData() && !series[i].options.isInternal) { |
||
142 | return true; |
||
143 | } |
||
144 | } |
||
145 | |||
146 | return chart.loadingShown; // #4588 |
||
147 | }; |
||
148 | |||
149 | /** |
||
150 | * Show no-data message if there is no data in sight. Otherwise, hide it. |
||
151 | */ |
||
152 | function handleNoData() { |
||
153 | var chart = this; |
||
154 | if (chart.hasData()) { |
||
155 | chart.hideNoData(); |
||
156 | } else { |
||
157 | chart.showNoData(); |
||
158 | } |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * Add event listener to handle automatic display of no-data message |
||
163 | */ |
||
164 | chartPrototype.callbacks.push(function(chart) { |
||
165 | H.addEvent(chart, 'load', handleNoData); |
||
166 | H.addEvent(chart, 'redraw', handleNoData); |
||
167 | }); |
||
168 | |||
169 | }(Highcharts)); |
||
170 | })); |