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