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