corrade-nucleus-nucleons – Blame information for rev 11
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /** |
11 | office | 2 | * @license Highcharts JS v5.0.12 (2017-05-24) |
1 | office | 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 | |||
52 | |||
11 | office | 53 | // Define hasData function for non-cartesian seris. Returns true if the series |
54 | // has points at all. |
||
55 | each([ |
||
56 | 'bubble', |
||
57 | 'gauge', |
||
58 | 'heatmap', |
||
59 | 'pie', |
||
60 | 'treemap', |
||
61 | 'waterfall' |
||
62 | ], function(type) { |
||
1 | office | 63 | if (seriesTypes[type]) { |
11 | office | 64 | seriesTypes[type].prototype.hasData = function() { |
65 | return !!this.points.length; /* != 0 */ |
||
66 | }; |
||
1 | office | 67 | } |
68 | }); |
||
69 | |||
11 | office | 70 | /** |
71 | * Define hasData functions for series. These return true if there are data |
||
72 | * points on this series within the plot area. |
||
73 | */ |
||
1 | office | 74 | H.Series.prototype.hasData = function() { |
75 | return this.visible && this.dataMax !== undefined && this.dataMin !== undefined; // #3703 |
||
76 | }; |
||
77 | |||
78 | /** |
||
79 | * Display a no-data message. |
||
80 | * |
||
81 | * @param {String} str An optional message to show in place of the default one |
||
82 | */ |
||
83 | chartPrototype.showNoData = function(str) { |
||
84 | var chart = this, |
||
85 | options = chart.options, |
||
86 | text = str || options.lang.noData, |
||
87 | noDataOptions = options.noData; |
||
88 | |||
89 | if (!chart.noDataLabel) { |
||
90 | chart.noDataLabel = chart.renderer |
||
91 | .label( |
||
92 | text, |
||
93 | 0, |
||
94 | 0, |
||
95 | null, |
||
96 | null, |
||
97 | null, |
||
98 | noDataOptions.useHTML, |
||
99 | null, |
||
100 | 'no-data' |
||
101 | ); |
||
102 | |||
103 | |||
104 | |||
105 | chart.noDataLabel.add(); |
||
106 | |||
107 | chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox'); |
||
108 | } |
||
109 | }; |
||
110 | |||
111 | /** |
||
112 | * Hide no-data message |
||
113 | */ |
||
114 | chartPrototype.hideNoData = function() { |
||
115 | var chart = this; |
||
116 | if (chart.noDataLabel) { |
||
117 | chart.noDataLabel = chart.noDataLabel.destroy(); |
||
118 | } |
||
119 | }; |
||
120 | |||
121 | /** |
||
122 | * Returns true if there are data points within the plot area now |
||
123 | */ |
||
124 | chartPrototype.hasData = function() { |
||
125 | var chart = this, |
||
126 | series = chart.series, |
||
127 | i = series.length; |
||
128 | |||
129 | while (i--) { |
||
130 | if (series[i].hasData() && !series[i].options.isInternal) { |
||
131 | return true; |
||
132 | } |
||
133 | } |
||
134 | |||
11 | office | 135 | return chart.loadingShown; // #4588 |
1 | office | 136 | }; |
137 | |||
138 | /** |
||
139 | * Show no-data message if there is no data in sight. Otherwise, hide it. |
||
140 | */ |
||
141 | function handleNoData() { |
||
142 | var chart = this; |
||
143 | if (chart.hasData()) { |
||
144 | chart.hideNoData(); |
||
145 | } else { |
||
146 | chart.showNoData(); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Add event listener to handle automatic display of no-data message |
||
152 | */ |
||
153 | chartPrototype.callbacks.push(function(chart) { |
||
154 | H.addEvent(chart, 'load', handleNoData); |
||
155 | H.addEvent(chart, 'redraw', handleNoData); |
||
156 | }); |
||
157 | |||
158 | }(Highcharts)); |
||
159 | })); |