chartkick 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chartkick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/chartkick/version.rb +1 -1
- data/vendor/assets/javascripts/chartkick.js +1771 -2073
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d61ca3628616e68eea049bd4ed6d49030b7ef63
|
4
|
+
data.tar.gz: d42a08538f32f13da2186c92131dab2bb7d9c37a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e12ecc4f8cd96a87cb9db18749ba7b62c3efaf812eaea7054878ae3b28efbd6131c6b3ee71c98e23afa86e3e15d2cdab37769661b73883dbe100989ab47dcce
|
7
|
+
data.tar.gz: '09c1e0bc186b38f258ade1f1b5122efb5dfdecdb5f07d92a0b8e4d3894ae1f6a92fa1148feeb2457ae3288ef03c2b2e83acda91d6597e19aeae420cef662af79'
|
data/CHANGELOG.md
CHANGED
data/lib/chartkick/version.rb
CHANGED
@@ -1,2429 +1,2127 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
/******/
|
18
|
-
/******/ // Check if module is in cache
|
19
|
-
/******/ if(installedModules[moduleId]) {
|
20
|
-
/******/ return installedModules[moduleId].exports;
|
21
|
-
/******/ }
|
22
|
-
/******/ // Create a new module (and put it into the cache)
|
23
|
-
/******/ var module = installedModules[moduleId] = {
|
24
|
-
/******/ i: moduleId,
|
25
|
-
/******/ l: false,
|
26
|
-
/******/ exports: {}
|
27
|
-
/******/ };
|
28
|
-
/******/
|
29
|
-
/******/ // Execute the module function
|
30
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
-
/******/
|
32
|
-
/******/ // Flag the module as loaded
|
33
|
-
/******/ module.l = true;
|
34
|
-
/******/
|
35
|
-
/******/ // Return the exports of the module
|
36
|
-
/******/ return module.exports;
|
37
|
-
/******/ }
|
38
|
-
/******/
|
39
|
-
/******/
|
40
|
-
/******/ // expose the modules object (__webpack_modules__)
|
41
|
-
/******/ __webpack_require__.m = modules;
|
42
|
-
/******/
|
43
|
-
/******/ // expose the module cache
|
44
|
-
/******/ __webpack_require__.c = installedModules;
|
45
|
-
/******/
|
46
|
-
/******/ // define getter function for harmony exports
|
47
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
48
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
49
|
-
/******/ Object.defineProperty(exports, name, {
|
50
|
-
/******/ configurable: false,
|
51
|
-
/******/ enumerable: true,
|
52
|
-
/******/ get: getter
|
53
|
-
/******/ });
|
54
|
-
/******/ }
|
55
|
-
/******/ };
|
56
|
-
/******/
|
57
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
58
|
-
/******/ __webpack_require__.n = function(module) {
|
59
|
-
/******/ var getter = module && module.__esModule ?
|
60
|
-
/******/ function getDefault() { return module['default']; } :
|
61
|
-
/******/ function getModuleExports() { return module; };
|
62
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
63
|
-
/******/ return getter;
|
64
|
-
/******/ };
|
65
|
-
/******/
|
66
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
67
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
68
|
-
/******/
|
69
|
-
/******/ // __webpack_public_path__
|
70
|
-
/******/ __webpack_require__.p = "";
|
71
|
-
/******/
|
72
|
-
/******/ // Load entry module and return exports
|
73
|
-
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
74
|
-
/******/ })
|
75
|
-
/************************************************************************/
|
76
|
-
/******/ ([
|
77
|
-
/* 0 */
|
78
|
-
/***/ (function(module, exports, __webpack_require__) {
|
79
|
-
|
80
|
-
"use strict";
|
81
|
-
|
82
|
-
|
83
|
-
Object.defineProperty(exports, "__esModule", {
|
84
|
-
value: true
|
85
|
-
});
|
86
|
-
|
87
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
88
|
-
|
89
|
-
function isArray(variable) {
|
90
|
-
return Object.prototype.toString.call(variable) === "[object Array]";
|
91
|
-
}
|
92
|
-
|
93
|
-
function isFunction(variable) {
|
94
|
-
return variable instanceof Function;
|
95
|
-
}
|
96
|
-
|
97
|
-
function isPlainObject(variable) {
|
98
|
-
return !isFunction(variable) && variable instanceof Object;
|
99
|
-
}
|
100
|
-
|
101
|
-
// https://github.com/madrobby/zepto/blob/master/src/zepto.js
|
102
|
-
function extend(target, source) {
|
103
|
-
var key = void 0;
|
104
|
-
for (key in source) {
|
105
|
-
if (isPlainObject(source[key]) || isArray(source[key])) {
|
106
|
-
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
|
107
|
-
target[key] = {};
|
108
|
-
}
|
109
|
-
if (isArray(source[key]) && !isArray(target[key])) {
|
110
|
-
target[key] = [];
|
111
|
-
}
|
112
|
-
extend(target[key], source[key]);
|
113
|
-
} else if (source[key] !== undefined) {
|
114
|
-
target[key] = source[key];
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
function merge(obj1, obj2) {
|
120
|
-
var target = {};
|
121
|
-
extend(target, obj1);
|
122
|
-
extend(target, obj2);
|
123
|
-
return target;
|
124
|
-
}
|
125
|
-
|
126
|
-
var DATE_PATTERN = /^(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)$/i;
|
127
|
-
|
128
|
-
// https://github.com/Do/iso8601.js
|
129
|
-
var ISO8601_PATTERN = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)?(:)?(\d\d)?([.,]\d+)?($|Z|([+-])(\d\d)(:)?(\d\d)?)/i;
|
130
|
-
var DECIMAL_SEPARATOR = String(1.5).charAt(1);
|
131
|
-
|
132
|
-
function parseISO8601(input) {
|
133
|
-
var day = void 0,
|
134
|
-
hour = void 0,
|
135
|
-
matches = void 0,
|
136
|
-
milliseconds = void 0,
|
137
|
-
minutes = void 0,
|
138
|
-
month = void 0,
|
139
|
-
offset = void 0,
|
140
|
-
result = void 0,
|
141
|
-
seconds = void 0,
|
142
|
-
type = void 0,
|
143
|
-
year = void 0;
|
144
|
-
type = Object.prototype.toString.call(input);
|
145
|
-
if (type === "[object Date]") {
|
146
|
-
return input;
|
147
|
-
}
|
148
|
-
if (type !== "[object String]") {
|
149
|
-
return;
|
1
|
+
/*
|
2
|
+
* Chartkick.js
|
3
|
+
* Create beautiful charts with one line of JavaScript
|
4
|
+
* https://github.com/ankane/chartkick.js
|
5
|
+
* v2.3.4
|
6
|
+
* MIT License
|
7
|
+
*/
|
8
|
+
|
9
|
+
(function (global, factory) {
|
10
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
11
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
12
|
+
(global.Chartkick = factory());
|
13
|
+
}(this, (function () { 'use strict';
|
14
|
+
|
15
|
+
function isArray(variable) {
|
16
|
+
return Object.prototype.toString.call(variable) === "[object Array]";
|
150
17
|
}
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
month = parseInt(matches[3], 10) - 1;
|
155
|
-
day = parseInt(matches[5], 10);
|
156
|
-
hour = parseInt(matches[7], 10);
|
157
|
-
minutes = matches[9] ? parseInt(matches[9], 10) : 0;
|
158
|
-
seconds = matches[11] ? parseInt(matches[11], 10) : 0;
|
159
|
-
milliseconds = matches[12] ? parseFloat(DECIMAL_SEPARATOR + matches[12].slice(1)) * 1000 : 0;
|
160
|
-
result = Date.UTC(year, month, day, hour, minutes, seconds, milliseconds);
|
161
|
-
if (matches[13] && matches[14]) {
|
162
|
-
offset = matches[15] * 60;
|
163
|
-
if (matches[17]) {
|
164
|
-
offset += parseInt(matches[17], 10);
|
165
|
-
}
|
166
|
-
offset *= matches[14] === "-" ? -1 : 1;
|
167
|
-
result -= offset * 60 * 1000;
|
168
|
-
}
|
169
|
-
return new Date(result);
|
18
|
+
|
19
|
+
function isFunction(variable) {
|
20
|
+
return variable instanceof Function;
|
170
21
|
}
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
function negativeValues(series) {
|
175
|
-
var i = void 0,
|
176
|
-
j = void 0,
|
177
|
-
data = void 0;
|
178
|
-
for (i = 0; i < series.length; i++) {
|
179
|
-
data = series[i].data;
|
180
|
-
for (j = 0; j < data.length; j++) {
|
181
|
-
if (data[j][1] < 0) {
|
182
|
-
return true;
|
183
|
-
}
|
184
|
-
}
|
22
|
+
|
23
|
+
function isPlainObject(variable) {
|
24
|
+
return !isFunction(variable) && variable instanceof Object;
|
185
25
|
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
day = void 0;
|
202
|
-
if ((typeof n === "undefined" ? "undefined" : _typeof(n)) !== "object") {
|
203
|
-
if (typeof n === "number") {
|
204
|
-
n = new Date(n * 1000); // ms
|
205
|
-
} else {
|
206
|
-
n = toStr(n);
|
207
|
-
if (matches = n.match(DATE_PATTERN)) {
|
208
|
-
year = parseInt(matches[1], 10);
|
209
|
-
month = parseInt(matches[3], 10) - 1;
|
210
|
-
day = parseInt(matches[5], 10);
|
211
|
-
return new Date(year, month, day);
|
212
|
-
} else {
|
213
|
-
// str
|
214
|
-
// try our best to get the str into iso8601
|
215
|
-
// TODO be smarter about this
|
216
|
-
var str = n.replace(/ /, "T").replace(" ", "").replace("UTC", "Z");
|
217
|
-
n = parseISO8601(str) || new Date(n);
|
26
|
+
|
27
|
+
// https://github.com/madrobby/zepto/blob/master/src/zepto.js
|
28
|
+
function extend(target, source) {
|
29
|
+
var key;
|
30
|
+
for (key in source) {
|
31
|
+
if (isPlainObject(source[key]) || isArray(source[key])) {
|
32
|
+
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
|
33
|
+
target[key] = {};
|
34
|
+
}
|
35
|
+
if (isArray(source[key]) && !isArray(target[key])) {
|
36
|
+
target[key] = [];
|
37
|
+
}
|
38
|
+
extend(target[key], source[key]);
|
39
|
+
} else if (source[key] !== undefined) {
|
40
|
+
target[key] = source[key];
|
218
41
|
}
|
219
42
|
}
|
220
43
|
}
|
221
|
-
return n;
|
222
|
-
}
|
223
44
|
|
224
|
-
function
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
if (n.hasOwnProperty(i)) {
|
230
|
-
arr.push([i, n[i]]);
|
231
|
-
}
|
232
|
-
}
|
233
|
-
n = arr;
|
45
|
+
function merge(obj1, obj2) {
|
46
|
+
var target = {};
|
47
|
+
extend(target, obj1);
|
48
|
+
extend(target, obj2);
|
49
|
+
return target;
|
234
50
|
}
|
235
|
-
return n;
|
236
|
-
}
|
237
51
|
|
238
|
-
|
239
|
-
return function (chart, opts, chartOptions) {
|
240
|
-
var series = chart.data;
|
241
|
-
var options = merge({}, defaultOptions);
|
242
|
-
options = merge(options, chartOptions || {});
|
52
|
+
var DATE_PATTERN = /^(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)$/i;
|
243
53
|
|
244
|
-
|
245
|
-
|
246
|
-
|
54
|
+
// https://github.com/Do/iso8601.js
|
55
|
+
var ISO8601_PATTERN = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)?(:)?(\d\d)?([.,]\d+)?($|Z|([+-])(\d\d)(:)?(\d\d)?)/i;
|
56
|
+
var DECIMAL_SEPARATOR = String(1.5).charAt(1);
|
247
57
|
|
248
|
-
|
249
|
-
|
58
|
+
function parseISO8601(input) {
|
59
|
+
var day, hour, matches, milliseconds, minutes, month, offset, result, seconds, type, year;
|
60
|
+
type = Object.prototype.toString.call(input);
|
61
|
+
if (type === "[object Date]") {
|
62
|
+
return input;
|
250
63
|
}
|
251
|
-
|
252
|
-
|
253
|
-
if ("min" in opts) {
|
254
|
-
setMin(options, opts.min);
|
255
|
-
} else if (!negativeValues(series)) {
|
256
|
-
setMin(options, 0);
|
64
|
+
if (type !== "[object String]") {
|
65
|
+
return;
|
257
66
|
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
67
|
+
matches = input.match(ISO8601_PATTERN);
|
68
|
+
if (matches) {
|
69
|
+
year = parseInt(matches[1], 10);
|
70
|
+
month = parseInt(matches[3], 10) - 1;
|
71
|
+
day = parseInt(matches[5], 10);
|
72
|
+
hour = parseInt(matches[7], 10);
|
73
|
+
minutes = matches[9] ? parseInt(matches[9], 10) : 0;
|
74
|
+
seconds = matches[11] ? parseInt(matches[11], 10) : 0;
|
75
|
+
milliseconds = matches[12] ? parseFloat(DECIMAL_SEPARATOR + matches[12].slice(1)) * 1000 : 0;
|
76
|
+
result = Date.UTC(year, month, day, hour, minutes, seconds, milliseconds);
|
77
|
+
if (matches[13] && matches[14]) {
|
78
|
+
offset = matches[15] * 60;
|
79
|
+
if (matches[17]) {
|
80
|
+
offset += parseInt(matches[17], 10);
|
81
|
+
}
|
82
|
+
offset *= matches[14] === "-" ? -1 : 1;
|
83
|
+
result -= offset * 60 * 1000;
|
84
|
+
}
|
85
|
+
return new Date(result);
|
262
86
|
}
|
87
|
+
}
|
88
|
+
// end iso8601.js
|
263
89
|
|
264
|
-
|
265
|
-
|
90
|
+
function negativeValues(series) {
|
91
|
+
var i, j, data;
|
92
|
+
for (i = 0; i < series.length; i++) {
|
93
|
+
data = series[i].data;
|
94
|
+
for (j = 0; j < data.length; j++) {
|
95
|
+
if (data[j][1] < 0) {
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
}
|
266
99
|
}
|
100
|
+
return false;
|
101
|
+
}
|
267
102
|
|
268
|
-
|
269
|
-
|
270
|
-
|
103
|
+
function toStr(n) {
|
104
|
+
return "" + n;
|
105
|
+
}
|
106
|
+
|
107
|
+
function toFloat(n) {
|
108
|
+
return parseFloat(n);
|
109
|
+
}
|
271
110
|
|
272
|
-
|
273
|
-
|
111
|
+
function toDate(n) {
|
112
|
+
var matches, year, month, day;
|
113
|
+
if (typeof n !== "object") {
|
114
|
+
if (typeof n === "number") {
|
115
|
+
n = new Date(n * 1000); // ms
|
116
|
+
} else {
|
117
|
+
n = toStr(n);
|
118
|
+
if ((matches = n.match(DATE_PATTERN))) {
|
119
|
+
year = parseInt(matches[1], 10);
|
120
|
+
month = parseInt(matches[3], 10) - 1;
|
121
|
+
day = parseInt(matches[5], 10);
|
122
|
+
return new Date(year, month, day);
|
123
|
+
} else { // str
|
124
|
+
// try our best to get the str into iso8601
|
125
|
+
// TODO be smarter about this
|
126
|
+
var str = n.replace(/ /, "T").replace(" ", "").replace("UTC", "Z");
|
127
|
+
n = parseISO8601(str) || new Date(n);
|
128
|
+
}
|
129
|
+
}
|
274
130
|
}
|
131
|
+
return n;
|
132
|
+
}
|
275
133
|
|
276
|
-
|
277
|
-
|
134
|
+
function toArr(n) {
|
135
|
+
if (!isArray(n)) {
|
136
|
+
var arr = [], i;
|
137
|
+
for (i in n) {
|
138
|
+
if (n.hasOwnProperty(i)) {
|
139
|
+
arr.push([i, n[i]]);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
n = arr;
|
278
143
|
}
|
144
|
+
return n;
|
145
|
+
}
|
279
146
|
|
280
|
-
|
281
|
-
|
147
|
+
function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {
|
148
|
+
return function (chart, opts, chartOptions) {
|
149
|
+
var series = chart.data;
|
150
|
+
var options = merge({}, defaultOptions);
|
151
|
+
options = merge(options, chartOptions || {});
|
282
152
|
|
283
|
-
|
284
|
-
|
285
|
-
}
|
153
|
+
if (chart.hideLegend || "legend" in opts) {
|
154
|
+
hideLegend(options, opts.legend, chart.hideLegend);
|
155
|
+
}
|
286
156
|
|
287
|
-
|
288
|
-
|
289
|
-
}
|
157
|
+
if (opts.title) {
|
158
|
+
setTitle(options, opts.title);
|
159
|
+
}
|
290
160
|
|
291
|
-
|
292
|
-
|
293
|
-
|
161
|
+
// min
|
162
|
+
if ("min" in opts) {
|
163
|
+
setMin(options, opts.min);
|
164
|
+
} else if (!negativeValues(series)) {
|
165
|
+
setMin(options, 0);
|
166
|
+
}
|
294
167
|
|
295
|
-
|
296
|
-
|
297
|
-
|
168
|
+
// max
|
169
|
+
if (opts.max) {
|
170
|
+
setMax(options, opts.max);
|
171
|
+
}
|
298
172
|
|
299
|
-
|
300
|
-
|
301
|
-
}
|
173
|
+
if ("stacked" in opts) {
|
174
|
+
setStacked(options, opts.stacked);
|
175
|
+
}
|
302
176
|
|
303
|
-
|
304
|
-
|
305
|
-
}
|
177
|
+
if (opts.colors) {
|
178
|
+
options.colors = opts.colors;
|
179
|
+
}
|
306
180
|
|
307
|
-
|
308
|
-
|
309
|
-
}
|
181
|
+
if (opts.xtitle) {
|
182
|
+
setXtitle(options, opts.xtitle);
|
183
|
+
}
|
310
184
|
|
311
|
-
|
312
|
-
|
313
|
-
}
|
185
|
+
if (opts.ytitle) {
|
186
|
+
setYtitle(options, opts.ytitle);
|
187
|
+
}
|
314
188
|
|
315
|
-
|
316
|
-
|
317
|
-
}
|
189
|
+
// merge library last
|
190
|
+
options = merge(options, opts.library || {});
|
318
191
|
|
319
|
-
|
320
|
-
|
321
|
-
}
|
192
|
+
return options;
|
193
|
+
};
|
194
|
+
}
|
322
195
|
|
323
|
-
function
|
324
|
-
|
325
|
-
}
|
196
|
+
function sortByTime(a, b) {
|
197
|
+
return a[0].getTime() - b[0].getTime();
|
198
|
+
}
|
326
199
|
|
327
|
-
function
|
328
|
-
|
329
|
-
if (options.prefix) {
|
330
|
-
if (value < 0) {
|
331
|
-
value = value * -1;
|
332
|
-
pre += "-";
|
333
|
-
}
|
334
|
-
pre += options.prefix;
|
200
|
+
function sortByNumberSeries(a, b) {
|
201
|
+
return a[0] - b[0];
|
335
202
|
}
|
336
203
|
|
337
|
-
|
338
|
-
|
339
|
-
var parts = value.split(".");
|
340
|
-
value = parts[0];
|
341
|
-
if (options.thousands) {
|
342
|
-
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, options.thousands);
|
343
|
-
}
|
344
|
-
if (parts.length > 1) {
|
345
|
-
value += (options.decimal || ".") + parts[1];
|
346
|
-
}
|
204
|
+
function sortByNumber(a, b) {
|
205
|
+
return a - b;
|
347
206
|
}
|
348
207
|
|
349
|
-
|
350
|
-
|
208
|
+
function isMinute(d) {
|
209
|
+
return d.getMilliseconds() === 0 && d.getSeconds() === 0;
|
210
|
+
}
|
351
211
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
exports.isArray = isArray;
|
356
|
-
exports.isFunction = isFunction;
|
357
|
-
exports.toStr = toStr;
|
358
|
-
exports.toFloat = toFloat;
|
359
|
-
exports.toDate = toDate;
|
360
|
-
exports.toArr = toArr;
|
361
|
-
exports.sortByTime = sortByTime;
|
362
|
-
exports.sortByNumberSeries = sortByNumberSeries;
|
363
|
-
exports.sortByNumber = sortByNumber;
|
364
|
-
exports.isMinute = isMinute;
|
365
|
-
exports.isHour = isHour;
|
366
|
-
exports.isDay = isDay;
|
367
|
-
exports.isWeek = isWeek;
|
368
|
-
exports.isMonth = isMonth;
|
369
|
-
exports.isYear = isYear;
|
370
|
-
exports.isDate = isDate;
|
212
|
+
function isHour(d) {
|
213
|
+
return isMinute(d) && d.getMinutes() === 0;
|
214
|
+
}
|
371
215
|
|
372
|
-
|
373
|
-
|
374
|
-
|
216
|
+
function isDay(d) {
|
217
|
+
return isHour(d) && d.getHours() === 0;
|
218
|
+
}
|
375
219
|
|
376
|
-
|
220
|
+
function isWeek(d, dayOfWeek) {
|
221
|
+
return isDay(d) && d.getDay() === dayOfWeek;
|
222
|
+
}
|
377
223
|
|
224
|
+
function isMonth(d) {
|
225
|
+
return isDay(d) && d.getDate() === 1;
|
226
|
+
}
|
378
227
|
|
379
|
-
|
380
|
-
|
381
|
-
}
|
228
|
+
function isYear(d) {
|
229
|
+
return isMonth(d) && d.getMonth() === 0;
|
230
|
+
}
|
382
231
|
|
383
|
-
|
232
|
+
function isDate(obj) {
|
233
|
+
return !isNaN(toDate(obj)) && toStr(obj).length >= 6;
|
234
|
+
}
|
384
235
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
236
|
+
function formatValue(pre, value, options) {
|
237
|
+
pre = pre || "";
|
238
|
+
if (options.prefix) {
|
239
|
+
if (value < 0) {
|
240
|
+
value = value * -1;
|
241
|
+
pre += "-";
|
242
|
+
}
|
243
|
+
pre += options.prefix;
|
244
|
+
}
|
392
245
|
|
393
|
-
|
246
|
+
if (options.thousands || options.decimal) {
|
247
|
+
value = toStr(value);
|
248
|
+
var parts = value.split(".");
|
249
|
+
value = parts[0];
|
250
|
+
if (options.thousands) {
|
251
|
+
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, options.thousands);
|
252
|
+
}
|
253
|
+
if (parts.length > 1) {
|
254
|
+
value += (options.decimal || ".") + parts[1];
|
255
|
+
}
|
256
|
+
}
|
394
257
|
|
395
|
-
|
258
|
+
return pre + value + (options.suffix || "");
|
259
|
+
}
|
396
260
|
|
397
|
-
|
261
|
+
function allZeros(data) {
|
262
|
+
var i, j, d;
|
263
|
+
for (i = 0; i < data.length; i++) {
|
264
|
+
d = data[i].data;
|
265
|
+
for (j = 0; j < d.length; j++) {
|
266
|
+
if (d[j][1] != 0) {
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
return true;
|
272
|
+
}
|
398
273
|
|
399
|
-
var
|
274
|
+
var baseOptions = {
|
275
|
+
maintainAspectRatio: false,
|
276
|
+
animation: false,
|
277
|
+
tooltips: {
|
278
|
+
displayColors: false,
|
279
|
+
callbacks: {}
|
280
|
+
},
|
281
|
+
legend: {},
|
282
|
+
title: {fontSize: 20, fontColor: "#333"}
|
283
|
+
};
|
400
284
|
|
401
|
-
var
|
285
|
+
var defaultOptions = {
|
286
|
+
scales: {
|
287
|
+
yAxes: [
|
288
|
+
{
|
289
|
+
ticks: {
|
290
|
+
maxTicksLimit: 4
|
291
|
+
},
|
292
|
+
scaleLabel: {
|
293
|
+
fontSize: 16,
|
294
|
+
// fontStyle: "bold",
|
295
|
+
fontColor: "#333"
|
296
|
+
}
|
297
|
+
}
|
298
|
+
],
|
299
|
+
xAxes: [
|
300
|
+
{
|
301
|
+
gridLines: {
|
302
|
+
drawOnChartArea: false
|
303
|
+
},
|
304
|
+
scaleLabel: {
|
305
|
+
fontSize: 16,
|
306
|
+
// fontStyle: "bold",
|
307
|
+
fontColor: "#333"
|
308
|
+
},
|
309
|
+
time: {},
|
310
|
+
ticks: {}
|
311
|
+
}
|
312
|
+
]
|
313
|
+
}
|
314
|
+
};
|
402
315
|
|
403
|
-
|
316
|
+
// http://there4.io/2012/05/02/google-chart-color-list/
|
317
|
+
var defaultColors = [
|
318
|
+
"#3366CC", "#DC3912", "#FF9900", "#109618", "#990099", "#3B3EAC", "#0099C6",
|
319
|
+
"#DD4477", "#66AA00", "#B82E2E", "#316395", "#994499", "#22AA99", "#AAAA11",
|
320
|
+
"#6633CC", "#E67300", "#8B0707", "#329262", "#5574A6", "#651067"
|
321
|
+
];
|
322
|
+
|
323
|
+
var hideLegend = function (options, legend, hideLegend) {
|
324
|
+
if (legend !== undefined) {
|
325
|
+
options.legend.display = !!legend;
|
326
|
+
if (legend && legend !== true) {
|
327
|
+
options.legend.position = legend;
|
328
|
+
}
|
329
|
+
} else if (hideLegend) {
|
330
|
+
options.legend.display = false;
|
331
|
+
}
|
332
|
+
};
|
404
333
|
|
405
|
-
var
|
334
|
+
var setTitle = function (options, title) {
|
335
|
+
options.title.display = true;
|
336
|
+
options.title.text = title;
|
337
|
+
};
|
406
338
|
|
407
|
-
var
|
339
|
+
var setMin = function (options, min) {
|
340
|
+
if (min !== null) {
|
341
|
+
options.scales.yAxes[0].ticks.min = toFloat(min);
|
342
|
+
}
|
343
|
+
};
|
408
344
|
|
409
|
-
|
345
|
+
var setMax = function (options, max) {
|
346
|
+
options.scales.yAxes[0].ticks.max = toFloat(max);
|
347
|
+
};
|
410
348
|
|
411
|
-
function
|
349
|
+
var setBarMin = function (options, min) {
|
350
|
+
if (min !== null) {
|
351
|
+
options.scales.xAxes[0].ticks.min = toFloat(min);
|
352
|
+
}
|
353
|
+
};
|
412
354
|
|
413
|
-
|
355
|
+
var setBarMax = function (options, max) {
|
356
|
+
options.scales.xAxes[0].ticks.max = toFloat(max);
|
357
|
+
};
|
414
358
|
|
415
|
-
|
359
|
+
var setStacked = function (options, stacked) {
|
360
|
+
options.scales.xAxes[0].stacked = !!stacked;
|
361
|
+
options.scales.yAxes[0].stacked = !!stacked;
|
362
|
+
};
|
416
363
|
|
417
|
-
var
|
418
|
-
|
364
|
+
var setXtitle = function (options, title) {
|
365
|
+
options.scales.xAxes[0].scaleLabel.display = true;
|
366
|
+
options.scales.xAxes[0].scaleLabel.labelString = title;
|
367
|
+
};
|
419
368
|
|
420
|
-
|
369
|
+
var setYtitle = function (options, title) {
|
370
|
+
options.scales.yAxes[0].scaleLabel.display = true;
|
371
|
+
options.scales.yAxes[0].scaleLabel.labelString = title;
|
372
|
+
};
|
421
373
|
|
422
|
-
function
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
element.textContent = text;
|
427
|
-
}
|
428
|
-
}
|
429
|
-
|
430
|
-
function chartError(element, message) {
|
431
|
-
setText(element, "Error Loading Chart: " + message);
|
432
|
-
element.style.color = "#ff0000";
|
433
|
-
}
|
434
|
-
|
435
|
-
function errorCatcher(chart) {
|
436
|
-
try {
|
437
|
-
chart.__render();
|
438
|
-
} catch (err) {
|
439
|
-
chartError(chart.element, err.message);
|
440
|
-
throw err;
|
441
|
-
}
|
442
|
-
}
|
374
|
+
var drawChart = function(chart, type, data, options) {
|
375
|
+
if (chart.chart) {
|
376
|
+
chart.chart.destroy();
|
377
|
+
}
|
443
378
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
chartError(chart.element, message);
|
451
|
-
});
|
452
|
-
} else {
|
453
|
-
chart.rawData = dataSource;
|
454
|
-
errorCatcher(chart);
|
455
|
-
}
|
456
|
-
}
|
457
|
-
|
458
|
-
function addDownloadButton(chart) {
|
459
|
-
var element = chart.element;
|
460
|
-
var link = document.createElement("a");
|
461
|
-
link.download = chart.options.download === true ? "chart.png" : chart.options.download; // http://caniuse.com/download
|
462
|
-
link.style.position = "absolute";
|
463
|
-
link.style.top = "20px";
|
464
|
-
link.style.right = "20px";
|
465
|
-
link.style.zIndex = 1000;
|
466
|
-
link.style.lineHeight = "20px";
|
467
|
-
link.target = "_blank"; // for safari
|
468
|
-
var image = document.createElement("img");
|
469
|
-
image.alt = "Download";
|
470
|
-
image.style.border = "none";
|
471
|
-
// icon from font-awesome
|
472
|
-
// http://fa2png.io/
|
473
|
-
image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABCFBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMywEsqxAAAAV3RSTlMAAQIDBggJCgsMDQ4PERQaHB0eISIjJCouLzE0OTo/QUJHSUpLTU5PUllhYmltcHh5foWLjI+SlaCio6atr7S1t7m6vsHHyM7R2tze5Obo7fHz9ff5+/1hlxK2AAAA30lEQVQYGUXBhVYCQQBA0TdYWAt2d3d3YWAHyur7/z9xgD16Lw0DW+XKx+1GgX+FRzM3HWQWrHl5N/oapW5RPe0PkBu+UYeICvozTWZVK23Ao04B79oJrOsJDOoxkZoQPWgX29pHpCZEk7rEvQYiNSFq1UMqvlCjJkRBS1R8hb00Vb/TajtBL7nTHE1X1vyMQF732dQhyF2o6SAwrzP06iUQzvwsArlnzcOdrgBhJyHa1QOgO9U1GsKuvjUTjavliZYQ8nNPapG6sap/3nrIdJ6bOWzmX/fy0XVpfzZP3S8OJT3g9EEiJwAAAABJRU5ErkJggg==";
|
474
|
-
link.appendChild(image);
|
475
|
-
element.style.position = "relative";
|
476
|
-
|
477
|
-
chart.downloadAttached = true;
|
478
|
-
|
479
|
-
// mouseenter
|
480
|
-
addEvent(element, "mouseover", function (e) {
|
481
|
-
var related = e.relatedTarget;
|
482
|
-
// check download option again to ensure it wasn't changed
|
483
|
-
if (!related || related !== this && !childOf(this, related) && chart.options.download) {
|
484
|
-
link.href = chart.toImage();
|
485
|
-
element.appendChild(link);
|
486
|
-
}
|
487
|
-
});
|
488
|
-
|
489
|
-
// mouseleave
|
490
|
-
addEvent(element, "mouseout", function (e) {
|
491
|
-
var related = e.relatedTarget;
|
492
|
-
if (!related || related !== this && !childOf(this, related)) {
|
493
|
-
if (link.parentNode) {
|
494
|
-
link.parentNode.removeChild(link);
|
495
|
-
}
|
496
|
-
}
|
497
|
-
});
|
498
|
-
}
|
499
|
-
|
500
|
-
// http://stackoverflow.com/questions/10149963/adding-event-listener-cross-browser
|
501
|
-
function addEvent(elem, event, fn) {
|
502
|
-
if (elem.addEventListener) {
|
503
|
-
elem.addEventListener(event, fn, false);
|
504
|
-
} else {
|
505
|
-
elem.attachEvent("on" + event, function () {
|
506
|
-
// set the this pointer same as addEventListener when fn is called
|
507
|
-
return fn.call(elem, window.event);
|
379
|
+
chart.element.innerHTML = "<canvas></canvas>";
|
380
|
+
var ctx = chart.element.getElementsByTagName("CANVAS")[0];
|
381
|
+
chart.chart = new window.Chart(ctx, {
|
382
|
+
type: type,
|
383
|
+
data: data,
|
384
|
+
options: options
|
508
385
|
});
|
509
|
-
}
|
510
|
-
}
|
511
|
-
|
512
|
-
// https://gist.github.com/shawnbot/4166283
|
513
|
-
function childOf(p, c) {
|
514
|
-
if (p === c) return false;
|
515
|
-
while (c && c !== p) {
|
516
|
-
c = c.parentNode;
|
517
|
-
}return c === p;
|
518
|
-
}
|
519
|
-
|
520
|
-
function addAdapter(adapter) {
|
521
|
-
if (adapters.indexOf(adapter) === -1) {
|
522
|
-
adapters.push(adapter);
|
523
|
-
}
|
524
|
-
}
|
525
|
-
|
526
|
-
function loadAdapters() {
|
527
|
-
if ("Chart" in window) {
|
528
|
-
addAdapter(_chartjs2.default);
|
529
|
-
}
|
530
|
-
|
531
|
-
if ("Highcharts" in window) {
|
532
|
-
addAdapter(_highcharts2.default);
|
533
|
-
}
|
386
|
+
};
|
534
387
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
388
|
+
// http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
|
389
|
+
var addOpacity = function(hex, opacity) {
|
390
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
391
|
+
return result ? "rgba(" + parseInt(result[1], 16) + ", " + parseInt(result[2], 16) + ", " + parseInt(result[3], 16) + ", " + opacity + ")" : hex;
|
392
|
+
};
|
539
393
|
|
540
|
-
function
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
for (var i = 0; i < data.length; i++) {
|
545
|
-
if (data[i].data.length > 0) {
|
546
|
-
return false;
|
547
|
-
}
|
394
|
+
var setLabelSize = function (chart, data, options) {
|
395
|
+
var maxLabelSize = Math.ceil(chart.element.offsetWidth / 4.0 / data.labels.length);
|
396
|
+
if (maxLabelSize > 25) {
|
397
|
+
maxLabelSize = 25;
|
548
398
|
}
|
549
|
-
|
550
|
-
|
551
|
-
|
399
|
+
options.scales.xAxes[0].ticks.callback = function (value) {
|
400
|
+
value = toStr(value);
|
401
|
+
if (value.length > maxLabelSize) {
|
402
|
+
return value.substring(0, maxLabelSize - 2) + "...";
|
403
|
+
} else {
|
404
|
+
return value;
|
405
|
+
}
|
406
|
+
};
|
407
|
+
};
|
552
408
|
|
553
|
-
function
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
}
|
561
|
-
}
|
562
|
-
}
|
563
|
-
|
564
|
-
// TODO remove chartType if cross-browser way
|
565
|
-
// to get the name of the chart class
|
566
|
-
function callAdapter(chartType, chart) {
|
567
|
-
var i = void 0,
|
568
|
-
adapter = void 0,
|
569
|
-
fnName = void 0,
|
570
|
-
adapterName = void 0;
|
571
|
-
fnName = "render" + chartType;
|
572
|
-
adapterName = chart.options.adapter;
|
573
|
-
|
574
|
-
loadAdapters();
|
575
|
-
|
576
|
-
for (i = 0; i < adapters.length; i++) {
|
577
|
-
adapter = adapters[i];
|
578
|
-
if ((!adapterName || adapterName === adapter.name) && (0, _helpers.isFunction)(adapter[fnName])) {
|
579
|
-
chart.adapter = adapter.name;
|
580
|
-
return adapter[fnName](chart);
|
581
|
-
}
|
582
|
-
}
|
409
|
+
var setFormatOptions = function(chart, options, chartType) {
|
410
|
+
var formatOptions = {
|
411
|
+
prefix: chart.options.prefix,
|
412
|
+
suffix: chart.options.suffix,
|
413
|
+
thousands: chart.options.thousands,
|
414
|
+
decimal: chart.options.decimal
|
415
|
+
};
|
583
416
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
}
|
417
|
+
if (formatOptions.prefix || formatOptions.suffix || formatOptions.thousands || formatOptions.decimal) {
|
418
|
+
if (chartType !== "pie") {
|
419
|
+
var myAxes = options.scales.yAxes;
|
420
|
+
if (chartType === "bar") {
|
421
|
+
myAxes = options.scales.xAxes;
|
422
|
+
}
|
590
423
|
|
591
|
-
|
424
|
+
if (!myAxes[0].ticks.callback) {
|
425
|
+
myAxes[0].ticks.callback = function (value) {
|
426
|
+
return formatValue("", value, formatOptions);
|
427
|
+
};
|
428
|
+
}
|
429
|
+
}
|
592
430
|
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
};
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
return r;
|
622
|
-
};
|
623
|
-
|
624
|
-
function detectDiscrete(series) {
|
625
|
-
var i = void 0,
|
626
|
-
j = void 0,
|
627
|
-
data = void 0;
|
628
|
-
for (i = 0; i < series.length; i++) {
|
629
|
-
data = (0, _helpers.toArr)(series[i].data);
|
630
|
-
for (j = 0; j < data.length; j++) {
|
631
|
-
if (!(0, _helpers.isDate)(data[j][0])) {
|
632
|
-
return true;
|
431
|
+
if (!options.tooltips.callbacks.label) {
|
432
|
+
if (chartType !== "pie") {
|
433
|
+
var valueLabel = chartType === "bar" ? "xLabel" : "yLabel";
|
434
|
+
options.tooltips.callbacks.label = function (tooltipItem, data) {
|
435
|
+
var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
436
|
+
if (label) {
|
437
|
+
label += ': ';
|
438
|
+
}
|
439
|
+
return formatValue(label, tooltipItem[valueLabel], formatOptions);
|
440
|
+
};
|
441
|
+
} else {
|
442
|
+
// need to use separate label for pie charts
|
443
|
+
options.tooltips.callbacks.label = function (tooltipItem, data) {
|
444
|
+
var dataLabel = data.labels[tooltipItem.index];
|
445
|
+
var value = ': ';
|
446
|
+
|
447
|
+
if (isArray(dataLabel)) {
|
448
|
+
// show value on first line of multiline label
|
449
|
+
// need to clone because we are changing the value
|
450
|
+
dataLabel = dataLabel.slice();
|
451
|
+
dataLabel[0] += value;
|
452
|
+
} else {
|
453
|
+
dataLabel += value;
|
454
|
+
}
|
455
|
+
|
456
|
+
return formatValue(dataLabel, data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index], formatOptions);
|
457
|
+
};
|
458
|
+
}
|
633
459
|
}
|
634
460
|
}
|
635
|
-
}
|
636
|
-
return false;
|
637
|
-
}
|
638
|
-
|
639
|
-
// creates a shallow copy of each element of the array
|
640
|
-
// elements are expected to be objects
|
641
|
-
function copySeries(series) {
|
642
|
-
var newSeries = [],
|
643
|
-
i = void 0,
|
644
|
-
j = void 0;
|
645
|
-
for (i = 0; i < series.length; i++) {
|
646
|
-
var copy = {};
|
647
|
-
for (j in series[i]) {
|
648
|
-
if (series[i].hasOwnProperty(j)) {
|
649
|
-
copy[j] = series[i][j];
|
650
|
-
}
|
651
|
-
}
|
652
|
-
newSeries.push(copy);
|
653
|
-
}
|
654
|
-
return newSeries;
|
655
|
-
}
|
656
|
-
|
657
|
-
function processSeries(chart, keyType) {
|
658
|
-
var i = void 0;
|
461
|
+
};
|
659
462
|
|
660
|
-
var
|
661
|
-
var series = chart.rawData;
|
463
|
+
var jsOptions = jsOptionsFunc(merge(baseOptions, defaultOptions), hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);
|
662
464
|
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
chart.hideLegend = true;
|
667
|
-
} else {
|
668
|
-
chart.hideLegend = false;
|
669
|
-
}
|
670
|
-
if ((opts.discrete === null || opts.discrete === undefined) && keyType !== "bubble" && keyType !== "number") {
|
671
|
-
chart.discrete = detectDiscrete(series);
|
672
|
-
} else {
|
673
|
-
chart.discrete = opts.discrete;
|
674
|
-
}
|
675
|
-
if (chart.discrete) {
|
676
|
-
keyType = "string";
|
677
|
-
}
|
678
|
-
if (chart.options.xtype) {
|
679
|
-
keyType = chart.options.xtype;
|
680
|
-
}
|
465
|
+
var createDataTable = function (chart, options, chartType) {
|
466
|
+
var datasets = [];
|
467
|
+
var labels = [];
|
681
468
|
|
682
|
-
|
683
|
-
series = copySeries(series);
|
684
|
-
for (i = 0; i < series.length; i++) {
|
685
|
-
series[i].data = formatSeriesData((0, _helpers.toArr)(series[i].data), keyType);
|
686
|
-
}
|
469
|
+
var colors = chart.options.colors || defaultColors;
|
687
470
|
|
688
|
-
|
689
|
-
|
471
|
+
var day = true;
|
472
|
+
var week = true;
|
473
|
+
var dayOfWeek;
|
474
|
+
var month = true;
|
475
|
+
var year = true;
|
476
|
+
var hour = true;
|
477
|
+
var minute = true;
|
478
|
+
var detectType = (chartType === "line" || chartType === "area") && !chart.discrete;
|
690
479
|
|
691
|
-
|
692
|
-
var perfectData = (0, _helpers.toArr)(chart.rawData),
|
693
|
-
i = void 0;
|
694
|
-
for (i = 0; i < perfectData.length; i++) {
|
695
|
-
perfectData[i] = [(0, _helpers.toStr)(perfectData[i][0]), (0, _helpers.toFloat)(perfectData[i][1])];
|
696
|
-
}
|
697
|
-
return perfectData;
|
698
|
-
}
|
480
|
+
var series = chart.data;
|
699
481
|
|
700
|
-
|
482
|
+
var sortedLabels = [];
|
701
483
|
|
702
|
-
var
|
703
|
-
|
704
|
-
|
484
|
+
var i, j, s, d, key, rows = [];
|
485
|
+
for (i = 0; i < series.length; i++) {
|
486
|
+
s = series[i];
|
705
487
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
488
|
+
for (j = 0; j < s.data.length; j++) {
|
489
|
+
d = s.data[j];
|
490
|
+
key = detectType ? d[0].getTime() : d[0];
|
491
|
+
if (!rows[key]) {
|
492
|
+
rows[key] = new Array(series.length);
|
493
|
+
}
|
494
|
+
rows[key][i] = toFloat(d[1]);
|
495
|
+
if (sortedLabels.indexOf(key) === -1) {
|
496
|
+
sortedLabels.push(key);
|
497
|
+
}
|
712
498
|
}
|
713
499
|
}
|
714
|
-
this.element = element;
|
715
|
-
this.options = (0, _helpers.merge)(Chartkick.options, options || {});
|
716
|
-
this.dataSource = dataSource;
|
717
|
-
|
718
|
-
Chartkick.charts[element.id] = this;
|
719
|
-
|
720
|
-
fetchDataSource(this, dataSource);
|
721
500
|
|
722
|
-
if (
|
723
|
-
|
501
|
+
if (detectType || chart.options.xtype === "number") {
|
502
|
+
sortedLabels.sort(sortByNumber);
|
724
503
|
}
|
725
|
-
}
|
726
504
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
}, {
|
743
|
-
key: "getOptions",
|
744
|
-
value: function getOptions() {
|
745
|
-
return this.options;
|
746
|
-
}
|
747
|
-
}, {
|
748
|
-
key: "getChartObject",
|
749
|
-
value: function getChartObject() {
|
750
|
-
return this.chart;
|
751
|
-
}
|
752
|
-
}, {
|
753
|
-
key: "getAdapter",
|
754
|
-
value: function getAdapter() {
|
755
|
-
return this.adapter;
|
756
|
-
}
|
757
|
-
}, {
|
758
|
-
key: "updateData",
|
759
|
-
value: function updateData(dataSource, options) {
|
760
|
-
this.dataSource = dataSource;
|
761
|
-
if (options) {
|
762
|
-
this.__updateOptions(options);
|
763
|
-
}
|
764
|
-
fetchDataSource(this, dataSource);
|
765
|
-
}
|
766
|
-
}, {
|
767
|
-
key: "setOptions",
|
768
|
-
value: function setOptions(options) {
|
769
|
-
this.__updateOptions(options);
|
770
|
-
this.redraw();
|
771
|
-
}
|
772
|
-
}, {
|
773
|
-
key: "redraw",
|
774
|
-
value: function redraw() {
|
775
|
-
fetchDataSource(this, this.rawData);
|
776
|
-
}
|
777
|
-
}, {
|
778
|
-
key: "refreshData",
|
779
|
-
value: function refreshData() {
|
780
|
-
if (typeof this.dataSource === "string") {
|
781
|
-
// prevent browser from caching
|
782
|
-
var sep = this.dataSource.indexOf("?") === -1 ? "?" : "&";
|
783
|
-
var url = this.dataSource + sep + "_=" + new Date().getTime();
|
784
|
-
fetchDataSource(this, url);
|
785
|
-
}
|
786
|
-
}
|
787
|
-
}, {
|
788
|
-
key: "startRefresh",
|
789
|
-
value: function startRefresh() {
|
790
|
-
var _this = this;
|
791
|
-
|
792
|
-
var refresh = this.options.refresh;
|
793
|
-
|
794
|
-
if (!this.intervalId) {
|
795
|
-
if (refresh) {
|
796
|
-
this.intervalId = setInterval(function () {
|
797
|
-
_this.refreshData();
|
798
|
-
}, refresh * 1000);
|
799
|
-
} else {
|
800
|
-
throw new Error("No refresh interval");
|
505
|
+
var rows2 = [];
|
506
|
+
for (j = 0; j < series.length; j++) {
|
507
|
+
rows2.push([]);
|
508
|
+
}
|
509
|
+
|
510
|
+
var value;
|
511
|
+
var k;
|
512
|
+
for (k = 0; k < sortedLabels.length; k++) {
|
513
|
+
i = sortedLabels[k];
|
514
|
+
if (detectType) {
|
515
|
+
value = new Date(toFloat(i));
|
516
|
+
// TODO make this efficient
|
517
|
+
day = day && isDay(value);
|
518
|
+
if (!dayOfWeek) {
|
519
|
+
dayOfWeek = value.getDay();
|
801
520
|
}
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
if (this.intervalId) {
|
808
|
-
clearInterval(this.intervalId);
|
809
|
-
this.intervalId = null;
|
810
|
-
}
|
811
|
-
}
|
812
|
-
}, {
|
813
|
-
key: "toImage",
|
814
|
-
value: function toImage() {
|
815
|
-
if (this.adapter === "chartjs") {
|
816
|
-
return this.chart.toBase64Image();
|
521
|
+
week = week && isWeek(value, dayOfWeek);
|
522
|
+
month = month && isMonth(value);
|
523
|
+
year = year && isYear(value);
|
524
|
+
hour = hour && isHour(value);
|
525
|
+
minute = minute && isMinute(value);
|
817
526
|
} else {
|
818
|
-
|
527
|
+
value = i;
|
819
528
|
}
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
var updateRefresh = options.refresh && options.refresh !== this.options.refresh;
|
825
|
-
this.options = (0, _helpers.merge)(Chartkick.options, options);
|
826
|
-
if (updateRefresh) {
|
827
|
-
this.stopRefresh();
|
828
|
-
this.startRefresh();
|
529
|
+
labels.push(value);
|
530
|
+
for (j = 0; j < series.length; j++) {
|
531
|
+
// Chart.js doesn't like undefined
|
532
|
+
rows2[j].push(rows[i][j] === undefined ? null : rows[i][j]);
|
829
533
|
}
|
830
534
|
}
|
831
|
-
}, {
|
832
|
-
key: "__render",
|
833
|
-
value: function __render() {
|
834
|
-
this.data = this.__processData();
|
835
|
-
renderChart(this.__chartName(), this);
|
836
|
-
}
|
837
|
-
}]);
|
838
535
|
|
839
|
-
|
840
|
-
|
536
|
+
for (i = 0; i < series.length; i++) {
|
537
|
+
s = series[i];
|
538
|
+
|
539
|
+
var color = s.color || colors[i];
|
540
|
+
var backgroundColor = chartType !== "line" ? addOpacity(color, 0.5) : color;
|
541
|
+
|
542
|
+
var dataset = {
|
543
|
+
label: s.name,
|
544
|
+
data: rows2[i],
|
545
|
+
fill: chartType === "area",
|
546
|
+
borderColor: color,
|
547
|
+
backgroundColor: backgroundColor,
|
548
|
+
pointBackgroundColor: color,
|
549
|
+
borderWidth: 2
|
550
|
+
};
|
841
551
|
|
842
|
-
|
843
|
-
|
552
|
+
if (s.stack) {
|
553
|
+
dataset.stack = s.stack;
|
554
|
+
}
|
844
555
|
|
845
|
-
|
846
|
-
|
556
|
+
if (chart.options.curve === false) {
|
557
|
+
dataset.lineTension = 0;
|
558
|
+
}
|
847
559
|
|
848
|
-
|
849
|
-
|
560
|
+
if (chart.options.points === false) {
|
561
|
+
dataset.pointRadius = 0;
|
562
|
+
dataset.pointHitRadius = 5;
|
563
|
+
}
|
850
564
|
|
851
|
-
|
852
|
-
key: "__processData",
|
853
|
-
value: function __processData() {
|
854
|
-
return processSeries(this, "datetime");
|
855
|
-
}
|
856
|
-
}, {
|
857
|
-
key: "__chartName",
|
858
|
-
value: function __chartName() {
|
859
|
-
return "LineChart";
|
565
|
+
datasets.push(merge(dataset, s.library || {}));
|
860
566
|
}
|
861
|
-
}]);
|
862
|
-
|
863
|
-
return LineChart;
|
864
|
-
}(Chart);
|
865
567
|
|
866
|
-
|
867
|
-
|
568
|
+
if (detectType && labels.length > 0) {
|
569
|
+
var minTime = labels[0].getTime();
|
570
|
+
var maxTime = labels[0].getTime();
|
571
|
+
for (i = 1; i < labels.length; i++) {
|
572
|
+
value = labels[i].getTime();
|
573
|
+
if (value < minTime) {
|
574
|
+
minTime = value;
|
575
|
+
}
|
576
|
+
if (value > maxTime) {
|
577
|
+
maxTime = value;
|
578
|
+
}
|
579
|
+
}
|
868
580
|
|
869
|
-
|
870
|
-
|
581
|
+
var timeDiff = (maxTime - minTime) / (86400 * 1000.0);
|
582
|
+
|
583
|
+
if (!options.scales.xAxes[0].time.unit) {
|
584
|
+
var step;
|
585
|
+
if (year || timeDiff > 365 * 10) {
|
586
|
+
options.scales.xAxes[0].time.unit = "year";
|
587
|
+
step = 365;
|
588
|
+
} else if (month || timeDiff > 30 * 10) {
|
589
|
+
options.scales.xAxes[0].time.unit = "month";
|
590
|
+
step = 30;
|
591
|
+
} else if (day || timeDiff > 10) {
|
592
|
+
options.scales.xAxes[0].time.unit = "day";
|
593
|
+
step = 1;
|
594
|
+
} else if (hour || timeDiff > 0.5) {
|
595
|
+
options.scales.xAxes[0].time.displayFormats = {hour: "MMM D, h a"};
|
596
|
+
options.scales.xAxes[0].time.unit = "hour";
|
597
|
+
step = 1 / 24.0;
|
598
|
+
} else if (minute) {
|
599
|
+
options.scales.xAxes[0].time.displayFormats = {minute: "h:mm a"};
|
600
|
+
options.scales.xAxes[0].time.unit = "minute";
|
601
|
+
step = 1 / 24.0 / 60.0;
|
602
|
+
}
|
871
603
|
|
872
|
-
|
873
|
-
|
604
|
+
if (step && timeDiff > 0) {
|
605
|
+
var unitStepSize = Math.ceil(timeDiff / step / (chart.element.offsetWidth / 100.0));
|
606
|
+
if (week && step === 1) {
|
607
|
+
unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
|
608
|
+
}
|
609
|
+
options.scales.xAxes[0].time.unitStepSize = unitStepSize;
|
610
|
+
}
|
611
|
+
}
|
874
612
|
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
613
|
+
if (!options.scales.xAxes[0].time.tooltipFormat) {
|
614
|
+
if (day) {
|
615
|
+
options.scales.xAxes[0].time.tooltipFormat = "ll";
|
616
|
+
} else if (hour) {
|
617
|
+
options.scales.xAxes[0].time.tooltipFormat = "MMM D, h a";
|
618
|
+
} else if (minute) {
|
619
|
+
options.scales.xAxes[0].time.tooltipFormat = "h:mm a";
|
620
|
+
}
|
621
|
+
}
|
884
622
|
}
|
885
|
-
}]);
|
886
|
-
|
887
|
-
return PieChart;
|
888
|
-
}(Chart);
|
889
623
|
|
890
|
-
var
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
_classCallCheck(this, ColumnChart);
|
624
|
+
var data = {
|
625
|
+
labels: labels,
|
626
|
+
datasets: datasets
|
627
|
+
};
|
895
628
|
|
896
|
-
return
|
897
|
-
}
|
629
|
+
return data;
|
630
|
+
};
|
898
631
|
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
return processSeries(this, "string");
|
632
|
+
var renderLineChart = function (chart, chartType) {
|
633
|
+
if (chart.options.xtype === "number") {
|
634
|
+
return renderScatterChart(chart, chartType, true);
|
903
635
|
}
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
636
|
+
|
637
|
+
var chartOptions = {};
|
638
|
+
// fix for https://github.com/chartjs/Chart.js/issues/2441
|
639
|
+
if (!chart.options.max && allZeros(chart.data)) {
|
640
|
+
chartOptions.max = 1;
|
908
641
|
}
|
909
|
-
}]);
|
910
642
|
|
911
|
-
|
912
|
-
|
643
|
+
var options = jsOptions(chart, merge(chartOptions, chart.options));
|
644
|
+
setFormatOptions(chart, options, chartType);
|
913
645
|
|
914
|
-
var
|
915
|
-
_inherits(BarChart, _Chart4);
|
646
|
+
var data = createDataTable(chart, options, chartType || "line");
|
916
647
|
|
917
|
-
|
918
|
-
_classCallCheck(this, BarChart);
|
648
|
+
options.scales.xAxes[0].type = chart.discrete ? "category" : "time";
|
919
649
|
|
920
|
-
|
921
|
-
}
|
650
|
+
drawChart(chart, "line", data, options);
|
651
|
+
};
|
922
652
|
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
653
|
+
var renderPieChart = function (chart) {
|
654
|
+
var options = merge({}, baseOptions);
|
655
|
+
if (chart.options.donut) {
|
656
|
+
options.cutoutPercentage = 50;
|
927
657
|
}
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
658
|
+
|
659
|
+
if ("legend" in chart.options) {
|
660
|
+
hideLegend(options, chart.options.legend);
|
661
|
+
}
|
662
|
+
|
663
|
+
if (chart.options.title) {
|
664
|
+
setTitle(options, chart.options.title);
|
932
665
|
}
|
933
|
-
}]);
|
934
666
|
|
935
|
-
|
936
|
-
|
667
|
+
options = merge(options, chart.options.library || {});
|
668
|
+
setFormatOptions(chart, options, "pie");
|
937
669
|
|
938
|
-
var
|
939
|
-
|
670
|
+
var labels = [];
|
671
|
+
var values = [];
|
672
|
+
for (var i = 0; i < chart.data.length; i++) {
|
673
|
+
var point = chart.data[i];
|
674
|
+
labels.push(point[0]);
|
675
|
+
values.push(point[1]);
|
676
|
+
}
|
940
677
|
|
941
|
-
|
942
|
-
|
678
|
+
var data = {
|
679
|
+
labels: labels,
|
680
|
+
datasets: [
|
681
|
+
{
|
682
|
+
data: values,
|
683
|
+
backgroundColor: chart.options.colors || defaultColors
|
684
|
+
}
|
685
|
+
]
|
686
|
+
};
|
943
687
|
|
944
|
-
|
945
|
-
}
|
688
|
+
drawChart(chart, "pie", data, options);
|
689
|
+
};
|
946
690
|
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
691
|
+
var renderColumnChart = function (chart, chartType) {
|
692
|
+
var options;
|
693
|
+
if (chartType === "bar") {
|
694
|
+
options = jsOptionsFunc(merge(baseOptions, defaultOptions), hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options);
|
695
|
+
} else {
|
696
|
+
options = jsOptions(chart, chart.options);
|
951
697
|
}
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
698
|
+
setFormatOptions(chart, options, chartType);
|
699
|
+
var data = createDataTable(chart, options, "column");
|
700
|
+
if (chartType !== "bar") {
|
701
|
+
setLabelSize(chart, data, options);
|
956
702
|
}
|
957
|
-
|
958
|
-
|
959
|
-
return AreaChart;
|
960
|
-
}(Chart);
|
703
|
+
drawChart(chart, (chartType === "bar" ? "horizontalBar" : "bar"), data, options);
|
704
|
+
};
|
961
705
|
|
962
|
-
var
|
963
|
-
|
706
|
+
var renderAreaChart = function (chart) {
|
707
|
+
renderLineChart(chart, "area");
|
708
|
+
};
|
964
709
|
|
965
|
-
function
|
966
|
-
|
710
|
+
var renderBarChart = function (chart) {
|
711
|
+
renderColumnChart(chart, "bar");
|
712
|
+
};
|
967
713
|
|
968
|
-
|
969
|
-
|
714
|
+
var renderScatterChart = function (chart, chartType, lineChart) {
|
715
|
+
chartType = chartType || "line";
|
970
716
|
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
return processSimple(this);
|
975
|
-
}
|
976
|
-
}, {
|
977
|
-
key: "__chartName",
|
978
|
-
value: function __chartName() {
|
979
|
-
return "GeoChart";
|
717
|
+
var options = jsOptions(chart, chart.options);
|
718
|
+
if (!lineChart) {
|
719
|
+
setFormatOptions(chart, options, chartType);
|
980
720
|
}
|
981
|
-
}]);
|
982
721
|
|
983
|
-
|
984
|
-
}(Chart);
|
722
|
+
var colors = chart.options.colors || defaultColors;
|
985
723
|
|
986
|
-
var
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
724
|
+
var datasets = [];
|
725
|
+
var series = chart.data;
|
726
|
+
for (var i = 0; i < series.length; i++) {
|
727
|
+
var s = series[i];
|
728
|
+
var d = [];
|
729
|
+
for (var j = 0; j < s.data.length; j++) {
|
730
|
+
var point = {
|
731
|
+
x: toFloat(s.data[j][0]),
|
732
|
+
y: toFloat(s.data[j][1])
|
733
|
+
};
|
734
|
+
if (chartType === "bubble") {
|
735
|
+
point.r = toFloat(s.data[j][2]);
|
736
|
+
}
|
737
|
+
d.push(point);
|
738
|
+
}
|
991
739
|
|
992
|
-
|
993
|
-
|
740
|
+
var color = s.color || colors[i];
|
741
|
+
var backgroundColor = chartType === "area" ? addOpacity(color, 0.5) : color;
|
994
742
|
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
743
|
+
datasets.push({
|
744
|
+
label: s.name,
|
745
|
+
showLine: lineChart || false,
|
746
|
+
data: d,
|
747
|
+
borderColor: color,
|
748
|
+
backgroundColor: backgroundColor,
|
749
|
+
pointBackgroundColor: color,
|
750
|
+
fill: chartType === "area"
|
751
|
+
});
|
999
752
|
}
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
return "ScatterChart";
|
753
|
+
|
754
|
+
if (chartType === "area") {
|
755
|
+
chartType = "line";
|
1004
756
|
}
|
1005
|
-
}]);
|
1006
757
|
|
1007
|
-
|
1008
|
-
}(Chart);
|
758
|
+
var data = {datasets: datasets};
|
1009
759
|
|
1010
|
-
|
1011
|
-
|
760
|
+
options.scales.xAxes[0].type = "linear";
|
761
|
+
options.scales.xAxes[0].position = "bottom";
|
1012
762
|
|
1013
|
-
|
1014
|
-
|
763
|
+
drawChart(chart, chartType, data, options);
|
764
|
+
};
|
1015
765
|
|
1016
|
-
|
1017
|
-
|
766
|
+
var renderBubbleChart = function (chart) {
|
767
|
+
renderScatterChart(chart, "bubble");
|
768
|
+
};
|
1018
769
|
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
770
|
+
var ChartjsAdapter = {
|
771
|
+
name: "chartjs",
|
772
|
+
renderLineChart: renderLineChart,
|
773
|
+
renderPieChart: renderPieChart,
|
774
|
+
renderColumnChart: renderColumnChart,
|
775
|
+
renderBarChart: renderBarChart,
|
776
|
+
renderAreaChart: renderAreaChart,
|
777
|
+
renderScatterChart: renderScatterChart,
|
778
|
+
renderBubbleChart: renderBubbleChart
|
779
|
+
};
|
780
|
+
|
781
|
+
var defaultOptions$1 = {
|
782
|
+
chart: {},
|
783
|
+
xAxis: {
|
784
|
+
title: {
|
785
|
+
text: null
|
786
|
+
},
|
787
|
+
labels: {
|
788
|
+
style: {
|
789
|
+
fontSize: "12px"
|
790
|
+
}
|
791
|
+
}
|
792
|
+
},
|
793
|
+
yAxis: {
|
794
|
+
title: {
|
795
|
+
text: null
|
796
|
+
},
|
797
|
+
labels: {
|
798
|
+
style: {
|
799
|
+
fontSize: "12px"
|
800
|
+
}
|
801
|
+
}
|
802
|
+
},
|
803
|
+
title: {
|
804
|
+
text: null
|
805
|
+
},
|
806
|
+
credits: {
|
807
|
+
enabled: false
|
808
|
+
},
|
809
|
+
legend: {
|
810
|
+
borderWidth: 0
|
811
|
+
},
|
812
|
+
tooltip: {
|
813
|
+
style: {
|
814
|
+
fontSize: "12px"
|
815
|
+
}
|
816
|
+
},
|
817
|
+
plotOptions: {
|
818
|
+
areaspline: {},
|
819
|
+
series: {
|
820
|
+
marker: {}
|
821
|
+
}
|
1023
822
|
}
|
1024
|
-
}
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
823
|
+
};
|
824
|
+
|
825
|
+
var hideLegend$1 = function (options, legend, hideLegend) {
|
826
|
+
if (legend !== undefined) {
|
827
|
+
options.legend.enabled = !!legend;
|
828
|
+
if (legend && legend !== true) {
|
829
|
+
if (legend === "top" || legend === "bottom") {
|
830
|
+
options.legend.verticalAlign = legend;
|
831
|
+
} else {
|
832
|
+
options.legend.layout = "vertical";
|
833
|
+
options.legend.verticalAlign = "middle";
|
834
|
+
options.legend.align = legend;
|
835
|
+
}
|
836
|
+
}
|
837
|
+
} else if (hideLegend) {
|
838
|
+
options.legend.enabled = false;
|
1028
839
|
}
|
1029
|
-
}
|
840
|
+
};
|
1030
841
|
|
1031
|
-
|
1032
|
-
|
842
|
+
var setTitle$1 = function (options, title) {
|
843
|
+
options.title.text = title;
|
844
|
+
};
|
1033
845
|
|
1034
|
-
var
|
1035
|
-
|
846
|
+
var setMin$1 = function (options, min) {
|
847
|
+
options.yAxis.min = min;
|
848
|
+
};
|
1036
849
|
|
1037
|
-
function
|
1038
|
-
|
850
|
+
var setMax$1 = function (options, max) {
|
851
|
+
options.yAxis.max = max;
|
852
|
+
};
|
1039
853
|
|
1040
|
-
|
1041
|
-
|
854
|
+
var setStacked$1 = function (options, stacked) {
|
855
|
+
options.plotOptions.series.stacking = stacked ? (stacked === true ? "normal" : stacked) : null;
|
856
|
+
};
|
1042
857
|
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
value: function __chartName() {
|
1057
|
-
return "Timeline";
|
858
|
+
var setXtitle$1 = function (options, title) {
|
859
|
+
options.xAxis.title.text = title;
|
860
|
+
};
|
861
|
+
|
862
|
+
var setYtitle$1 = function (options, title) {
|
863
|
+
options.yAxis.title.text = title;
|
864
|
+
};
|
865
|
+
|
866
|
+
var jsOptions$1 = jsOptionsFunc(defaultOptions$1, hideLegend$1, setTitle$1, setMin$1, setMax$1, setStacked$1, setXtitle$1, setYtitle$1);
|
867
|
+
|
868
|
+
var drawChart$1 = function(chart, data, options) {
|
869
|
+
if (chart.chart) {
|
870
|
+
chart.chart.destroy();
|
1058
871
|
}
|
1059
|
-
}]);
|
1060
872
|
|
1061
|
-
|
1062
|
-
|
873
|
+
options.chart.renderTo = chart.element.id;
|
874
|
+
options.series = data;
|
875
|
+
chart.chart = new window.Highcharts.Chart(options);
|
876
|
+
};
|
877
|
+
|
878
|
+
var setFormatOptions$1 = function(chart, options, chartType) {
|
879
|
+
var formatOptions = {
|
880
|
+
prefix: chart.options.prefix,
|
881
|
+
suffix: chart.options.suffix,
|
882
|
+
thousands: chart.options.thousands,
|
883
|
+
decimal: chart.options.decimal
|
884
|
+
};
|
1063
885
|
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
AreaChart: AreaChart,
|
1070
|
-
GeoChart: GeoChart,
|
1071
|
-
ScatterChart: ScatterChart,
|
1072
|
-
BubbleChart: BubbleChart,
|
1073
|
-
Timeline: Timeline,
|
1074
|
-
charts: {},
|
1075
|
-
configure: function configure(options) {
|
1076
|
-
for (var key in options) {
|
1077
|
-
if (options.hasOwnProperty(key)) {
|
1078
|
-
Chartkick.config[key] = options[key];
|
886
|
+
if (formatOptions.prefix || formatOptions.suffix || formatOptions.thousands || formatOptions.decimal) {
|
887
|
+
if (chartType !== "pie" && !options.yAxis.labels.formatter) {
|
888
|
+
options.yAxis.labels.formatter = function () {
|
889
|
+
return formatValue("", this.value, formatOptions);
|
890
|
+
};
|
1079
891
|
}
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
callback(Chartkick.charts[chartId]);
|
892
|
+
|
893
|
+
if (!options.tooltip.pointFormatter) {
|
894
|
+
options.tooltip.pointFormatter = function () {
|
895
|
+
return '<span style="color:' + this.color + '>\u25CF</span> ' + formatValue(this.series.name + ': <b>', this.y, formatOptions) + '</b><br/>';
|
896
|
+
};
|
1086
897
|
}
|
1087
898
|
}
|
1088
|
-
}
|
1089
|
-
config: config,
|
1090
|
-
options: {},
|
1091
|
-
adapters: adapters
|
1092
|
-
};
|
899
|
+
};
|
1093
900
|
|
1094
|
-
|
901
|
+
var renderLineChart$1 = function (chart, chartType) {
|
902
|
+
chartType = chartType || "spline";
|
903
|
+
var chartOptions = {};
|
904
|
+
if (chartType === "areaspline") {
|
905
|
+
chartOptions = {
|
906
|
+
plotOptions: {
|
907
|
+
areaspline: {
|
908
|
+
stacking: "normal"
|
909
|
+
},
|
910
|
+
area: {
|
911
|
+
stacking: "normal"
|
912
|
+
},
|
913
|
+
series: {
|
914
|
+
marker: {
|
915
|
+
enabled: false
|
916
|
+
}
|
917
|
+
}
|
918
|
+
}
|
919
|
+
};
|
920
|
+
}
|
1095
921
|
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
922
|
+
if (chart.options.curve === false) {
|
923
|
+
if (chartType === "areaspline") {
|
924
|
+
chartType = "area";
|
925
|
+
} else if (chartType === "spline") {
|
926
|
+
chartType = "line";
|
927
|
+
}
|
928
|
+
}
|
1099
929
|
|
1100
|
-
|
930
|
+
var options = jsOptions$1(chart, chart.options, chartOptions), data, i, j;
|
931
|
+
options.xAxis.type = chart.discrete ? "category" : "datetime";
|
932
|
+
if (!options.chart.type) {
|
933
|
+
options.chart.type = chartType;
|
934
|
+
}
|
935
|
+
setFormatOptions$1(chart, options, chartType);
|
1101
936
|
|
937
|
+
var series = chart.data;
|
938
|
+
for (i = 0; i < series.length; i++) {
|
939
|
+
data = series[i].data;
|
940
|
+
if (!chart.discrete) {
|
941
|
+
for (j = 0; j < data.length; j++) {
|
942
|
+
data[j][0] = data[j][0].getTime();
|
943
|
+
}
|
944
|
+
}
|
945
|
+
series[i].marker = {symbol: "circle"};
|
946
|
+
if (chart.options.points === false) {
|
947
|
+
series[i].marker.enabled = false;
|
948
|
+
}
|
949
|
+
}
|
950
|
+
|
951
|
+
drawChart$1(chart, series, options);
|
952
|
+
};
|
1102
953
|
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
954
|
+
var renderScatterChart$1 = function (chart) {
|
955
|
+
var options = jsOptions$1(chart, chart.options, {});
|
956
|
+
options.chart.type = "scatter";
|
957
|
+
drawChart$1(chart, chart.data, options);
|
958
|
+
};
|
1106
959
|
|
1107
|
-
var
|
960
|
+
var renderPieChart$1 = function (chart) {
|
961
|
+
var chartOptions = merge(defaultOptions$1, {});
|
1108
962
|
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
d = data[i].data;
|
1115
|
-
for (j = 0; j < d.length; j++) {
|
1116
|
-
if (d[j][1] != 0) {
|
1117
|
-
return false;
|
1118
|
-
}
|
963
|
+
if (chart.options.colors) {
|
964
|
+
chartOptions.colors = chart.options.colors;
|
965
|
+
}
|
966
|
+
if (chart.options.donut) {
|
967
|
+
chartOptions.plotOptions = {pie: {innerSize: "50%"}};
|
1119
968
|
}
|
1120
|
-
}
|
1121
|
-
return true;
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
var baseOptions = {
|
1125
|
-
maintainAspectRatio: false,
|
1126
|
-
animation: false,
|
1127
|
-
tooltips: {
|
1128
|
-
displayColors: false,
|
1129
|
-
callbacks: {}
|
1130
|
-
},
|
1131
|
-
legend: {},
|
1132
|
-
title: { fontSize: 20, fontColor: "#333" }
|
1133
|
-
};
|
1134
|
-
|
1135
|
-
var defaultOptions = {
|
1136
|
-
scales: {
|
1137
|
-
yAxes: [{
|
1138
|
-
ticks: {
|
1139
|
-
maxTicksLimit: 4
|
1140
|
-
},
|
1141
|
-
scaleLabel: {
|
1142
|
-
fontSize: 16,
|
1143
|
-
// fontStyle: "bold",
|
1144
|
-
fontColor: "#333"
|
1145
|
-
}
|
1146
|
-
}],
|
1147
|
-
xAxes: [{
|
1148
|
-
gridLines: {
|
1149
|
-
drawOnChartArea: false
|
1150
|
-
},
|
1151
|
-
scaleLabel: {
|
1152
|
-
fontSize: 16,
|
1153
|
-
// fontStyle: "bold",
|
1154
|
-
fontColor: "#333"
|
1155
|
-
},
|
1156
|
-
time: {},
|
1157
|
-
ticks: {}
|
1158
|
-
}]
|
1159
|
-
}
|
1160
|
-
};
|
1161
969
|
|
1162
|
-
|
1163
|
-
|
970
|
+
if ("legend" in chart.options) {
|
971
|
+
hideLegend$1(chartOptions, chart.options.legend);
|
972
|
+
}
|
1164
973
|
|
1165
|
-
|
1166
|
-
|
1167
|
-
options.legend.display = !!legend;
|
1168
|
-
if (legend && legend !== true) {
|
1169
|
-
options.legend.position = legend;
|
974
|
+
if (chart.options.title) {
|
975
|
+
setTitle$1(chartOptions, chart.options.title);
|
1170
976
|
}
|
1171
|
-
} else if (_hideLegend) {
|
1172
|
-
options.legend.display = false;
|
1173
|
-
}
|
1174
|
-
};
|
1175
977
|
|
1176
|
-
var
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
978
|
+
var options = merge(chartOptions, chart.options.library || {});
|
979
|
+
setFormatOptions$1(chart, options, "pie");
|
980
|
+
var series = [{
|
981
|
+
type: "pie",
|
982
|
+
name: chart.options.label || "Value",
|
983
|
+
data: chart.data
|
984
|
+
}];
|
1180
985
|
|
1181
|
-
|
1182
|
-
|
1183
|
-
options.scales.yAxes[0].ticks.min = (0, _helpers.toFloat)(min);
|
1184
|
-
}
|
1185
|
-
};
|
986
|
+
drawChart$1(chart, series, options);
|
987
|
+
};
|
1186
988
|
|
1187
|
-
var
|
1188
|
-
|
1189
|
-
|
989
|
+
var renderColumnChart$1 = function (chart, chartType) {
|
990
|
+
chartType = chartType || "column";
|
991
|
+
var series = chart.data;
|
992
|
+
var options = jsOptions$1(chart, chart.options), i, j, s, d, rows = [], categories = [];
|
993
|
+
options.chart.type = chartType;
|
994
|
+
setFormatOptions$1(chart, options, chartType);
|
1190
995
|
|
1191
|
-
|
1192
|
-
|
1193
|
-
options.scales.xAxes[0].ticks.min = (0, _helpers.toFloat)(min);
|
1194
|
-
}
|
1195
|
-
};
|
1196
|
-
|
1197
|
-
var setBarMax = function setBarMax(options, max) {
|
1198
|
-
options.scales.xAxes[0].ticks.max = (0, _helpers.toFloat)(max);
|
1199
|
-
};
|
1200
|
-
|
1201
|
-
var setStacked = function setStacked(options, stacked) {
|
1202
|
-
options.scales.xAxes[0].stacked = !!stacked;
|
1203
|
-
options.scales.yAxes[0].stacked = !!stacked;
|
1204
|
-
};
|
1205
|
-
|
1206
|
-
var setXtitle = function setXtitle(options, title) {
|
1207
|
-
options.scales.xAxes[0].scaleLabel.display = true;
|
1208
|
-
options.scales.xAxes[0].scaleLabel.labelString = title;
|
1209
|
-
};
|
1210
|
-
|
1211
|
-
var setYtitle = function setYtitle(options, title) {
|
1212
|
-
options.scales.yAxes[0].scaleLabel.display = true;
|
1213
|
-
options.scales.yAxes[0].scaleLabel.labelString = title;
|
1214
|
-
};
|
1215
|
-
|
1216
|
-
var drawChart = function drawChart(chart, type, data, options) {
|
1217
|
-
if (chart.chart) {
|
1218
|
-
chart.chart.destroy();
|
1219
|
-
} else {
|
1220
|
-
chart.element.innerHTML = "<canvas></canvas>";
|
1221
|
-
}
|
996
|
+
for (i = 0; i < series.length; i++) {
|
997
|
+
s = series[i];
|
1222
998
|
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
// http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
|
1232
|
-
var addOpacity = function addOpacity(hex, opacity) {
|
1233
|
-
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
1234
|
-
return result ? "rgba(" + parseInt(result[1], 16) + ", " + parseInt(result[2], 16) + ", " + parseInt(result[3], 16) + ", " + opacity + ")" : hex;
|
1235
|
-
};
|
1236
|
-
|
1237
|
-
var setLabelSize = function setLabelSize(chart, data, options) {
|
1238
|
-
var maxLabelSize = Math.ceil(chart.element.offsetWidth / 4.0 / data.labels.length);
|
1239
|
-
if (maxLabelSize > 25) {
|
1240
|
-
maxLabelSize = 25;
|
1241
|
-
}
|
1242
|
-
options.scales.xAxes[0].ticks.callback = function (value) {
|
1243
|
-
value = (0, _helpers.toStr)(value);
|
1244
|
-
if (value.length > maxLabelSize) {
|
1245
|
-
return value.substring(0, maxLabelSize - 2) + "...";
|
1246
|
-
} else {
|
1247
|
-
return value;
|
999
|
+
for (j = 0; j < s.data.length; j++) {
|
1000
|
+
d = s.data[j];
|
1001
|
+
if (!rows[d[0]]) {
|
1002
|
+
rows[d[0]] = new Array(series.length);
|
1003
|
+
categories.push(d[0]);
|
1004
|
+
}
|
1005
|
+
rows[d[0]][i] = d[1];
|
1006
|
+
}
|
1248
1007
|
}
|
1249
|
-
};
|
1250
|
-
};
|
1251
1008
|
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
decimal: chart.options.decimal
|
1258
|
-
};
|
1009
|
+
if (chart.options.xtype === "number") {
|
1010
|
+
categories.sort(sortByNumber);
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
options.xAxis.categories = categories;
|
1259
1014
|
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1015
|
+
var newSeries = [], d2;
|
1016
|
+
for (i = 0; i < series.length; i++) {
|
1017
|
+
d = [];
|
1018
|
+
for (j = 0; j < categories.length; j++) {
|
1019
|
+
d.push(rows[categories[j]][i] || 0);
|
1265
1020
|
}
|
1266
1021
|
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1022
|
+
d2 = {
|
1023
|
+
name: series[i].name,
|
1024
|
+
data: d
|
1025
|
+
};
|
1026
|
+
if (series[i].stack) {
|
1027
|
+
d2.stack = series[i].stack;
|
1271
1028
|
}
|
1029
|
+
|
1030
|
+
newSeries.push(d2);
|
1272
1031
|
}
|
1273
1032
|
|
1274
|
-
|
1275
|
-
|
1276
|
-
var valueLabel = chartType === "bar" ? "xLabel" : "yLabel";
|
1277
|
-
options.tooltips.callbacks.label = function (tooltipItem, data) {
|
1278
|
-
var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
1279
|
-
if (label) {
|
1280
|
-
label += ': ';
|
1281
|
-
}
|
1282
|
-
return (0, _helpers.formatValue)(label, tooltipItem[valueLabel], formatOptions);
|
1283
|
-
};
|
1284
|
-
} else {
|
1285
|
-
// need to use separate label for pie charts
|
1286
|
-
options.tooltips.callbacks.label = function (tooltipItem, data) {
|
1287
|
-
var dataLabel = data.labels[tooltipItem.index];
|
1288
|
-
var value = ': ';
|
1289
|
-
|
1290
|
-
if ((0, _helpers.isArray)(dataLabel)) {
|
1291
|
-
// show value on first line of multiline label
|
1292
|
-
// need to clone because we are changing the value
|
1293
|
-
dataLabel = dataLabel.slice();
|
1294
|
-
dataLabel[0] += value;
|
1295
|
-
} else {
|
1296
|
-
dataLabel += value;
|
1297
|
-
}
|
1033
|
+
drawChart$1(chart, newSeries, options);
|
1034
|
+
};
|
1298
1035
|
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
}
|
1303
|
-
}
|
1304
|
-
};
|
1036
|
+
var renderBarChart$1 = function (chart) {
|
1037
|
+
renderColumnChart$1(chart, "bar");
|
1038
|
+
};
|
1305
1039
|
|
1306
|
-
var
|
1040
|
+
var renderAreaChart$1 = function (chart) {
|
1041
|
+
renderLineChart$1(chart, "areaspline");
|
1042
|
+
};
|
1307
1043
|
|
1308
|
-
var
|
1309
|
-
|
1310
|
-
|
1044
|
+
var HighchartsAdapter = {
|
1045
|
+
name: "highcharts",
|
1046
|
+
renderLineChart: renderLineChart$1,
|
1047
|
+
renderPieChart: renderPieChart$1,
|
1048
|
+
renderColumnChart: renderColumnChart$1,
|
1049
|
+
renderBarChart: renderBarChart$1,
|
1050
|
+
renderAreaChart: renderAreaChart$1,
|
1051
|
+
renderScatterChart: renderScatterChart$1
|
1052
|
+
};
|
1311
1053
|
|
1312
|
-
var
|
1054
|
+
var loaded = {};
|
1055
|
+
var callbacks = [];
|
1056
|
+
|
1057
|
+
var runCallbacks = function () {
|
1058
|
+
var cb, call;
|
1059
|
+
for (var i = 0; i < callbacks.length; i++) {
|
1060
|
+
cb = callbacks[i];
|
1061
|
+
call = window.google.visualization && ((cb.pack === "corechart" && window.google.visualization.LineChart) || (cb.pack === "timeline" && window.google.visualization.Timeline));
|
1062
|
+
if (call) {
|
1063
|
+
cb.callback();
|
1064
|
+
callbacks.splice(i, 1);
|
1065
|
+
i--;
|
1066
|
+
}
|
1067
|
+
}
|
1068
|
+
};
|
1313
1069
|
|
1314
|
-
var
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
var hour = true;
|
1320
|
-
var minute = true;
|
1321
|
-
var detectType = (chartType === "line" || chartType === "area") && !chart.discrete;
|
1070
|
+
var waitForLoaded = function (chart, pack, callback) {
|
1071
|
+
if (!callback) {
|
1072
|
+
callback = pack;
|
1073
|
+
pack = "corechart";
|
1074
|
+
}
|
1322
1075
|
|
1323
|
-
|
1076
|
+
callbacks.push({pack: pack, callback: callback});
|
1324
1077
|
|
1325
|
-
|
1078
|
+
if (loaded[pack]) {
|
1079
|
+
runCallbacks();
|
1080
|
+
} else {
|
1081
|
+
loaded[pack] = true;
|
1326
1082
|
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1083
|
+
// https://groups.google.com/forum/#!topic/google-visualization-api/fMKJcyA2yyI
|
1084
|
+
var loadOptions = {
|
1085
|
+
packages: [pack],
|
1086
|
+
callback: runCallbacks
|
1087
|
+
};
|
1088
|
+
var config = chart.__config();
|
1089
|
+
if (config.language) {
|
1090
|
+
loadOptions.language = config.language;
|
1091
|
+
}
|
1092
|
+
if (pack === "corechart" && config.mapsApiKey) {
|
1093
|
+
loadOptions.mapsApiKey = config.mapsApiKey;
|
1094
|
+
}
|
1335
1095
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
rows[key] = new Array(series.length);
|
1096
|
+
if (window.google.setOnLoadCallback) {
|
1097
|
+
window.google.load("visualization", "1", loadOptions);
|
1098
|
+
} else {
|
1099
|
+
window.google.charts.load("current", loadOptions);
|
1341
1100
|
}
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1101
|
+
}
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
// Set chart options
|
1105
|
+
var defaultOptions$2 = {
|
1106
|
+
chartArea: {},
|
1107
|
+
fontName: "'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif",
|
1108
|
+
pointSize: 6,
|
1109
|
+
legend: {
|
1110
|
+
textStyle: {
|
1111
|
+
fontSize: 12,
|
1112
|
+
color: "#444"
|
1113
|
+
},
|
1114
|
+
alignment: "center",
|
1115
|
+
position: "right"
|
1116
|
+
},
|
1117
|
+
curveType: "function",
|
1118
|
+
hAxis: {
|
1119
|
+
textStyle: {
|
1120
|
+
color: "#666",
|
1121
|
+
fontSize: 12
|
1122
|
+
},
|
1123
|
+
titleTextStyle: {},
|
1124
|
+
gridlines: {
|
1125
|
+
color: "transparent"
|
1126
|
+
},
|
1127
|
+
baselineColor: "#ccc",
|
1128
|
+
viewWindow: {}
|
1129
|
+
},
|
1130
|
+
vAxis: {
|
1131
|
+
textStyle: {
|
1132
|
+
color: "#666",
|
1133
|
+
fontSize: 12
|
1134
|
+
},
|
1135
|
+
titleTextStyle: {},
|
1136
|
+
baselineColor: "#ccc",
|
1137
|
+
viewWindow: {}
|
1138
|
+
},
|
1139
|
+
tooltip: {
|
1140
|
+
textStyle: {
|
1141
|
+
color: "#666",
|
1142
|
+
fontSize: 12
|
1345
1143
|
}
|
1346
1144
|
}
|
1347
|
-
}
|
1145
|
+
};
|
1348
1146
|
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1147
|
+
var hideLegend$2 = function (options, legend, hideLegend) {
|
1148
|
+
if (legend !== undefined) {
|
1149
|
+
var position;
|
1150
|
+
if (!legend) {
|
1151
|
+
position = "none";
|
1152
|
+
} else if (legend === true) {
|
1153
|
+
position = "right";
|
1154
|
+
} else {
|
1155
|
+
position = legend;
|
1156
|
+
}
|
1157
|
+
options.legend.position = position;
|
1158
|
+
} else if (hideLegend) {
|
1159
|
+
options.legend.position = "none";
|
1160
|
+
}
|
1161
|
+
};
|
1352
1162
|
|
1353
|
-
var
|
1354
|
-
|
1355
|
-
|
1356
|
-
}
|
1163
|
+
var setTitle$2 = function (options, title) {
|
1164
|
+
options.title = title;
|
1165
|
+
options.titleTextStyle = {color: "#333", fontSize: "20px"};
|
1166
|
+
};
|
1357
1167
|
|
1358
|
-
var
|
1359
|
-
|
1360
|
-
|
1361
|
-
i = sortedLabels[k];
|
1362
|
-
if (detectType) {
|
1363
|
-
value = new Date((0, _helpers.toFloat)(i));
|
1364
|
-
// TODO make this efficient
|
1365
|
-
day = day && (0, _helpers.isDay)(value);
|
1366
|
-
if (!dayOfWeek) {
|
1367
|
-
dayOfWeek = value.getDay();
|
1368
|
-
}
|
1369
|
-
week = week && (0, _helpers.isWeek)(value, dayOfWeek);
|
1370
|
-
month = month && (0, _helpers.isMonth)(value);
|
1371
|
-
year = year && (0, _helpers.isYear)(value);
|
1372
|
-
hour = hour && (0, _helpers.isHour)(value);
|
1373
|
-
minute = minute && (0, _helpers.isMinute)(value);
|
1374
|
-
} else {
|
1375
|
-
value = i;
|
1376
|
-
}
|
1377
|
-
labels.push(value);
|
1378
|
-
for (j = 0; j < series.length; j++) {
|
1379
|
-
// Chart.js doesn't like undefined
|
1380
|
-
rows2[j].push(rows[i][j] === undefined ? null : rows[i][j]);
|
1381
|
-
}
|
1382
|
-
}
|
1168
|
+
var setMin$2 = function (options, min) {
|
1169
|
+
options.vAxis.viewWindow.min = min;
|
1170
|
+
};
|
1383
1171
|
|
1384
|
-
|
1385
|
-
|
1172
|
+
var setMax$2 = function (options, max) {
|
1173
|
+
options.vAxis.viewWindow.max = max;
|
1174
|
+
};
|
1386
1175
|
|
1387
|
-
|
1388
|
-
|
1176
|
+
var setBarMin$1 = function (options, min) {
|
1177
|
+
options.hAxis.viewWindow.min = min;
|
1178
|
+
};
|
1389
1179
|
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
fill: chartType === "area",
|
1394
|
-
borderColor: color,
|
1395
|
-
backgroundColor: backgroundColor,
|
1396
|
-
pointBackgroundColor: color,
|
1397
|
-
borderWidth: 2
|
1398
|
-
};
|
1180
|
+
var setBarMax$1 = function (options, max) {
|
1181
|
+
options.hAxis.viewWindow.max = max;
|
1182
|
+
};
|
1399
1183
|
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1184
|
+
var setStacked$2 = function (options, stacked) {
|
1185
|
+
options.isStacked = stacked ? stacked : false;
|
1186
|
+
};
|
1403
1187
|
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1188
|
+
var setXtitle$2 = function (options, title) {
|
1189
|
+
options.hAxis.title = title;
|
1190
|
+
options.hAxis.titleTextStyle.italic = false;
|
1191
|
+
};
|
1407
1192
|
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1193
|
+
var setYtitle$2 = function (options, title) {
|
1194
|
+
options.vAxis.title = title;
|
1195
|
+
options.vAxis.titleTextStyle.italic = false;
|
1196
|
+
};
|
1412
1197
|
|
1413
|
-
|
1414
|
-
}
|
1198
|
+
var jsOptions$2 = jsOptionsFunc(defaultOptions$2, hideLegend$2, setTitle$2, setMin$2, setMax$2, setStacked$2, setXtitle$2, setYtitle$2);
|
1415
1199
|
|
1416
|
-
|
1417
|
-
|
1418
|
-
var
|
1419
|
-
for (i =
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
var timeDiff = (maxTime - minTime) / (86400 * 1000.0);
|
1430
|
-
|
1431
|
-
if (!options.scales.xAxes[0].time.unit) {
|
1432
|
-
var step = void 0;
|
1433
|
-
if (year || timeDiff > 365 * 10) {
|
1434
|
-
options.scales.xAxes[0].time.unit = "year";
|
1435
|
-
step = 365;
|
1436
|
-
} else if (month || timeDiff > 30 * 10) {
|
1437
|
-
options.scales.xAxes[0].time.unit = "month";
|
1438
|
-
step = 30;
|
1439
|
-
} else if (day || timeDiff > 10) {
|
1440
|
-
options.scales.xAxes[0].time.unit = "day";
|
1441
|
-
step = 1;
|
1442
|
-
} else if (hour || timeDiff > 0.5) {
|
1443
|
-
options.scales.xAxes[0].time.displayFormats = { hour: "MMM D, h a" };
|
1444
|
-
options.scales.xAxes[0].time.unit = "hour";
|
1445
|
-
step = 1 / 24.0;
|
1446
|
-
} else if (minute) {
|
1447
|
-
options.scales.xAxes[0].time.displayFormats = { minute: "h:mm a" };
|
1448
|
-
options.scales.xAxes[0].time.unit = "minute";
|
1449
|
-
step = 1 / 24.0 / 60.0;
|
1450
|
-
}
|
1451
|
-
|
1452
|
-
if (step && timeDiff > 0) {
|
1453
|
-
var unitStepSize = Math.ceil(timeDiff / step / (chart.element.offsetWidth / 100.0));
|
1454
|
-
if (week && step === 1) {
|
1455
|
-
unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
|
1200
|
+
// cant use object as key
|
1201
|
+
var createDataTable$1 = function (series, columnType, xtype) {
|
1202
|
+
var i, j, s, d, key, rows = [], sortedLabels = [];
|
1203
|
+
for (i = 0; i < series.length; i++) {
|
1204
|
+
s = series[i];
|
1205
|
+
|
1206
|
+
for (j = 0; j < s.data.length; j++) {
|
1207
|
+
d = s.data[j];
|
1208
|
+
key = (columnType === "datetime") ? d[0].getTime() : d[0];
|
1209
|
+
if (!rows[key]) {
|
1210
|
+
rows[key] = new Array(series.length);
|
1211
|
+
sortedLabels.push(key);
|
1456
1212
|
}
|
1457
|
-
|
1213
|
+
rows[key][i] = toFloat(d[1]);
|
1458
1214
|
}
|
1459
1215
|
}
|
1460
1216
|
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1217
|
+
var rows2 = [];
|
1218
|
+
var day = true;
|
1219
|
+
var value;
|
1220
|
+
for (j = 0; j < sortedLabels.length; j++) {
|
1221
|
+
i = sortedLabels[j];
|
1222
|
+
if (columnType === "datetime") {
|
1223
|
+
value = new Date(toFloat(i));
|
1224
|
+
day = day && isDay(value);
|
1225
|
+
} else if (columnType === "number") {
|
1226
|
+
value = toFloat(i);
|
1227
|
+
} else {
|
1228
|
+
value = i;
|
1468
1229
|
}
|
1230
|
+
rows2.push([value].concat(rows[i]));
|
1231
|
+
}
|
1232
|
+
if (columnType === "datetime") {
|
1233
|
+
rows2.sort(sortByTime);
|
1234
|
+
} else if (columnType === "number") {
|
1235
|
+
rows2.sort(sortByNumberSeries);
|
1469
1236
|
}
|
1470
|
-
}
|
1471
1237
|
|
1472
|
-
|
1473
|
-
|
1474
|
-
datasets: datasets
|
1475
|
-
};
|
1238
|
+
if (xtype === "number") {
|
1239
|
+
rows2.sort(sortByNumberSeries);
|
1476
1240
|
|
1477
|
-
|
1478
|
-
|
1241
|
+
for (i = 0; i < rows2.length; i++) {
|
1242
|
+
rows2[i][0] = toStr(rows2[i][0]);
|
1243
|
+
}
|
1244
|
+
}
|
1479
1245
|
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1246
|
+
// create datatable
|
1247
|
+
var data = new window.google.visualization.DataTable();
|
1248
|
+
columnType = columnType === "datetime" && day ? "date" : columnType;
|
1249
|
+
data.addColumn(columnType, "");
|
1250
|
+
for (i = 0; i < series.length; i++) {
|
1251
|
+
data.addColumn("number", series[i].name);
|
1252
|
+
}
|
1253
|
+
data.addRows(rows2);
|
1484
1254
|
|
1485
|
-
|
1486
|
-
|
1487
|
-
// TODO fix area stacked
|
1488
|
-
// chartOptions.stacked = true;
|
1255
|
+
return data;
|
1256
|
+
};
|
1489
1257
|
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1258
|
+
var resize = function (callback) {
|
1259
|
+
if (window.attachEvent) {
|
1260
|
+
window.attachEvent("onresize", callback);
|
1261
|
+
} else if (window.addEventListener) {
|
1262
|
+
window.addEventListener("resize", callback, true);
|
1263
|
+
}
|
1264
|
+
callback();
|
1265
|
+
};
|
1494
1266
|
|
1495
|
-
var
|
1496
|
-
|
1267
|
+
var drawChart$2 = function(chart, type, data, options) {
|
1268
|
+
if (chart.chart) {
|
1269
|
+
chart.chart.clearChart();
|
1270
|
+
}
|
1497
1271
|
|
1498
|
-
|
1272
|
+
chart.chart = new type(chart.element);
|
1273
|
+
resize(function () {
|
1274
|
+
chart.chart.draw(data, options);
|
1275
|
+
});
|
1276
|
+
};
|
1499
1277
|
|
1500
|
-
|
1278
|
+
var renderLineChart$2 = function (chart) {
|
1279
|
+
waitForLoaded(chart, function () {
|
1280
|
+
var chartOptions = {};
|
1501
1281
|
|
1502
|
-
|
1503
|
-
|
1282
|
+
if (chart.options.curve === false) {
|
1283
|
+
chartOptions.curveType = "none";
|
1284
|
+
}
|
1504
1285
|
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
options.cutoutPercentage = 50;
|
1509
|
-
}
|
1286
|
+
if (chart.options.points === false) {
|
1287
|
+
chartOptions.pointSize = 0;
|
1288
|
+
}
|
1510
1289
|
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1290
|
+
var options = jsOptions$2(chart, chart.options, chartOptions);
|
1291
|
+
var columnType = chart.discrete ? "string" : "datetime";
|
1292
|
+
if (chart.options.xtype === "number") {
|
1293
|
+
columnType = "number";
|
1294
|
+
}
|
1295
|
+
var data = createDataTable$1(chart.data, columnType);
|
1514
1296
|
|
1515
|
-
|
1516
|
-
|
1517
|
-
}
|
1297
|
+
drawChart$2(chart, window.google.visualization.LineChart, data, options);
|
1298
|
+
});
|
1299
|
+
};
|
1518
1300
|
|
1519
|
-
|
1520
|
-
|
1301
|
+
var renderPieChart$2 = function (chart) {
|
1302
|
+
waitForLoaded(chart, function () {
|
1303
|
+
var chartOptions = {
|
1304
|
+
chartArea: {
|
1305
|
+
top: "10%",
|
1306
|
+
height: "80%"
|
1307
|
+
},
|
1308
|
+
legend: {}
|
1309
|
+
};
|
1310
|
+
if (chart.options.colors) {
|
1311
|
+
chartOptions.colors = chart.options.colors;
|
1312
|
+
}
|
1313
|
+
if (chart.options.donut) {
|
1314
|
+
chartOptions.pieHole = 0.5;
|
1315
|
+
}
|
1316
|
+
if ("legend" in chart.options) {
|
1317
|
+
hideLegend$2(chartOptions, chart.options.legend);
|
1318
|
+
}
|
1319
|
+
if (chart.options.title) {
|
1320
|
+
setTitle$2(chartOptions, chart.options.title);
|
1321
|
+
}
|
1322
|
+
var options = merge(merge(defaultOptions$2, chartOptions), chart.options.library || {});
|
1521
1323
|
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
labels.push(point[0]);
|
1527
|
-
values.push(point[1]);
|
1528
|
-
}
|
1324
|
+
var data = new window.google.visualization.DataTable();
|
1325
|
+
data.addColumn("string", "");
|
1326
|
+
data.addColumn("number", "Value");
|
1327
|
+
data.addRows(chart.data);
|
1529
1328
|
|
1530
|
-
|
1531
|
-
|
1532
|
-
datasets: [{
|
1533
|
-
data: values,
|
1534
|
-
backgroundColor: chart.options.colors || defaultColors
|
1535
|
-
}]
|
1329
|
+
drawChart$2(chart, window.google.visualization.PieChart, data, options);
|
1330
|
+
});
|
1536
1331
|
};
|
1537
1332
|
|
1538
|
-
|
1539
|
-
|
1333
|
+
var renderColumnChart$2 = function (chart) {
|
1334
|
+
waitForLoaded(chart, function () {
|
1335
|
+
var options = jsOptions$2(chart, chart.options);
|
1336
|
+
var data = createDataTable$1(chart.data, "string", chart.options.xtype);
|
1540
1337
|
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
options = (0, _helpers.jsOptionsFunc)((0, _helpers.merge)(baseOptions, defaultOptions), hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options);
|
1545
|
-
} else {
|
1546
|
-
options = jsOptions(chart, chart.options);
|
1547
|
-
}
|
1548
|
-
setFormatOptions(chart, options, chartType);
|
1549
|
-
var data = createDataTable(chart, options, "column");
|
1550
|
-
if (chartType !== "bar") {
|
1551
|
-
setLabelSize(chart, data, options);
|
1552
|
-
}
|
1553
|
-
drawChart(chart, chartType === "bar" ? "horizontalBar" : "bar", data, options);
|
1554
|
-
};
|
1338
|
+
drawChart$2(chart, window.google.visualization.ColumnChart, data, options);
|
1339
|
+
});
|
1340
|
+
};
|
1555
1341
|
|
1556
|
-
var
|
1557
|
-
|
1558
|
-
|
1342
|
+
var renderBarChart$2 = function (chart) {
|
1343
|
+
waitForLoaded(chart, function () {
|
1344
|
+
var chartOptions = {
|
1345
|
+
hAxis: {
|
1346
|
+
gridlines: {
|
1347
|
+
color: "#ccc"
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
};
|
1351
|
+
var options = jsOptionsFunc(defaultOptions$2, hideLegend$2, setTitle$2, setBarMin$1, setBarMax$1, setStacked$2, setXtitle$2, setYtitle$2)(chart, chart.options, chartOptions);
|
1352
|
+
var data = createDataTable$1(chart.data, "string", chart.options.xtype);
|
1559
1353
|
|
1560
|
-
|
1561
|
-
|
1562
|
-
};
|
1354
|
+
drawChart$2(chart, window.google.visualization.BarChart, data, options);
|
1355
|
+
});
|
1356
|
+
};
|
1563
1357
|
|
1564
|
-
var
|
1565
|
-
|
1358
|
+
var renderAreaChart$2 = function (chart) {
|
1359
|
+
waitForLoaded(chart, function () {
|
1360
|
+
var chartOptions = {
|
1361
|
+
isStacked: true,
|
1362
|
+
pointSize: 0,
|
1363
|
+
areaOpacity: 0.5
|
1364
|
+
};
|
1566
1365
|
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1366
|
+
var options = jsOptions$2(chart, chart.options, chartOptions);
|
1367
|
+
var columnType = chart.discrete ? "string" : "datetime";
|
1368
|
+
if (chart.options.xtype === "number") {
|
1369
|
+
columnType = "number";
|
1370
|
+
}
|
1371
|
+
var data = createDataTable$1(chart.data, columnType);
|
1571
1372
|
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1373
|
+
drawChart$2(chart, window.google.visualization.AreaChart, data, options);
|
1374
|
+
});
|
1375
|
+
};
|
1376
|
+
|
1377
|
+
var renderGeoChart = function (chart) {
|
1378
|
+
waitForLoaded(chart, function () {
|
1379
|
+
var chartOptions = {
|
1380
|
+
legend: "none",
|
1381
|
+
colorAxis: {
|
1382
|
+
colors: chart.options.colors || ["#f6c7b6", "#ce502d"]
|
1383
|
+
}
|
1583
1384
|
};
|
1584
|
-
|
1585
|
-
point.r = (0, _helpers.toFloat)(s.data[j][2]);
|
1586
|
-
}
|
1587
|
-
d.push(point);
|
1588
|
-
}
|
1385
|
+
var options = merge(merge(defaultOptions$2, chartOptions), chart.options.library || {});
|
1589
1386
|
|
1590
|
-
|
1591
|
-
|
1387
|
+
var data = new window.google.visualization.DataTable();
|
1388
|
+
data.addColumn("string", "");
|
1389
|
+
data.addColumn("number", chart.options.label || "Value");
|
1390
|
+
data.addRows(chart.data);
|
1592
1391
|
|
1593
|
-
|
1594
|
-
label: s.name,
|
1595
|
-
showLine: lineChart || false,
|
1596
|
-
data: d,
|
1597
|
-
borderColor: color,
|
1598
|
-
backgroundColor: backgroundColor,
|
1599
|
-
pointBackgroundColor: color,
|
1600
|
-
fill: chartType === "area"
|
1392
|
+
drawChart$2(chart, window.google.visualization.GeoChart, data, options);
|
1601
1393
|
});
|
1602
|
-
}
|
1394
|
+
};
|
1603
1395
|
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1396
|
+
var renderScatterChart$2 = function (chart) {
|
1397
|
+
waitForLoaded(chart, function () {
|
1398
|
+
var chartOptions = {};
|
1399
|
+
var options = jsOptions$2(chart, chart.options, chartOptions);
|
1400
|
+
|
1401
|
+
var series = chart.data, rows2 = [], i, j, data, d;
|
1402
|
+
for (i = 0; i < series.length; i++) {
|
1403
|
+
d = series[i].data;
|
1404
|
+
for (j = 0; j < d.length; j++) {
|
1405
|
+
var row = new Array(series.length + 1);
|
1406
|
+
row[0] = d[j][0];
|
1407
|
+
row[i + 1] = d[j][1];
|
1408
|
+
rows2.push(row);
|
1409
|
+
}
|
1410
|
+
}
|
1607
1411
|
|
1608
|
-
|
1412
|
+
data = new window.google.visualization.DataTable();
|
1413
|
+
data.addColumn("number", "");
|
1414
|
+
for (i = 0; i < series.length; i++) {
|
1415
|
+
data.addColumn("number", series[i].name);
|
1416
|
+
}
|
1417
|
+
data.addRows(rows2);
|
1609
1418
|
|
1610
|
-
|
1611
|
-
|
1419
|
+
drawChart$2(chart, window.google.visualization.ScatterChart, data, options);
|
1420
|
+
});
|
1421
|
+
};
|
1612
1422
|
|
1613
|
-
|
1614
|
-
|
1423
|
+
var renderTimeline = function (chart) {
|
1424
|
+
waitForLoaded(chart, "timeline", function () {
|
1425
|
+
var chartOptions = {
|
1426
|
+
legend: "none"
|
1427
|
+
};
|
1615
1428
|
|
1616
|
-
|
1617
|
-
|
1618
|
-
}
|
1429
|
+
if (chart.options.colors) {
|
1430
|
+
chartOptions.colors = chart.options.colors;
|
1431
|
+
}
|
1432
|
+
var options = merge(merge(defaultOptions$2, chartOptions), chart.options.library || {});
|
1619
1433
|
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
renderBarChart: renderBarChart,
|
1626
|
-
renderAreaChart: renderAreaChart,
|
1627
|
-
renderScatterChart: renderScatterChart,
|
1628
|
-
renderBubbleChart: renderBubbleChart
|
1629
|
-
};
|
1434
|
+
var data = new window.google.visualization.DataTable();
|
1435
|
+
data.addColumn({type: "string", id: "Name"});
|
1436
|
+
data.addColumn({type: "date", id: "Start"});
|
1437
|
+
data.addColumn({type: "date", id: "End"});
|
1438
|
+
data.addRows(chart.data);
|
1630
1439
|
|
1631
|
-
|
1632
|
-
/* 3 */
|
1633
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1440
|
+
chart.element.style.lineHeight = "normal";
|
1634
1441
|
|
1635
|
-
|
1442
|
+
drawChart$2(chart, window.google.visualization.Timeline, data, options);
|
1443
|
+
});
|
1444
|
+
};
|
1636
1445
|
|
1446
|
+
var GoogleChartsAdapter = {
|
1447
|
+
name: "google",
|
1448
|
+
renderLineChart: renderLineChart$2,
|
1449
|
+
renderPieChart: renderPieChart$2,
|
1450
|
+
renderColumnChart: renderColumnChart$2,
|
1451
|
+
renderBarChart: renderBarChart$2,
|
1452
|
+
renderAreaChart: renderAreaChart$2,
|
1453
|
+
renderScatterChart: renderScatterChart$2,
|
1454
|
+
renderGeoChart: renderGeoChart,
|
1455
|
+
renderTimeline: renderTimeline
|
1456
|
+
};
|
1637
1457
|
|
1638
|
-
|
1639
|
-
value: true
|
1640
|
-
});
|
1458
|
+
var pendingRequests = [], runningRequests = 0, maxRequests = 4;
|
1641
1459
|
|
1642
|
-
|
1460
|
+
function pushRequest(url, success, error) {
|
1461
|
+
pendingRequests.push([url, success, error]);
|
1462
|
+
runNext();
|
1463
|
+
}
|
1643
1464
|
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
style: {
|
1652
|
-
fontSize: "12px"
|
1465
|
+
function runNext() {
|
1466
|
+
if (runningRequests < maxRequests) {
|
1467
|
+
var request = pendingRequests.shift();
|
1468
|
+
if (request) {
|
1469
|
+
runningRequests++;
|
1470
|
+
getJSON(request[0], request[1], request[2]);
|
1471
|
+
runNext();
|
1653
1472
|
}
|
1654
1473
|
}
|
1655
|
-
},
|
1656
|
-
yAxis: {
|
1657
|
-
title: {
|
1658
|
-
text: null
|
1659
|
-
},
|
1660
|
-
labels: {
|
1661
|
-
style: {
|
1662
|
-
fontSize: "12px"
|
1663
|
-
}
|
1664
|
-
}
|
1665
|
-
},
|
1666
|
-
title: {
|
1667
|
-
text: null
|
1668
|
-
},
|
1669
|
-
credits: {
|
1670
|
-
enabled: false
|
1671
|
-
},
|
1672
|
-
legend: {
|
1673
|
-
borderWidth: 0
|
1674
|
-
},
|
1675
|
-
tooltip: {
|
1676
|
-
style: {
|
1677
|
-
fontSize: "12px"
|
1678
|
-
}
|
1679
|
-
},
|
1680
|
-
plotOptions: {
|
1681
|
-
areaspline: {},
|
1682
|
-
series: {
|
1683
|
-
marker: {}
|
1684
|
-
}
|
1685
1474
|
}
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1475
|
+
|
1476
|
+
function requestComplete() {
|
1477
|
+
runningRequests--;
|
1478
|
+
runNext();
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
function getJSON(url, success, error) {
|
1482
|
+
ajaxCall(url, success, function (jqXHR, textStatus, errorThrown) {
|
1483
|
+
var message = (typeof errorThrown === "string") ? errorThrown : errorThrown.message;
|
1484
|
+
error(message);
|
1485
|
+
});
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
function ajaxCall(url, success, error) {
|
1489
|
+
var $ = window.jQuery || window.Zepto || window.$;
|
1490
|
+
|
1491
|
+
if ($) {
|
1492
|
+
$.ajax({
|
1493
|
+
dataType: "json",
|
1494
|
+
url: url,
|
1495
|
+
success: success,
|
1496
|
+
error: error,
|
1497
|
+
complete: requestComplete
|
1498
|
+
});
|
1499
|
+
} else {
|
1500
|
+
var xhr = new XMLHttpRequest();
|
1501
|
+
xhr.open("GET", url, true);
|
1502
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
1503
|
+
xhr.onload = function () {
|
1504
|
+
requestComplete();
|
1505
|
+
if (xhr.status === 200) {
|
1506
|
+
success(JSON.parse(xhr.responseText), xhr.statusText, xhr);
|
1507
|
+
} else {
|
1508
|
+
error(xhr, "error", xhr.statusText);
|
1509
|
+
}
|
1510
|
+
};
|
1511
|
+
xhr.send();
|
1699
1512
|
}
|
1700
|
-
} else if (_hideLegend) {
|
1701
|
-
options.legend.enabled = false;
|
1702
1513
|
}
|
1703
|
-
};
|
1704
1514
|
|
1705
|
-
var
|
1706
|
-
|
1707
|
-
};
|
1515
|
+
var config = (typeof window !== "undefined" && window.Chartkick) || {};
|
1516
|
+
var adapters = [];
|
1708
1517
|
|
1709
|
-
|
1710
|
-
options.yAxis.min = min;
|
1711
|
-
};
|
1518
|
+
// helpers
|
1712
1519
|
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1520
|
+
function setText(element, text) {
|
1521
|
+
if (document.body.innerText) {
|
1522
|
+
element.innerText = text;
|
1523
|
+
} else {
|
1524
|
+
element.textContent = text;
|
1525
|
+
}
|
1526
|
+
}
|
1716
1527
|
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1528
|
+
function chartError(element, message) {
|
1529
|
+
setText(element, "Error Loading Chart: " + message);
|
1530
|
+
element.style.color = "#ff0000";
|
1531
|
+
}
|
1720
1532
|
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1533
|
+
function errorCatcher(chart) {
|
1534
|
+
try {
|
1535
|
+
chart.__render();
|
1536
|
+
} catch (err) {
|
1537
|
+
chartError(chart.element, err.message);
|
1538
|
+
throw err;
|
1539
|
+
}
|
1540
|
+
}
|
1724
1541
|
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1542
|
+
function fetchDataSource(chart, dataSource) {
|
1543
|
+
if (typeof dataSource === "string") {
|
1544
|
+
pushRequest(dataSource, function (data) {
|
1545
|
+
chart.rawData = data;
|
1546
|
+
errorCatcher(chart);
|
1547
|
+
}, function (message) {
|
1548
|
+
chartError(chart.element, message);
|
1549
|
+
});
|
1550
|
+
} else {
|
1551
|
+
chart.rawData = dataSource;
|
1552
|
+
errorCatcher(chart);
|
1553
|
+
}
|
1554
|
+
}
|
1728
1555
|
|
1729
|
-
|
1556
|
+
function addDownloadButton(chart) {
|
1557
|
+
var element = chart.element;
|
1558
|
+
var link = document.createElement("a");
|
1559
|
+
link.download = chart.options.download === true ? "chart.png" : chart.options.download; // http://caniuse.com/download
|
1560
|
+
link.style.position = "absolute";
|
1561
|
+
link.style.top = "20px";
|
1562
|
+
link.style.right = "20px";
|
1563
|
+
link.style.zIndex = 1000;
|
1564
|
+
link.style.lineHeight = "20px";
|
1565
|
+
link.target = "_blank"; // for safari
|
1566
|
+
var image = document.createElement("img");
|
1567
|
+
image.alt = "Download";
|
1568
|
+
image.style.border = "none";
|
1569
|
+
// icon from font-awesome
|
1570
|
+
// http://fa2png.io/
|
1571
|
+
image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABCFBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMywEsqxAAAAV3RSTlMAAQIDBggJCgsMDQ4PERQaHB0eISIjJCouLzE0OTo/QUJHSUpLTU5PUllhYmltcHh5foWLjI+SlaCio6atr7S1t7m6vsHHyM7R2tze5Obo7fHz9ff5+/1hlxK2AAAA30lEQVQYGUXBhVYCQQBA0TdYWAt2d3d3YWAHyur7/z9xgD16Lw0DW+XKx+1GgX+FRzM3HWQWrHl5N/oapW5RPe0PkBu+UYeICvozTWZVK23Ao04B79oJrOsJDOoxkZoQPWgX29pHpCZEk7rEvQYiNSFq1UMqvlCjJkRBS1R8hb00Vb/TajtBL7nTHE1X1vyMQF732dQhyF2o6SAwrzP06iUQzvwsArlnzcOdrgBhJyHa1QOgO9U1GsKuvjUTjavliZYQ8nNPapG6sap/3nrIdJ6bOWzmX/fy0XVpfzZP3S8OJT3g9EEiJwAAAABJRU5ErkJggg==";
|
1572
|
+
link.appendChild(image);
|
1573
|
+
element.style.position = "relative";
|
1574
|
+
|
1575
|
+
chart.downloadAttached = true;
|
1576
|
+
|
1577
|
+
// mouseenter
|
1578
|
+
addEvent(element, "mouseover", function(e) {
|
1579
|
+
var related = e.relatedTarget;
|
1580
|
+
// check download option again to ensure it wasn't changed
|
1581
|
+
if (!related || (related !== this && !childOf(this, related)) && chart.options.download) {
|
1582
|
+
link.href = chart.toImage();
|
1583
|
+
element.appendChild(link);
|
1584
|
+
}
|
1585
|
+
});
|
1730
1586
|
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1587
|
+
// mouseleave
|
1588
|
+
addEvent(element, "mouseout", function(e) {
|
1589
|
+
var related = e.relatedTarget;
|
1590
|
+
if (!related || (related !== this && !childOf(this, related))) {
|
1591
|
+
if (link.parentNode) {
|
1592
|
+
link.parentNode.removeChild(link);
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
});
|
1734
1596
|
}
|
1735
1597
|
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1598
|
+
// http://stackoverflow.com/questions/10149963/adding-event-listener-cross-browser
|
1599
|
+
function addEvent(elem, event, fn) {
|
1600
|
+
if (elem.addEventListener) {
|
1601
|
+
elem.addEventListener(event, fn, false);
|
1602
|
+
} else {
|
1603
|
+
elem.attachEvent("on" + event, function() {
|
1604
|
+
// set the this pointer same as addEventListener when fn is called
|
1605
|
+
return(fn.call(elem, window.event));
|
1606
|
+
});
|
1607
|
+
}
|
1608
|
+
}
|
1740
1609
|
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
};
|
1610
|
+
// https://gist.github.com/shawnbot/4166283
|
1611
|
+
function childOf(p, c) {
|
1612
|
+
if (p === c) { return false; }
|
1613
|
+
while (c && c !== p) { c = c.parentNode; }
|
1614
|
+
return c === p;
|
1615
|
+
}
|
1748
1616
|
|
1749
|
-
|
1750
|
-
if (
|
1751
|
-
|
1752
|
-
return (0, _helpers.formatValue)("", this.value, formatOptions);
|
1753
|
-
};
|
1617
|
+
function addAdapter(adapter) {
|
1618
|
+
if (adapters.indexOf(adapter) === -1) {
|
1619
|
+
adapters.push(adapter);
|
1754
1620
|
}
|
1621
|
+
}
|
1755
1622
|
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1623
|
+
function loadAdapters() {
|
1624
|
+
if ("Chart" in window) {
|
1625
|
+
addAdapter(ChartjsAdapter);
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
if ("Highcharts" in window) {
|
1629
|
+
addAdapter(HighchartsAdapter);
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
if (window.google && (window.google.setOnLoadCallback || window.google.charts)) {
|
1633
|
+
addAdapter(GoogleChartsAdapter);
|
1760
1634
|
}
|
1761
1635
|
}
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
areaspline: {
|
1771
|
-
stacking: "normal"
|
1772
|
-
},
|
1773
|
-
area: {
|
1774
|
-
stacking: "normal"
|
1775
|
-
},
|
1776
|
-
series: {
|
1777
|
-
marker: {
|
1778
|
-
enabled: false
|
1779
|
-
}
|
1636
|
+
|
1637
|
+
function dataEmpty(data, chartType) {
|
1638
|
+
if (chartType === "PieChart" || chartType === "GeoChart" || chartType === "Timeline") {
|
1639
|
+
return data.length === 0;
|
1640
|
+
} else {
|
1641
|
+
for (var i = 0; i < data.length; i++) {
|
1642
|
+
if (data[i].data.length > 0) {
|
1643
|
+
return false;
|
1780
1644
|
}
|
1781
1645
|
}
|
1782
|
-
|
1646
|
+
return true;
|
1647
|
+
}
|
1783
1648
|
}
|
1784
1649
|
|
1785
|
-
|
1786
|
-
if (
|
1787
|
-
|
1788
|
-
} else
|
1789
|
-
chartType
|
1650
|
+
function renderChart(chartType, chart) {
|
1651
|
+
if (chart.options.messages && chart.options.messages.empty && dataEmpty(chart.data, chartType)) {
|
1652
|
+
setText(chart.element, chart.options.messages.empty);
|
1653
|
+
} else {
|
1654
|
+
callAdapter(chartType, chart);
|
1655
|
+
if (chart.options.download && !chart.downloadAttached && chart.adapter === "chartjs") {
|
1656
|
+
addDownloadButton(chart);
|
1657
|
+
}
|
1790
1658
|
}
|
1791
1659
|
}
|
1792
1660
|
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
options.chart.type = chartType;
|
1800
|
-
}
|
1801
|
-
setFormatOptions(chart, options, chartType);
|
1661
|
+
// TODO remove chartType if cross-browser way
|
1662
|
+
// to get the name of the chart class
|
1663
|
+
function callAdapter(chartType, chart) {
|
1664
|
+
var i, adapter, fnName, adapterName;
|
1665
|
+
fnName = "render" + chartType;
|
1666
|
+
adapterName = chart.options.adapter;
|
1802
1667
|
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1668
|
+
loadAdapters();
|
1669
|
+
|
1670
|
+
for (i = 0; i < adapters.length; i++) {
|
1671
|
+
adapter = adapters[i];
|
1672
|
+
if ((!adapterName || adapterName === adapter.name) && isFunction(adapter[fnName])) {
|
1673
|
+
chart.adapter = adapter.name;
|
1674
|
+
return adapter[fnName](chart);
|
1809
1675
|
}
|
1810
1676
|
}
|
1811
|
-
|
1812
|
-
if (
|
1813
|
-
|
1677
|
+
|
1678
|
+
if (adapters.length > 0) {
|
1679
|
+
throw new Error("No charting library found for " + chartType);
|
1680
|
+
} else {
|
1681
|
+
throw new Error("No charting libraries found - be sure to include one before your charts");
|
1814
1682
|
}
|
1815
1683
|
}
|
1816
1684
|
|
1817
|
-
|
1818
|
-
};
|
1685
|
+
// process data
|
1819
1686
|
|
1820
|
-
var
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1687
|
+
var toFormattedKey = function (key, keyType) {
|
1688
|
+
if (keyType === "number") {
|
1689
|
+
key = toFloat(key);
|
1690
|
+
} else if (keyType === "datetime") {
|
1691
|
+
key = toDate(key);
|
1692
|
+
} else {
|
1693
|
+
key = toStr(key);
|
1694
|
+
}
|
1695
|
+
return key;
|
1696
|
+
};
|
1825
1697
|
|
1826
|
-
var
|
1827
|
-
|
1698
|
+
var formatSeriesData = function (data, keyType) {
|
1699
|
+
var r = [], key, j;
|
1700
|
+
for (j = 0; j < data.length; j++) {
|
1701
|
+
if (keyType === "bubble") {
|
1702
|
+
r.push([toFloat(data[j][0]), toFloat(data[j][1]), toFloat(data[j][2])]);
|
1703
|
+
} else {
|
1704
|
+
key = toFormattedKey(data[j][0], keyType);
|
1705
|
+
r.push([key, toFloat(data[j][1])]);
|
1706
|
+
}
|
1707
|
+
}
|
1708
|
+
if (keyType === "datetime") {
|
1709
|
+
r.sort(sortByTime);
|
1710
|
+
} else if (keyType === "number") {
|
1711
|
+
r.sort(sortByNumberSeries);
|
1712
|
+
}
|
1713
|
+
return r;
|
1714
|
+
};
|
1828
1715
|
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1716
|
+
function detectDiscrete(series) {
|
1717
|
+
var i, j, data;
|
1718
|
+
for (i = 0; i < series.length; i++) {
|
1719
|
+
data = toArr(series[i].data);
|
1720
|
+
for (j = 0; j < data.length; j++) {
|
1721
|
+
if (!isDate(data[j][0])) {
|
1722
|
+
return true;
|
1723
|
+
}
|
1724
|
+
}
|
1725
|
+
}
|
1726
|
+
return false;
|
1834
1727
|
}
|
1835
1728
|
|
1836
|
-
|
1837
|
-
|
1729
|
+
// creates a shallow copy of each element of the array
|
1730
|
+
// elements are expected to be objects
|
1731
|
+
function copySeries(series) {
|
1732
|
+
var newSeries = [], i, j;
|
1733
|
+
for (i = 0; i < series.length; i++) {
|
1734
|
+
var copy = {};
|
1735
|
+
for (j in series[i]) {
|
1736
|
+
if (series[i].hasOwnProperty(j)) {
|
1737
|
+
copy[j] = series[i][j];
|
1738
|
+
}
|
1739
|
+
}
|
1740
|
+
newSeries.push(copy);
|
1741
|
+
}
|
1742
|
+
return newSeries;
|
1838
1743
|
}
|
1839
1744
|
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1745
|
+
function processSeries(chart, keyType) {
|
1746
|
+
var i;
|
1747
|
+
|
1748
|
+
var opts = chart.options;
|
1749
|
+
var series = chart.rawData;
|
1843
1750
|
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
}];
|
1851
|
-
|
1852
|
-
drawChart(chart, series, options);
|
1853
|
-
};
|
1854
|
-
|
1855
|
-
var renderColumnChart = function renderColumnChart(chart, chartType) {
|
1856
|
-
chartType = chartType || "column";
|
1857
|
-
var series = chart.data;
|
1858
|
-
var options = jsOptions(chart, chart.options),
|
1859
|
-
i = void 0,
|
1860
|
-
j = void 0,
|
1861
|
-
s = void 0,
|
1862
|
-
d = void 0,
|
1863
|
-
rows = [],
|
1864
|
-
categories = [];
|
1865
|
-
options.chart.type = chartType;
|
1866
|
-
setFormatOptions(chart, options, chartType);
|
1867
|
-
|
1868
|
-
for (i = 0; i < series.length; i++) {
|
1869
|
-
s = series[i];
|
1870
|
-
|
1871
|
-
for (j = 0; j < s.data.length; j++) {
|
1872
|
-
d = s.data[j];
|
1873
|
-
if (!rows[d[0]]) {
|
1874
|
-
rows[d[0]] = new Array(series.length);
|
1875
|
-
categories.push(d[0]);
|
1876
|
-
}
|
1877
|
-
rows[d[0]][i] = d[1];
|
1751
|
+
// see if one series or multiple
|
1752
|
+
if (!isArray(series) || typeof series[0] !== "object" || isArray(series[0])) {
|
1753
|
+
series = [{name: opts.label || "Value", data: series}];
|
1754
|
+
chart.hideLegend = true;
|
1755
|
+
} else {
|
1756
|
+
chart.hideLegend = false;
|
1878
1757
|
}
|
1758
|
+
if ((opts.discrete === null || opts.discrete === undefined) && keyType !== "bubble" && keyType !== "number") {
|
1759
|
+
chart.discrete = detectDiscrete(series);
|
1760
|
+
} else {
|
1761
|
+
chart.discrete = opts.discrete;
|
1762
|
+
}
|
1763
|
+
if (chart.discrete) {
|
1764
|
+
keyType = "string";
|
1765
|
+
}
|
1766
|
+
if (chart.options.xtype) {
|
1767
|
+
keyType = chart.options.xtype;
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
// right format
|
1771
|
+
series = copySeries(series);
|
1772
|
+
for (i = 0; i < series.length; i++) {
|
1773
|
+
series[i].data = formatSeriesData(toArr(series[i].data), keyType);
|
1774
|
+
}
|
1775
|
+
|
1776
|
+
return series;
|
1879
1777
|
}
|
1880
1778
|
|
1881
|
-
|
1882
|
-
|
1779
|
+
function processSimple(chart) {
|
1780
|
+
var perfectData = toArr(chart.rawData), i;
|
1781
|
+
for (i = 0; i < perfectData.length; i++) {
|
1782
|
+
perfectData[i] = [toStr(perfectData[i][0]), toFloat(perfectData[i][1])];
|
1783
|
+
}
|
1784
|
+
return perfectData;
|
1883
1785
|
}
|
1884
1786
|
|
1885
|
-
|
1787
|
+
// define classes
|
1886
1788
|
|
1887
|
-
var
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1789
|
+
var Chart = function Chart(element, dataSource, options) {
|
1790
|
+
var elementId;
|
1791
|
+
if (typeof element === "string") {
|
1792
|
+
elementId = element;
|
1793
|
+
element = document.getElementById(element);
|
1794
|
+
if (!element) {
|
1795
|
+
throw new Error("No element with id " + elementId);
|
1796
|
+
}
|
1893
1797
|
}
|
1798
|
+
this.element = element;
|
1799
|
+
this.options = merge(Chartkick.options, options || {});
|
1800
|
+
this.dataSource = dataSource;
|
1894
1801
|
|
1895
|
-
|
1896
|
-
name: series[i].name,
|
1897
|
-
data: d
|
1898
|
-
};
|
1899
|
-
if (series[i].stack) {
|
1900
|
-
d2.stack = series[i].stack;
|
1901
|
-
}
|
1802
|
+
Chartkick.charts[element.id] = this;
|
1902
1803
|
|
1903
|
-
|
1904
|
-
}
|
1804
|
+
fetchDataSource(this, dataSource);
|
1905
1805
|
|
1906
|
-
|
1907
|
-
|
1806
|
+
if (this.options.refresh) {
|
1807
|
+
this.startRefresh();
|
1808
|
+
}
|
1809
|
+
};
|
1908
1810
|
|
1909
|
-
|
1910
|
-
|
1911
|
-
};
|
1811
|
+
Chart.prototype.getElement = function getElement () {
|
1812
|
+
return this.element;
|
1813
|
+
};
|
1912
1814
|
|
1913
|
-
|
1914
|
-
|
1915
|
-
};
|
1815
|
+
Chart.prototype.getDataSource = function getDataSource () {
|
1816
|
+
return this.dataSource;
|
1817
|
+
};
|
1916
1818
|
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
renderPieChart: renderPieChart,
|
1921
|
-
renderColumnChart: renderColumnChart,
|
1922
|
-
renderBarChart: renderBarChart,
|
1923
|
-
renderAreaChart: renderAreaChart,
|
1924
|
-
renderScatterChart: renderScatterChart
|
1925
|
-
};
|
1819
|
+
Chart.prototype.getData = function getData () {
|
1820
|
+
return this.data;
|
1821
|
+
};
|
1926
1822
|
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1823
|
+
Chart.prototype.getOptions = function getOptions () {
|
1824
|
+
return this.options;
|
1825
|
+
};
|
1930
1826
|
|
1931
|
-
|
1827
|
+
Chart.prototype.getChartObject = function getChartObject () {
|
1828
|
+
return this.chart;
|
1829
|
+
};
|
1932
1830
|
|
1831
|
+
Chart.prototype.getAdapter = function getAdapter () {
|
1832
|
+
return this.adapter;
|
1833
|
+
};
|
1933
1834
|
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1835
|
+
Chart.prototype.updateData = function updateData (dataSource, options) {
|
1836
|
+
this.dataSource = dataSource;
|
1837
|
+
if (options) {
|
1838
|
+
this.__updateOptions(options);
|
1839
|
+
}
|
1840
|
+
fetchDataSource(this, dataSource);
|
1841
|
+
};
|
1937
1842
|
|
1938
|
-
|
1843
|
+
Chart.prototype.setOptions = function setOptions (options) {
|
1844
|
+
this.__updateOptions(options);
|
1845
|
+
this.redraw();
|
1846
|
+
};
|
1939
1847
|
|
1940
|
-
|
1941
|
-
|
1848
|
+
Chart.prototype.redraw = function redraw () {
|
1849
|
+
fetchDataSource(this, this.rawData);
|
1850
|
+
};
|
1942
1851
|
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
if (call) {
|
1950
|
-
cb.callback();
|
1951
|
-
callbacks.splice(i, 1);
|
1952
|
-
i--;
|
1852
|
+
Chart.prototype.refreshData = function refreshData () {
|
1853
|
+
if (typeof this.dataSource === "string") {
|
1854
|
+
// prevent browser from caching
|
1855
|
+
var sep = this.dataSource.indexOf("?") === -1 ? "?" : "&";
|
1856
|
+
var url = this.dataSource + sep + "_=" + (new Date()).getTime();
|
1857
|
+
fetchDataSource(this, url);
|
1953
1858
|
}
|
1954
|
-
}
|
1955
|
-
};
|
1956
|
-
|
1957
|
-
var waitForLoaded = function waitForLoaded(pack, callback) {
|
1958
|
-
if (!callback) {
|
1959
|
-
callback = pack;
|
1960
|
-
pack = "corechart";
|
1961
|
-
}
|
1859
|
+
};
|
1962
1860
|
|
1963
|
-
|
1861
|
+
Chart.prototype.startRefresh = function startRefresh () {
|
1862
|
+
var this$1 = this;
|
1964
1863
|
|
1965
|
-
|
1966
|
-
runCallbacks();
|
1967
|
-
} else {
|
1968
|
-
loaded[pack] = true;
|
1864
|
+
var refresh = this.options.refresh;
|
1969
1865
|
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
}
|
1979
|
-
if (pack === "corechart" && config.mapsApiKey) {
|
1980
|
-
loadOptions.mapsApiKey = config.mapsApiKey;
|
1866
|
+
if (!this.intervalId) {
|
1867
|
+
if (refresh) {
|
1868
|
+
this.intervalId = setInterval( function () {
|
1869
|
+
this$1.refreshData();
|
1870
|
+
}, refresh * 1000);
|
1871
|
+
} else {
|
1872
|
+
throw new Error("No refresh interval");
|
1873
|
+
}
|
1981
1874
|
}
|
1875
|
+
};
|
1982
1876
|
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
}
|
1988
|
-
}
|
1989
|
-
};
|
1990
|
-
|
1991
|
-
// Set chart options
|
1992
|
-
var defaultOptions = {
|
1993
|
-
chartArea: {},
|
1994
|
-
fontName: "'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif",
|
1995
|
-
pointSize: 6,
|
1996
|
-
legend: {
|
1997
|
-
textStyle: {
|
1998
|
-
fontSize: 12,
|
1999
|
-
color: "#444"
|
2000
|
-
},
|
2001
|
-
alignment: "center",
|
2002
|
-
position: "right"
|
2003
|
-
},
|
2004
|
-
curveType: "function",
|
2005
|
-
hAxis: {
|
2006
|
-
textStyle: {
|
2007
|
-
color: "#666",
|
2008
|
-
fontSize: 12
|
2009
|
-
},
|
2010
|
-
titleTextStyle: {},
|
2011
|
-
gridlines: {
|
2012
|
-
color: "transparent"
|
2013
|
-
},
|
2014
|
-
baselineColor: "#ccc",
|
2015
|
-
viewWindow: {}
|
2016
|
-
},
|
2017
|
-
vAxis: {
|
2018
|
-
textStyle: {
|
2019
|
-
color: "#666",
|
2020
|
-
fontSize: 12
|
2021
|
-
},
|
2022
|
-
titleTextStyle: {},
|
2023
|
-
baselineColor: "#ccc",
|
2024
|
-
viewWindow: {}
|
2025
|
-
},
|
2026
|
-
tooltip: {
|
2027
|
-
textStyle: {
|
2028
|
-
color: "#666",
|
2029
|
-
fontSize: 12
|
1877
|
+
Chart.prototype.stopRefresh = function stopRefresh () {
|
1878
|
+
if (this.intervalId) {
|
1879
|
+
clearInterval(this.intervalId);
|
1880
|
+
this.intervalId = null;
|
2030
1881
|
}
|
2031
|
-
}
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
var position = void 0;
|
2037
|
-
if (!legend) {
|
2038
|
-
position = "none";
|
2039
|
-
} else if (legend === true) {
|
2040
|
-
position = "right";
|
1882
|
+
};
|
1883
|
+
|
1884
|
+
Chart.prototype.toImage = function toImage () {
|
1885
|
+
if (this.adapter === "chartjs") {
|
1886
|
+
return this.chart.toBase64Image();
|
2041
1887
|
} else {
|
2042
|
-
|
2043
|
-
}
|
2044
|
-
options.legend.position = position;
|
2045
|
-
} else if (_hideLegend) {
|
2046
|
-
options.legend.position = "none";
|
2047
|
-
}
|
2048
|
-
};
|
2049
|
-
|
2050
|
-
var setTitle = function setTitle(options, title) {
|
2051
|
-
options.title = title;
|
2052
|
-
options.titleTextStyle = { color: "#333", fontSize: "20px" };
|
2053
|
-
};
|
2054
|
-
|
2055
|
-
var setMin = function setMin(options, min) {
|
2056
|
-
options.vAxis.viewWindow.min = min;
|
2057
|
-
};
|
2058
|
-
|
2059
|
-
var setMax = function setMax(options, max) {
|
2060
|
-
options.vAxis.viewWindow.max = max;
|
2061
|
-
};
|
2062
|
-
|
2063
|
-
var setBarMin = function setBarMin(options, min) {
|
2064
|
-
options.hAxis.viewWindow.min = min;
|
2065
|
-
};
|
2066
|
-
|
2067
|
-
var setBarMax = function setBarMax(options, max) {
|
2068
|
-
options.hAxis.viewWindow.max = max;
|
2069
|
-
};
|
2070
|
-
|
2071
|
-
var setStacked = function setStacked(options, stacked) {
|
2072
|
-
options.isStacked = stacked ? stacked : false;
|
2073
|
-
};
|
2074
|
-
|
2075
|
-
var setXtitle = function setXtitle(options, title) {
|
2076
|
-
options.hAxis.title = title;
|
2077
|
-
options.hAxis.titleTextStyle.italic = false;
|
2078
|
-
};
|
2079
|
-
|
2080
|
-
var setYtitle = function setYtitle(options, title) {
|
2081
|
-
options.vAxis.title = title;
|
2082
|
-
options.vAxis.titleTextStyle.italic = false;
|
2083
|
-
};
|
2084
|
-
|
2085
|
-
var jsOptions = (0, _helpers.jsOptionsFunc)(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);
|
2086
|
-
|
2087
|
-
// cant use object as key
|
2088
|
-
var createDataTable = function createDataTable(series, columnType, xtype) {
|
2089
|
-
var i = void 0,
|
2090
|
-
j = void 0,
|
2091
|
-
s = void 0,
|
2092
|
-
d = void 0,
|
2093
|
-
key = void 0,
|
2094
|
-
rows = [],
|
2095
|
-
sortedLabels = [];
|
2096
|
-
for (i = 0; i < series.length; i++) {
|
2097
|
-
s = series[i];
|
2098
|
-
|
2099
|
-
for (j = 0; j < s.data.length; j++) {
|
2100
|
-
d = s.data[j];
|
2101
|
-
key = columnType === "datetime" ? d[0].getTime() : d[0];
|
2102
|
-
if (!rows[key]) {
|
2103
|
-
rows[key] = new Array(series.length);
|
2104
|
-
sortedLabels.push(key);
|
2105
|
-
}
|
2106
|
-
rows[key][i] = (0, _helpers.toFloat)(d[1]);
|
1888
|
+
return null;
|
2107
1889
|
}
|
2108
|
-
}
|
1890
|
+
};
|
2109
1891
|
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
value = new Date((0, _helpers.toFloat)(i));
|
2117
|
-
day = day && (0, _helpers.isDay)(value);
|
2118
|
-
} else if (columnType === "number") {
|
2119
|
-
value = (0, _helpers.toFloat)(i);
|
2120
|
-
} else {
|
2121
|
-
value = i;
|
1892
|
+
Chart.prototype.__updateOptions = function __updateOptions (options) {
|
1893
|
+
var updateRefresh = options.refresh && options.refresh !== this.options.refresh;
|
1894
|
+
this.options = merge(Chartkick.options, options);
|
1895
|
+
if (updateRefresh) {
|
1896
|
+
this.stopRefresh();
|
1897
|
+
this.startRefresh();
|
2122
1898
|
}
|
2123
|
-
|
2124
|
-
}
|
2125
|
-
if (columnType === "datetime") {
|
2126
|
-
rows2.sort(_helpers.sortByTime);
|
2127
|
-
} else if (columnType === "number") {
|
2128
|
-
rows2.sort(_helpers.sortByNumberSeries);
|
2129
|
-
}
|
1899
|
+
};
|
2130
1900
|
|
2131
|
-
|
2132
|
-
|
1901
|
+
Chart.prototype.__render = function __render () {
|
1902
|
+
this.data = this.__processData();
|
1903
|
+
renderChart(this.__chartName(), this);
|
1904
|
+
};
|
2133
1905
|
|
2134
|
-
|
2135
|
-
|
1906
|
+
Chart.prototype.__config = function __config () {
|
1907
|
+
return config;
|
1908
|
+
};
|
1909
|
+
|
1910
|
+
var LineChart = (function (Chart) {
|
1911
|
+
function LineChart () {
|
1912
|
+
Chart.apply(this, arguments);
|
2136
1913
|
}
|
2137
|
-
}
|
2138
1914
|
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
data.addColumn(columnType, "");
|
2143
|
-
for (i = 0; i < series.length; i++) {
|
2144
|
-
data.addColumn("number", series[i].name);
|
2145
|
-
}
|
2146
|
-
data.addRows(rows2);
|
1915
|
+
if ( Chart ) LineChart.__proto__ = Chart;
|
1916
|
+
LineChart.prototype = Object.create( Chart && Chart.prototype );
|
1917
|
+
LineChart.prototype.constructor = LineChart;
|
2147
1918
|
|
2148
|
-
|
2149
|
-
|
1919
|
+
LineChart.prototype.__processData = function __processData () {
|
1920
|
+
return processSeries(this, "datetime");
|
1921
|
+
};
|
2150
1922
|
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
} else if (window.addEventListener) {
|
2155
|
-
window.addEventListener("resize", callback, true);
|
2156
|
-
}
|
2157
|
-
callback();
|
2158
|
-
};
|
1923
|
+
LineChart.prototype.__chartName = function __chartName () {
|
1924
|
+
return "LineChart";
|
1925
|
+
};
|
2159
1926
|
|
2160
|
-
|
2161
|
-
|
2162
|
-
chart.chart.clearChart();
|
2163
|
-
}
|
1927
|
+
return LineChart;
|
1928
|
+
}(Chart));
|
2164
1929
|
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
};
|
1930
|
+
var PieChart = (function (Chart) {
|
1931
|
+
function PieChart () {
|
1932
|
+
Chart.apply(this, arguments);
|
1933
|
+
}
|
2170
1934
|
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
1935
|
+
if ( Chart ) PieChart.__proto__ = Chart;
|
1936
|
+
PieChart.prototype = Object.create( Chart && Chart.prototype );
|
1937
|
+
PieChart.prototype.constructor = PieChart;
|
2174
1938
|
|
2175
|
-
|
2176
|
-
|
2177
|
-
}
|
1939
|
+
PieChart.prototype.__processData = function __processData () {
|
1940
|
+
return processSimple(this);
|
1941
|
+
};
|
2178
1942
|
|
2179
|
-
|
2180
|
-
|
2181
|
-
}
|
1943
|
+
PieChart.prototype.__chartName = function __chartName () {
|
1944
|
+
return "PieChart";
|
1945
|
+
};
|
2182
1946
|
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
1947
|
+
return PieChart;
|
1948
|
+
}(Chart));
|
1949
|
+
|
1950
|
+
var ColumnChart = (function (Chart) {
|
1951
|
+
function ColumnChart () {
|
1952
|
+
Chart.apply(this, arguments);
|
2187
1953
|
}
|
2188
|
-
var data = createDataTable(chart.data, columnType);
|
2189
1954
|
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
1955
|
+
if ( Chart ) ColumnChart.__proto__ = Chart;
|
1956
|
+
ColumnChart.prototype = Object.create( Chart && Chart.prototype );
|
1957
|
+
ColumnChart.prototype.constructor = ColumnChart;
|
2193
1958
|
|
2194
|
-
|
2195
|
-
|
2196
|
-
var chartOptions = {
|
2197
|
-
chartArea: {
|
2198
|
-
top: "10%",
|
2199
|
-
height: "80%"
|
2200
|
-
},
|
2201
|
-
legend: {}
|
1959
|
+
ColumnChart.prototype.__processData = function __processData () {
|
1960
|
+
return processSeries(this, "string");
|
2202
1961
|
};
|
2203
|
-
if (chart.options.colors) {
|
2204
|
-
chartOptions.colors = chart.options.colors;
|
2205
|
-
}
|
2206
|
-
if (chart.options.donut) {
|
2207
|
-
chartOptions.pieHole = 0.5;
|
2208
|
-
}
|
2209
|
-
if ("legend" in chart.options) {
|
2210
|
-
hideLegend(chartOptions, chart.options.legend);
|
2211
|
-
}
|
2212
|
-
if (chart.options.title) {
|
2213
|
-
setTitle(chartOptions, chart.options.title);
|
2214
|
-
}
|
2215
|
-
var options = (0, _helpers.merge)((0, _helpers.merge)(defaultOptions, chartOptions), chart.options.library || {});
|
2216
1962
|
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
data.addRows(chart.data);
|
1963
|
+
ColumnChart.prototype.__chartName = function __chartName () {
|
1964
|
+
return "ColumnChart";
|
1965
|
+
};
|
2221
1966
|
|
2222
|
-
|
2223
|
-
});
|
2224
|
-
};
|
1967
|
+
return ColumnChart;
|
1968
|
+
}(Chart));
|
2225
1969
|
|
2226
|
-
var
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
var chartOptions = {
|
2238
|
-
hAxis: {
|
2239
|
-
gridlines: {
|
2240
|
-
color: "#ccc"
|
2241
|
-
}
|
2242
|
-
}
|
1970
|
+
var BarChart = (function (Chart) {
|
1971
|
+
function BarChart () {
|
1972
|
+
Chart.apply(this, arguments);
|
1973
|
+
}
|
1974
|
+
|
1975
|
+
if ( Chart ) BarChart.__proto__ = Chart;
|
1976
|
+
BarChart.prototype = Object.create( Chart && Chart.prototype );
|
1977
|
+
BarChart.prototype.constructor = BarChart;
|
1978
|
+
|
1979
|
+
BarChart.prototype.__processData = function __processData () {
|
1980
|
+
return processSeries(this, "string");
|
2243
1981
|
};
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
drawChart(chart, window.google.visualization.BarChart, data, options);
|
2248
|
-
});
|
2249
|
-
};
|
2250
|
-
|
2251
|
-
var renderAreaChart = function renderAreaChart(chart) {
|
2252
|
-
waitForLoaded(function () {
|
2253
|
-
var chartOptions = {
|
2254
|
-
isStacked: true,
|
2255
|
-
pointSize: 0,
|
2256
|
-
areaOpacity: 0.5
|
1982
|
+
|
1983
|
+
BarChart.prototype.__chartName = function __chartName () {
|
1984
|
+
return "BarChart";
|
2257
1985
|
};
|
2258
1986
|
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
1987
|
+
return BarChart;
|
1988
|
+
}(Chart));
|
1989
|
+
|
1990
|
+
var AreaChart = (function (Chart) {
|
1991
|
+
function AreaChart () {
|
1992
|
+
Chart.apply(this, arguments);
|
2263
1993
|
}
|
2264
|
-
var data = createDataTable(chart.data, columnType);
|
2265
1994
|
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
1995
|
+
if ( Chart ) AreaChart.__proto__ = Chart;
|
1996
|
+
AreaChart.prototype = Object.create( Chart && Chart.prototype );
|
1997
|
+
AreaChart.prototype.constructor = AreaChart;
|
2269
1998
|
|
2270
|
-
|
2271
|
-
|
2272
|
-
var chartOptions = {
|
2273
|
-
legend: "none",
|
2274
|
-
colorAxis: {
|
2275
|
-
colors: chart.options.colors || ["#f6c7b6", "#ce502d"]
|
2276
|
-
}
|
1999
|
+
AreaChart.prototype.__processData = function __processData () {
|
2000
|
+
return processSeries(this, "datetime");
|
2277
2001
|
};
|
2278
|
-
var options = (0, _helpers.merge)((0, _helpers.merge)(defaultOptions, chartOptions), chart.options.library || {});
|
2279
2002
|
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
data.addRows(chart.data);
|
2003
|
+
AreaChart.prototype.__chartName = function __chartName () {
|
2004
|
+
return "AreaChart";
|
2005
|
+
};
|
2284
2006
|
|
2285
|
-
|
2286
|
-
});
|
2287
|
-
};
|
2007
|
+
return AreaChart;
|
2008
|
+
}(Chart));
|
2288
2009
|
|
2289
|
-
var
|
2290
|
-
|
2291
|
-
|
2292
|
-
var options = jsOptions(chart, chart.options, chartOptions);
|
2293
|
-
|
2294
|
-
var series = chart.data,
|
2295
|
-
rows2 = [],
|
2296
|
-
i = void 0,
|
2297
|
-
j = void 0,
|
2298
|
-
data = void 0,
|
2299
|
-
d = void 0;
|
2300
|
-
for (i = 0; i < series.length; i++) {
|
2301
|
-
d = series[i].data;
|
2302
|
-
for (j = 0; j < d.length; j++) {
|
2303
|
-
var row = new Array(series.length + 1);
|
2304
|
-
row[0] = d[j][0];
|
2305
|
-
row[i + 1] = d[j][1];
|
2306
|
-
rows2.push(row);
|
2307
|
-
}
|
2010
|
+
var GeoChart = (function (Chart) {
|
2011
|
+
function GeoChart () {
|
2012
|
+
Chart.apply(this, arguments);
|
2308
2013
|
}
|
2309
2014
|
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2015
|
+
if ( Chart ) GeoChart.__proto__ = Chart;
|
2016
|
+
GeoChart.prototype = Object.create( Chart && Chart.prototype );
|
2017
|
+
GeoChart.prototype.constructor = GeoChart;
|
2018
|
+
|
2019
|
+
GeoChart.prototype.__processData = function __processData () {
|
2020
|
+
return processSimple(this);
|
2021
|
+
};
|
2022
|
+
|
2023
|
+
GeoChart.prototype.__chartName = function __chartName () {
|
2024
|
+
return "GeoChart";
|
2025
|
+
};
|
2026
|
+
|
2027
|
+
return GeoChart;
|
2028
|
+
}(Chart));
|
2029
|
+
|
2030
|
+
var ScatterChart = (function (Chart) {
|
2031
|
+
function ScatterChart () {
|
2032
|
+
Chart.apply(this, arguments);
|
2314
2033
|
}
|
2315
|
-
data.addRows(rows2);
|
2316
2034
|
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2035
|
+
if ( Chart ) ScatterChart.__proto__ = Chart;
|
2036
|
+
ScatterChart.prototype = Object.create( Chart && Chart.prototype );
|
2037
|
+
ScatterChart.prototype.constructor = ScatterChart;
|
2320
2038
|
|
2321
|
-
|
2322
|
-
|
2323
|
-
var chartOptions = {
|
2324
|
-
legend: "none"
|
2039
|
+
ScatterChart.prototype.__processData = function __processData () {
|
2040
|
+
return processSeries(this, "number");
|
2325
2041
|
};
|
2326
2042
|
|
2327
|
-
|
2328
|
-
|
2043
|
+
ScatterChart.prototype.__chartName = function __chartName () {
|
2044
|
+
return "ScatterChart";
|
2045
|
+
};
|
2046
|
+
|
2047
|
+
return ScatterChart;
|
2048
|
+
}(Chart));
|
2049
|
+
|
2050
|
+
var BubbleChart = (function (Chart) {
|
2051
|
+
function BubbleChart () {
|
2052
|
+
Chart.apply(this, arguments);
|
2329
2053
|
}
|
2330
|
-
var options = (0, _helpers.merge)((0, _helpers.merge)(defaultOptions, chartOptions), chart.options.library || {});
|
2331
2054
|
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
};
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
renderAreaChart: renderAreaChart,
|
2351
|
-
renderScatterChart: renderScatterChart,
|
2352
|
-
renderGeoChart: renderGeoChart,
|
2353
|
-
renderTimeline: renderTimeline
|
2354
|
-
};
|
2355
|
-
|
2356
|
-
/***/ }),
|
2357
|
-
/* 5 */
|
2358
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2359
|
-
|
2360
|
-
"use strict";
|
2361
|
-
|
2362
|
-
|
2363
|
-
Object.defineProperty(exports, "__esModule", {
|
2364
|
-
value: true
|
2365
|
-
});
|
2366
|
-
var pendingRequests = [],
|
2367
|
-
runningRequests = 0,
|
2368
|
-
maxRequests = 4;
|
2369
|
-
|
2370
|
-
function pushRequest(url, success, error) {
|
2371
|
-
pendingRequests.push([url, success, error]);
|
2372
|
-
runNext();
|
2373
|
-
}
|
2374
|
-
|
2375
|
-
function runNext() {
|
2376
|
-
if (runningRequests < maxRequests) {
|
2377
|
-
var request = pendingRequests.shift();
|
2378
|
-
if (request) {
|
2379
|
-
runningRequests++;
|
2380
|
-
getJSON(request[0], request[1], request[2]);
|
2381
|
-
runNext();
|
2055
|
+
if ( Chart ) BubbleChart.__proto__ = Chart;
|
2056
|
+
BubbleChart.prototype = Object.create( Chart && Chart.prototype );
|
2057
|
+
BubbleChart.prototype.constructor = BubbleChart;
|
2058
|
+
|
2059
|
+
BubbleChart.prototype.__processData = function __processData () {
|
2060
|
+
return processSeries(this, "bubble");
|
2061
|
+
};
|
2062
|
+
|
2063
|
+
BubbleChart.prototype.__chartName = function __chartName () {
|
2064
|
+
return "BubbleChart";
|
2065
|
+
};
|
2066
|
+
|
2067
|
+
return BubbleChart;
|
2068
|
+
}(Chart));
|
2069
|
+
|
2070
|
+
var Timeline = (function (Chart) {
|
2071
|
+
function Timeline () {
|
2072
|
+
Chart.apply(this, arguments);
|
2382
2073
|
}
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
var message = typeof errorThrown === "string" ? errorThrown : errorThrown.message;
|
2394
|
-
error(message);
|
2395
|
-
});
|
2396
|
-
}
|
2397
|
-
|
2398
|
-
function ajaxCall(url, success, error) {
|
2399
|
-
var $ = window.jQuery || window.Zepto || window.$;
|
2400
|
-
|
2401
|
-
if ($) {
|
2402
|
-
$.ajax({
|
2403
|
-
dataType: "json",
|
2404
|
-
url: url,
|
2405
|
-
success: success,
|
2406
|
-
error: error,
|
2407
|
-
complete: requestComplete
|
2408
|
-
});
|
2409
|
-
} else {
|
2410
|
-
var xhr = new XMLHttpRequest();
|
2411
|
-
xhr.open("GET", url, true);
|
2412
|
-
xhr.setRequestHeader("Content-Type", "application/json");
|
2413
|
-
xhr.onload = function () {
|
2414
|
-
requestComplete();
|
2415
|
-
if (xhr.status === 200) {
|
2416
|
-
success(JSON.parse(xhr.responseText), xhr.statusText, xhr);
|
2417
|
-
} else {
|
2418
|
-
error(xhr, "error", xhr.statusText);
|
2074
|
+
|
2075
|
+
if ( Chart ) Timeline.__proto__ = Chart;
|
2076
|
+
Timeline.prototype = Object.create( Chart && Chart.prototype );
|
2077
|
+
Timeline.prototype.constructor = Timeline;
|
2078
|
+
|
2079
|
+
Timeline.prototype.__processData = function __processData () {
|
2080
|
+
var i, data = this.rawData;
|
2081
|
+
for (i = 0; i < data.length; i++) {
|
2082
|
+
data[i][1] = toDate(data[i][1]);
|
2083
|
+
data[i][2] = toDate(data[i][2]);
|
2419
2084
|
}
|
2085
|
+
return data;
|
2420
2086
|
};
|
2421
|
-
xhr.send();
|
2422
|
-
}
|
2423
|
-
}
|
2424
2087
|
|
2425
|
-
|
2088
|
+
Timeline.prototype.__chartName = function __chartName () {
|
2089
|
+
return "Timeline";
|
2090
|
+
};
|
2091
|
+
|
2092
|
+
return Timeline;
|
2093
|
+
}(Chart));
|
2094
|
+
|
2095
|
+
var Chartkick = {
|
2096
|
+
LineChart: LineChart,
|
2097
|
+
PieChart: PieChart,
|
2098
|
+
ColumnChart: ColumnChart,
|
2099
|
+
BarChart: BarChart,
|
2100
|
+
AreaChart: AreaChart,
|
2101
|
+
GeoChart: GeoChart,
|
2102
|
+
ScatterChart: ScatterChart,
|
2103
|
+
BubbleChart: BubbleChart,
|
2104
|
+
Timeline: Timeline,
|
2105
|
+
charts: {},
|
2106
|
+
configure: function (options) {
|
2107
|
+
for (var key in options) {
|
2108
|
+
if (options.hasOwnProperty(key)) {
|
2109
|
+
config[key] = options[key];
|
2110
|
+
}
|
2111
|
+
}
|
2112
|
+
},
|
2113
|
+
eachChart: function (callback) {
|
2114
|
+
for (var chartId in Chartkick.charts) {
|
2115
|
+
if (Chartkick.charts.hasOwnProperty(chartId)) {
|
2116
|
+
callback(Chartkick.charts[chartId]);
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
},
|
2120
|
+
config: config,
|
2121
|
+
options: {},
|
2122
|
+
adapters: adapters
|
2123
|
+
};
|
2124
|
+
|
2125
|
+
return Chartkick;
|
2426
2126
|
|
2427
|
-
|
2428
|
-
/******/ ])["default"];
|
2429
|
-
});
|
2127
|
+
})));
|