highstocks-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,128 +0,0 @@
1
- /**
2
- * @license Highstock JS v1.3.7 (2013-10-24)
3
- * Plugin for displaying a message when there is no data visible in chart.
4
- *
5
- * (c) 2010-2013 Highsoft AS
6
- * Author: Øystein Moseng
7
- *
8
- * License: www.highcharts.com/license
9
- */
10
-
11
- (function (H) { // docs
12
-
13
- var seriesTypes = H.seriesTypes,
14
- chartPrototype = H.Chart.prototype,
15
- defaultOptions = H.getOptions(),
16
- extend = H.extend;
17
-
18
- // Add language option
19
- extend(defaultOptions.lang, {
20
- noData: 'No data to display'
21
- });
22
-
23
- // Add default display options for message
24
- defaultOptions.noData = {
25
- position: {
26
- x: 0,
27
- y: 0,
28
- align: 'center',
29
- verticalAlign: 'middle'
30
- },
31
- attr: {
32
- },
33
- style: {
34
- fontWeight: 'bold',
35
- fontSize: '12px',
36
- color: '#60606a'
37
- }
38
- };
39
-
40
- /**
41
- * Define hasData functions for series. These return true if there are data points on this series within the plot area
42
- */
43
- function hasDataPie() {
44
- return !!this.points.length; /* != 0 */
45
- }
46
-
47
- seriesTypes.pie.prototype.hasData = hasDataPie;
48
-
49
- if (seriesTypes.gauge) {
50
- seriesTypes.gauge.prototype.hasData = hasDataPie;
51
- }
52
-
53
- if (seriesTypes.waterfall) {
54
- seriesTypes.waterfall.prototype.hasData = hasDataPie;
55
- }
56
-
57
- H.Series.prototype.hasData = function () {
58
- return this.dataMax !== undefined && this.dataMin !== undefined;
59
- };
60
-
61
- /**
62
- * Display a no-data message.
63
- *
64
- * @param {String} str An optional message to show in place of the default one
65
- */
66
- chartPrototype.showNoData = function (str) {
67
- var chart = this,
68
- options = chart.options,
69
- text = str || options.lang.noData,
70
- noDataOptions = options.noData;
71
-
72
- if (!chart.noDataLabel) {
73
- chart.noDataLabel = chart.renderer.label(text, 0, 0, null, null, null, null, null, 'no-data')
74
- .attr(noDataOptions.attr)
75
- .css(noDataOptions.style)
76
- .add();
77
- chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox');
78
- }
79
- };
80
-
81
- /**
82
- * Hide no-data message
83
- */
84
- chartPrototype.hideNoData = function () {
85
- var chart = this;
86
- if (chart.noDataLabel) {
87
- chart.noDataLabel = chart.noDataLabel.destroy();
88
- }
89
- };
90
-
91
- /**
92
- * Returns true if there are data points within the plot area now
93
- */
94
- chartPrototype.hasData = function () {
95
- var chart = this,
96
- series = chart.series,
97
- i = series.length;
98
-
99
- while (i--) {
100
- if (series[i].hasData() && !series[i].options.isInternal) {
101
- return true;
102
- }
103
- }
104
-
105
- return false;
106
- };
107
-
108
- /**
109
- * Show no-data message if there is no data in sight. Otherwise, hide it.
110
- */
111
- function handleNoData() {
112
- var chart = this;
113
- if (chart.hasData()) {
114
- chart.hideNoData();
115
- } else {
116
- chart.showNoData();
117
- }
118
- }
119
-
120
- /**
121
- * Add event listener to handle automatic display of no-data message
122
- */
123
- chartPrototype.callbacks.push(function (chart) {
124
- H.addEvent(chart, 'load', handleNoData);
125
- H.addEvent(chart, 'redraw', handleNoData);
126
- });
127
-
128
- }(Highcharts));