ext_yarn 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +41 -47
  3. data/README.md +10 -0
  4. data/bin/yarn_after +12 -0
  5. data/lib/ext_yarn/version.rb +1 -1
  6. data/package.json +14 -13
  7. data/vendor/.yarn-integrity +35 -39
  8. data/vendor/bootswatch-sass/package.json +1 -1
  9. data/vendor/chart.js/dist/Chart.bundle.js +5754 -5711
  10. data/vendor/chart.js/dist/Chart.js +2118 -2046
  11. data/vendor/chart.js/package.json +1 -1
  12. data/vendor/chartkick/LICENSE.txt +1 -1
  13. data/vendor/chartkick/dist/chartkick.js +2239 -0
  14. data/vendor/chartkick/package.json +18 -8
  15. data/vendor/file-saver/dist/FileSaver.js +180 -0
  16. data/vendor/file-saver/package.json +16 -4
  17. data/vendor/jquery/dist/jquery.js +453 -342
  18. data/vendor/jquery/dist/jquery.slim.js +428 -319
  19. data/vendor/jquery/package.json +32 -21
  20. data/vendor/{tempusdominus-bootstrap-4 → jquery-touch-events}/LICENSE +21 -21
  21. data/vendor/jquery-touch-events/package.json +32 -0
  22. data/vendor/jquery-touch-events/src/jquery.mobile-events.js +920 -0
  23. data/vendor/jquery-ui-touch-punch-zoom-fork/jquery.ui.touch-punch.js +186 -0
  24. data/vendor/jquery-ujs/package.json +1 -1
  25. data/vendor/jquery-ujs/src/rails.js +14 -4
  26. data/vendor/{bootswatch → jquery.iframe-transport}/LICENSE +2 -2
  27. data/vendor/jquery.iframe-transport/jquery.iframe-transport.js +247 -0
  28. data/vendor/jquery.iframe-transport/package.json +28 -0
  29. data/vendor/jstz/dist/jstz.js +9 -1
  30. data/vendor/jstz/package.json +6 -4
  31. data/vendor/lazysizes/LICENSE +22 -0
  32. data/vendor/lazysizes/lazysizes-umd.js +706 -0
  33. data/vendor/lazysizes/lazysizes.js +703 -0
  34. data/vendor/lazysizes/package.json +65 -0
  35. data/vendor/lazysizes/plugins/artdirect/ls.artdirect.js +160 -0
  36. data/vendor/lazysizes/plugins/aspectratio/ls.aspectratio.js +209 -0
  37. data/vendor/lazysizes/plugins/attrchange/ls.attrchange.js +129 -0
  38. data/vendor/lazysizes/plugins/bgset/ls.bgset.js +198 -0
  39. data/vendor/lazysizes/plugins/blur-up/ls.blur-up.js +191 -0
  40. data/vendor/lazysizes/plugins/custommedia/ls.custommedia.js +75 -0
  41. data/vendor/lazysizes/plugins/fix-ios-sizes/fix-ios-sizes.js +80 -0
  42. data/vendor/lazysizes/plugins/include/ls.include.js +589 -0
  43. data/vendor/lazysizes/plugins/noscript/ls.noscript.js +87 -0
  44. data/vendor/lazysizes/plugins/object-fit/ls.object-fit.js +149 -0
  45. data/vendor/lazysizes/plugins/optimumx/ls.optimumx.js +273 -0
  46. data/vendor/lazysizes/plugins/parent-fit/ls.parent-fit.js +157 -0
  47. data/vendor/lazysizes/plugins/print/ls.print.js +51 -0
  48. data/vendor/lazysizes/plugins/progressive/ls.progressive.js +49 -0
  49. data/vendor/lazysizes/plugins/respimg/ls.respimg.js +314 -0
  50. data/vendor/lazysizes/plugins/rias/ls.rias.js +391 -0
  51. data/vendor/lazysizes/plugins/static-gecko-picture/ls.static-gecko-picture.js +82 -0
  52. data/vendor/lazysizes/plugins/twitter/ls.twitter.js +63 -0
  53. data/vendor/lazysizes/plugins/unload/ls.unload.js +155 -0
  54. data/vendor/lazysizes/plugins/unveilhooks/ls.unveilhooks.js +145 -0
  55. data/vendor/lazysizes/plugins/video-embed/ls.video-embed.js +114 -0
  56. data/vendor/lodash/core.js +75 -57
  57. data/vendor/lodash/lodash.js +105 -82
  58. data/vendor/lodash/package.json +2 -2
  59. data/vendor/moment/locale/af.js +58 -60
  60. data/vendor/moment/locale/ar-dz.js +45 -47
  61. data/vendor/moment/locale/ar-kw.js +45 -47
  62. data/vendor/moment/locale/ar-ly.js +106 -112
  63. data/vendor/moment/locale/ar-ma.js +45 -48
  64. data/vendor/moment/locale/ar-sa.js +88 -91
  65. data/vendor/moment/locale/ar-tn.js +45 -47
  66. data/vendor/moment/locale/ar.js +119 -128
  67. data/vendor/moment/locale/az.js +89 -91
  68. data/vendor/moment/locale/be.js +111 -115
  69. data/vendor/moment/locale/bg.js +73 -75
  70. data/vendor/moment/locale/bm.js +44 -47
  71. data/vendor/moment/locale/bn.js +103 -105
  72. data/vendor/moment/locale/bo.js +103 -105
  73. data/vendor/moment/locale/br.js +88 -90
  74. data/vendor/moment/locale/bs.js +133 -136
  75. data/vendor/moment/locale/ca.js +68 -70
  76. data/vendor/moment/locale/cs.js +160 -162
  77. data/vendor/moment/locale/cv.js +48 -50
  78. data/vendor/moment/locale/cy.js +64 -67
  79. data/vendor/moment/locale/da.js +46 -48
  80. data/vendor/moment/locale/de-at.js +61 -66
  81. data/vendor/moment/locale/de-ch.js +61 -65
  82. data/vendor/moment/locale/de.js +61 -65
  83. data/vendor/moment/locale/dv.js +82 -85
  84. data/vendor/moment/locale/el.js +82 -84
  85. data/vendor/moment/locale/en-au.js +53 -55
  86. data/vendor/moment/locale/en-ca.js +49 -51
  87. data/vendor/moment/locale/en-gb.js +53 -55
  88. data/vendor/moment/locale/en-ie.js +53 -55
  89. data/vendor/moment/locale/en-il.js +61 -0
  90. data/vendor/moment/locale/en-nz.js +53 -55
  91. data/vendor/moment/locale/eo.js +56 -60
  92. data/vendor/moment/locale/es-do.js +72 -73
  93. data/vendor/moment/locale/es-us.js +64 -66
  94. data/vendor/moment/locale/es.js +72 -74
  95. data/vendor/moment/locale/et.js +64 -67
  96. data/vendor/moment/locale/eu.js +52 -54
  97. data/vendor/moment/locale/fa.js +90 -93
  98. data/vendor/moment/locale/fi.js +93 -95
  99. data/vendor/moment/locale/fo.js +46 -48
  100. data/vendor/moment/locale/fr-ca.js +58 -60
  101. data/vendor/moment/locale/fr-ch.js +62 -64
  102. data/vendor/moment/locale/fr.js +66 -68
  103. data/vendor/moment/locale/fy.js +59 -61
  104. data/vendor/moment/locale/gd.js +57 -59
  105. data/vendor/moment/locale/gl.js +60 -62
  106. data/vendor/moment/locale/gom-latn.js +107 -109
  107. data/vendor/moment/locale/gu.js +108 -110
  108. data/vendor/moment/locale/he.js +77 -81
  109. data/vendor/moment/locale/hi.js +108 -110
  110. data/vendor/moment/locale/hr.js +136 -138
  111. data/vendor/moment/locale/hu.js +92 -94
  112. data/vendor/moment/locale/hy-am.js +78 -80
  113. data/vendor/moment/locale/id.js +67 -70
  114. data/vendor/moment/locale/is.js +110 -112
  115. data/vendor/moment/locale/it.js +53 -56
  116. data/vendor/moment/locale/ja.js +77 -67
  117. data/vendor/moment/locale/jv.js +67 -70
  118. data/vendor/moment/locale/ka.js +70 -72
  119. data/vendor/moment/locale/kk.js +72 -74
  120. data/vendor/moment/locale/km.js +96 -46
  121. data/vendor/moment/locale/kn.js +110 -112
  122. data/vendor/moment/locale/ko.js +66 -69
  123. data/vendor/moment/locale/ky.js +72 -75
  124. data/vendor/moment/locale/lb.js +113 -116
  125. data/vendor/moment/locale/lo.js +55 -57
  126. data/vendor/moment/locale/lt.js +100 -102
  127. data/vendor/moment/locale/lv.js +81 -84
  128. data/vendor/moment/locale/me.js +93 -95
  129. data/vendor/moment/locale/mi.js +50 -52
  130. data/vendor/moment/locale/mk.js +73 -75
  131. data/vendor/moment/locale/ml.js +66 -68
  132. data/vendor/moment/locale/mn.js +103 -0
  133. data/vendor/moment/locale/mr.js +140 -143
  134. data/vendor/moment/locale/ms-my.js +67 -70
  135. data/vendor/moment/locale/ms.js +67 -69
  136. data/vendor/moment/locale/mt.js +46 -48
  137. data/vendor/moment/locale/my.js +77 -82
  138. data/vendor/moment/locale/nb.js +48 -51
  139. data/vendor/moment/locale/ne.js +107 -109
  140. data/vendor/moment/locale/nl-be.js +68 -71
  141. data/vendor/moment/locale/nl.js +68 -71
  142. data/vendor/moment/locale/nn.js +46 -48
  143. data/vendor/moment/locale/pa-in.js +108 -110
  144. data/vendor/moment/locale/pl.js +104 -106
  145. data/vendor/moment/locale/pt-br.js +46 -48
  146. data/vendor/moment/locale/pt.js +50 -52
  147. data/vendor/moment/locale/ro.js +59 -62
  148. data/vendor/moment/locale/ru.js +153 -157
  149. data/vendor/moment/locale/sd.js +82 -84
  150. data/vendor/moment/locale/se.js +46 -49
  151. data/vendor/moment/locale/si.js +56 -58
  152. data/vendor/moment/locale/sk.js +138 -141
  153. data/vendor/moment/locale/sl.js +154 -156
  154. data/vendor/moment/locale/sq.js +54 -58
  155. data/vendor/moment/locale/sr-cyrl.js +93 -95
  156. data/vendor/moment/locale/sr.js +93 -95
  157. data/vendor/moment/locale/ss.js +72 -75
  158. data/vendor/moment/locale/sv.js +55 -57
  159. data/vendor/moment/locale/sw.js +45 -47
  160. data/vendor/moment/locale/ta.js +113 -116
  161. data/vendor/moment/locale/te.js +74 -76
  162. data/vendor/moment/locale/tet.js +53 -56
  163. data/vendor/moment/locale/tg.js +115 -0
  164. data/vendor/moment/locale/th.js +52 -54
  165. data/vendor/moment/locale/tl-ph.js +48 -50
  166. data/vendor/moment/locale/tlh.js +101 -103
  167. data/vendor/moment/locale/tr.js +80 -78
  168. data/vendor/moment/locale/tzl.js +75 -78
  169. data/vendor/moment/locale/tzm-latn.js +44 -46
  170. data/vendor/moment/locale/tzm.js +44 -46
  171. data/vendor/moment/locale/ug-cn.js +118 -0
  172. data/vendor/moment/locale/uk.js +129 -132
  173. data/vendor/moment/locale/ur.js +82 -85
  174. data/vendor/moment/locale/uz-latn.js +44 -46
  175. data/vendor/moment/locale/uz.js +44 -46
  176. data/vendor/moment/locale/vi.js +64 -66
  177. data/vendor/moment/locale/x-pseudo.js +54 -56
  178. data/vendor/moment/locale/yo.js +46 -48
  179. data/vendor/moment/locale/zh-cn.js +95 -98
  180. data/vendor/moment/locale/zh-hk.js +88 -92
  181. data/vendor/moment/locale/zh-tw.js +88 -91
  182. data/vendor/moment/min/locales.js +9701 -9581
  183. data/vendor/moment/min/moment-with-locales.js +13426 -13335
  184. data/vendor/moment/moment.js +3780 -3809
  185. data/vendor/moment/package.json +10 -10
  186. data/vendor/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +43 -35
  187. data/vendor/moment-timezone/builds/moment-timezone-with-data.js +290 -282
  188. data/vendor/moment-timezone/moment-timezone-utils.js +12 -10
  189. data/vendor/moment-timezone/moment-timezone.js +15 -7
  190. data/vendor/moment-timezone/package.json +5 -3
  191. data/vendor/{bootstrap → pako}/LICENSE +2 -3
  192. data/vendor/pako/dist/pako.js +6811 -0
  193. data/vendor/pako/dist/pako_deflate.js +3995 -0
  194. data/vendor/pako/dist/pako_inflate.js +3295 -0
  195. data/vendor/pako/package.json +48 -0
  196. data/yarn.lock +51 -78
  197. metadata +45 -155
  198. data/vendor/bootstrap/dist/js/bootstrap.bundle.js +0 -6461
  199. data/vendor/bootstrap/dist/js/bootstrap.js +0 -3944
  200. data/vendor/bootstrap/js/dist/alert.js +0 -204
  201. data/vendor/bootstrap/js/dist/button.js +0 -192
  202. data/vendor/bootstrap/js/dist/carousel.js +0 -567
  203. data/vendor/bootstrap/js/dist/collapse.js +0 -431
  204. data/vendor/bootstrap/js/dist/dropdown.js +0 -552
  205. data/vendor/bootstrap/js/dist/index.js +0 -23
  206. data/vendor/bootstrap/js/dist/modal.js +0 -634
  207. data/vendor/bootstrap/js/dist/popover.js +0 -266
  208. data/vendor/bootstrap/js/dist/scrollspy.js +0 -379
  209. data/vendor/bootstrap/js/dist/tab.js +0 -278
  210. data/vendor/bootstrap/js/dist/tooltip.js +0 -734
  211. data/vendor/bootstrap/js/dist/util.js +0 -144
  212. data/vendor/bootstrap/package.json +0 -217
  213. data/vendor/bootstrap/scss/_alert.scss +0 -51
  214. data/vendor/bootstrap/scss/_badge.scss +0 -47
  215. data/vendor/bootstrap/scss/_breadcrumb.scss +0 -41
  216. data/vendor/bootstrap/scss/_button-group.scss +0 -172
  217. data/vendor/bootstrap/scss/_buttons.scss +0 -143
  218. data/vendor/bootstrap/scss/_card.scss +0 -301
  219. data/vendor/bootstrap/scss/_carousel.scss +0 -236
  220. data/vendor/bootstrap/scss/_close.scss +0 -35
  221. data/vendor/bootstrap/scss/_code.scss +0 -48
  222. data/vendor/bootstrap/scss/_custom-forms.scss +0 -433
  223. data/vendor/bootstrap/scss/_dropdown.scss +0 -166
  224. data/vendor/bootstrap/scss/_forms.scss +0 -333
  225. data/vendor/bootstrap/scss/_functions.scss +0 -86
  226. data/vendor/bootstrap/scss/_grid.scss +0 -52
  227. data/vendor/bootstrap/scss/_images.scss +0 -42
  228. data/vendor/bootstrap/scss/_input-group.scss +0 -173
  229. data/vendor/bootstrap/scss/_jumbotron.scss +0 -16
  230. data/vendor/bootstrap/scss/_list-group.scss +0 -115
  231. data/vendor/bootstrap/scss/_media.scss +0 -8
  232. data/vendor/bootstrap/scss/_mixins.scss +0 -41
  233. data/vendor/bootstrap/scss/_modal.scss +0 -180
  234. data/vendor/bootstrap/scss/_nav.scss +0 -118
  235. data/vendor/bootstrap/scss/_navbar.scss +0 -299
  236. data/vendor/bootstrap/scss/_pagination.scss +0 -78
  237. data/vendor/bootstrap/scss/_popover.scss +0 -183
  238. data/vendor/bootstrap/scss/_print.scss +0 -141
  239. data/vendor/bootstrap/scss/_progress.scss +0 -34
  240. data/vendor/bootstrap/scss/_reboot.scss +0 -483
  241. data/vendor/bootstrap/scss/_root.scss +0 -19
  242. data/vendor/bootstrap/scss/_tables.scss +0 -187
  243. data/vendor/bootstrap/scss/_tooltip.scss +0 -115
  244. data/vendor/bootstrap/scss/_transitions.scss +0 -22
  245. data/vendor/bootstrap/scss/_type.scss +0 -125
  246. data/vendor/bootstrap/scss/_utilities.scss +0 -15
  247. data/vendor/bootstrap/scss/_variables.scss +0 -952
  248. data/vendor/bootstrap/scss/bootstrap-grid.scss +0 -32
  249. data/vendor/bootstrap/scss/bootstrap-reboot.scss +0 -12
  250. data/vendor/bootstrap/scss/bootstrap.scss +0 -42
  251. data/vendor/bootstrap/scss/mixins/_alert.scss +0 -13
  252. data/vendor/bootstrap/scss/mixins/_background-variant.scss +0 -21
  253. data/vendor/bootstrap/scss/mixins/_badge.scss +0 -12
  254. data/vendor/bootstrap/scss/mixins/_border-radius.scss +0 -35
  255. data/vendor/bootstrap/scss/mixins/_box-shadow.scss +0 -5
  256. data/vendor/bootstrap/scss/mixins/_breakpoints.scss +0 -123
  257. data/vendor/bootstrap/scss/mixins/_buttons.scss +0 -109
  258. data/vendor/bootstrap/scss/mixins/_caret.scss +0 -66
  259. data/vendor/bootstrap/scss/mixins/_clearfix.scss +0 -7
  260. data/vendor/bootstrap/scss/mixins/_float.scss +0 -11
  261. data/vendor/bootstrap/scss/mixins/_forms.scss +0 -147
  262. data/vendor/bootstrap/scss/mixins/_gradients.scss +0 -45
  263. data/vendor/bootstrap/scss/mixins/_grid-framework.scss +0 -67
  264. data/vendor/bootstrap/scss/mixins/_grid.scss +0 -52
  265. data/vendor/bootstrap/scss/mixins/_hover.scss +0 -37
  266. data/vendor/bootstrap/scss/mixins/_image.scss +0 -36
  267. data/vendor/bootstrap/scss/mixins/_list-group.scss +0 -21
  268. data/vendor/bootstrap/scss/mixins/_lists.scss +0 -7
  269. data/vendor/bootstrap/scss/mixins/_nav-divider.scss +0 -10
  270. data/vendor/bootstrap/scss/mixins/_pagination.scss +0 -22
  271. data/vendor/bootstrap/scss/mixins/_reset-text.scss +0 -17
  272. data/vendor/bootstrap/scss/mixins/_resize.scss +0 -6
  273. data/vendor/bootstrap/scss/mixins/_screen-reader.scss +0 -33
  274. data/vendor/bootstrap/scss/mixins/_size.scss +0 -6
  275. data/vendor/bootstrap/scss/mixins/_table-row.scss +0 -30
  276. data/vendor/bootstrap/scss/mixins/_text-emphasis.scss +0 -14
  277. data/vendor/bootstrap/scss/mixins/_text-hide.scss +0 -13
  278. data/vendor/bootstrap/scss/mixins/_text-truncate.scss +0 -8
  279. data/vendor/bootstrap/scss/mixins/_transition.scss +0 -13
  280. data/vendor/bootstrap/scss/mixins/_visibility.scss +0 -7
  281. data/vendor/bootstrap/scss/utilities/_align.scss +0 -8
  282. data/vendor/bootstrap/scss/utilities/_background.scss +0 -19
  283. data/vendor/bootstrap/scss/utilities/_borders.scss +0 -59
  284. data/vendor/bootstrap/scss/utilities/_clearfix.scss +0 -3
  285. data/vendor/bootstrap/scss/utilities/_display.scss +0 -38
  286. data/vendor/bootstrap/scss/utilities/_embed.scss +0 -52
  287. data/vendor/bootstrap/scss/utilities/_flex.scss +0 -51
  288. data/vendor/bootstrap/scss/utilities/_float.scss +0 -9
  289. data/vendor/bootstrap/scss/utilities/_position.scss +0 -37
  290. data/vendor/bootstrap/scss/utilities/_screenreaders.scss +0 -11
  291. data/vendor/bootstrap/scss/utilities/_shadows.scss +0 -6
  292. data/vendor/bootstrap/scss/utilities/_sizing.scss +0 -12
  293. data/vendor/bootstrap/scss/utilities/_spacing.scss +0 -51
  294. data/vendor/bootstrap/scss/utilities/_text.scss +0 -58
  295. data/vendor/bootstrap/scss/utilities/_visibility.scss +0 -11
  296. data/vendor/bootswatch/dist/cerulean/_bootswatch.scss +0 -99
  297. data/vendor/bootswatch/dist/cerulean/_variables.scss +0 -57
  298. data/vendor/bootswatch/dist/cosmo/_bootswatch.scss +0 -38
  299. data/vendor/bootswatch/dist/cosmo/_variables.scss +0 -68
  300. data/vendor/bootswatch/dist/cyborg/_bootswatch.scss +0 -230
  301. data/vendor/bootswatch/dist/cyborg/_variables.scss +0 -173
  302. data/vendor/bootswatch/dist/darkly/_bootswatch.scss +0 -186
  303. data/vendor/bootswatch/dist/darkly/_variables.scss +0 -178
  304. data/vendor/bootswatch/dist/flatly/_bootswatch.scss +0 -185
  305. data/vendor/bootswatch/dist/flatly/_variables.scss +0 -113
  306. data/vendor/bootswatch/dist/journal/_bootswatch.scss +0 -73
  307. data/vendor/bootswatch/dist/journal/_variables.scss +0 -60
  308. data/vendor/bootswatch/dist/litera/_bootswatch.scss +0 -212
  309. data/vendor/bootswatch/dist/litera/_variables.scss +0 -77
  310. data/vendor/bootswatch/dist/lumen/_bootswatch.scss +0 -429
  311. data/vendor/bootswatch/dist/lumen/_variables.scss +0 -82
  312. data/vendor/bootswatch/dist/lux/_bootswatch.scss +0 -157
  313. data/vendor/bootswatch/dist/lux/_variables.scss +0 -120
  314. data/vendor/bootswatch/dist/materia/_bootswatch.scss +0 -677
  315. data/vendor/bootswatch/dist/materia/_variables.scss +0 -131
  316. data/vendor/bootswatch/dist/minty/_bootswatch.scss +0 -258
  317. data/vendor/bootswatch/dist/minty/_variables.scss +0 -97
  318. data/vendor/bootswatch/dist/pulse/_bootswatch.scss +0 -154
  319. data/vendor/bootswatch/dist/pulse/_variables.scss +0 -100
  320. data/vendor/bootswatch/dist/sandstone/_bootswatch.scss +0 -235
  321. data/vendor/bootswatch/dist/sandstone/_variables.scss +0 -143
  322. data/vendor/bootswatch/dist/simplex/_bootswatch.scss +0 -130
  323. data/vendor/bootswatch/dist/simplex/_variables.scss +0 -108
  324. data/vendor/bootswatch/dist/sketchy/_bootswatch.scss +0 -411
  325. data/vendor/bootswatch/dist/sketchy/_variables.scss +0 -164
  326. data/vendor/bootswatch/dist/slate/_bootswatch.scss +0 -425
  327. data/vendor/bootswatch/dist/slate/_variables.scss +0 -160
  328. data/vendor/bootswatch/dist/solar/_bootswatch.scss +0 -119
  329. data/vendor/bootswatch/dist/solar/_variables.scss +0 -175
  330. data/vendor/bootswatch/dist/spacelab/_bootswatch.scss +0 -167
  331. data/vendor/bootswatch/dist/spacelab/_variables.scss +0 -63
  332. data/vendor/bootswatch/dist/superhero/_bootswatch.scss +0 -200
  333. data/vendor/bootswatch/dist/superhero/_variables.scss +0 -148
  334. data/vendor/bootswatch/dist/united/_bootswatch.scss +0 -26
  335. data/vendor/bootswatch/dist/united/_variables.scss +0 -53
  336. data/vendor/bootswatch/dist/yeti/_bootswatch.scss +0 -468
  337. data/vendor/bootswatch/dist/yeti/_variables.scss +0 -110
  338. data/vendor/bootswatch/package.json +0 -38
  339. data/vendor/chartkick/chartkick.js +0 -1872
  340. data/vendor/file-saver/FileSaver.js +0 -188
  341. data/vendor/popper.js/dist/umd/popper-utils.js +0 -1133
  342. data/vendor/popper.js/dist/umd/popper.js +0 -2540
  343. data/vendor/popper.js/package.json +0 -54
  344. data/vendor/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js +0 -2779
  345. data/vendor/tempusdominus-bootstrap-4/package.json +0 -79
  346. data/vendor/tempusdominus-bootstrap-4/src/sass/_tempusdominus-bootstrap-4.scss +0 -342
  347. data/vendor/tempusdominus-bootstrap-4/src/sass/tempusdominus-bootstrap-4-build.scss +0 -12
@@ -1,1872 +0,0 @@
1
- /*
2
- * Chartkick.js
3
- * Create beautiful charts with one line of JavaScript
4
- * https://github.com/ankane/chartkick.js
5
- * v2.2.4
6
- * MIT License
7
- */
8
-
9
- /*jslint browser: true, indent: 2, plusplus: true, vars: true */
10
-
11
- (function (window) {
12
- 'use strict';
13
-
14
- var config = window.Chartkick || {};
15
- var Chartkick, ISO8601_PATTERN, DECIMAL_SEPARATOR, adapters = [];
16
- var DATE_PATTERN = /^(\d\d\d\d)(\-)?(\d\d)(\-)?(\d\d)$/i;
17
- var GoogleChartsAdapter, HighchartsAdapter, ChartjsAdapter;
18
- var pendingRequests = [], runningRequests = 0, maxRequests = 4;
19
-
20
- // helpers
21
-
22
- function isArray(variable) {
23
- return Object.prototype.toString.call(variable) === "[object Array]";
24
- }
25
-
26
- function isFunction(variable) {
27
- return variable instanceof Function;
28
- }
29
-
30
- function isPlainObject(variable) {
31
- return !isFunction(variable) && variable instanceof Object;
32
- }
33
-
34
- // https://github.com/madrobby/zepto/blob/master/src/zepto.js
35
- function extend(target, source) {
36
- var key;
37
- for (key in source) {
38
- if (isPlainObject(source[key]) || isArray(source[key])) {
39
- if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
40
- target[key] = {};
41
- }
42
- if (isArray(source[key]) && !isArray(target[key])) {
43
- target[key] = [];
44
- }
45
- extend(target[key], source[key]);
46
- } else if (source[key] !== undefined) {
47
- target[key] = source[key];
48
- }
49
- }
50
- }
51
-
52
- function merge(obj1, obj2) {
53
- var target = {};
54
- extend(target, obj1);
55
- extend(target, obj2);
56
- return target;
57
- }
58
-
59
- // https://github.com/Do/iso8601.js
60
- ISO8601_PATTERN = /(\d\d\d\d)(\-)?(\d\d)(\-)?(\d\d)(T)?(\d\d)(:)?(\d\d)?(:)?(\d\d)?([\.,]\d+)?($|Z|([\+\-])(\d\d)(:)?(\d\d)?)/i;
61
- DECIMAL_SEPARATOR = String(1.5).charAt(1);
62
-
63
- function parseISO8601(input) {
64
- var day, hour, matches, milliseconds, minutes, month, offset, result, seconds, type, year;
65
- type = Object.prototype.toString.call(input);
66
- if (type === "[object Date]") {
67
- return input;
68
- }
69
- if (type !== "[object String]") {
70
- return;
71
- }
72
- matches = input.match(ISO8601_PATTERN);
73
- if (matches) {
74
- year = parseInt(matches[1], 10);
75
- month = parseInt(matches[3], 10) - 1;
76
- day = parseInt(matches[5], 10);
77
- hour = parseInt(matches[7], 10);
78
- minutes = matches[9] ? parseInt(matches[9], 10) : 0;
79
- seconds = matches[11] ? parseInt(matches[11], 10) : 0;
80
- milliseconds = matches[12] ? parseFloat(DECIMAL_SEPARATOR + matches[12].slice(1)) * 1000 : 0;
81
- result = Date.UTC(year, month, day, hour, minutes, seconds, milliseconds);
82
- if (matches[13] && matches[14]) {
83
- offset = matches[15] * 60;
84
- if (matches[17]) {
85
- offset += parseInt(matches[17], 10);
86
- }
87
- offset *= matches[14] === "-" ? -1 : 1;
88
- result -= offset * 60 * 1000;
89
- }
90
- return new Date(result);
91
- }
92
- }
93
- // end iso8601.js
94
-
95
- function negativeValues(series) {
96
- var i, j, data;
97
- for (i = 0; i < series.length; i++) {
98
- data = series[i].data;
99
- for (j = 0; j < data.length; j++) {
100
- if (data[j][1] < 0) {
101
- return true;
102
- }
103
- }
104
- }
105
- return false;
106
- }
107
-
108
- function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {
109
- return function (chart, opts, chartOptions) {
110
- var series = chart.data;
111
- var options = merge({}, defaultOptions);
112
- options = merge(options, chartOptions || {});
113
-
114
- if (chart.hideLegend || "legend" in opts) {
115
- hideLegend(options, opts.legend, chart.hideLegend);
116
- }
117
-
118
- if (opts.title) {
119
- setTitle(options, opts.title);
120
- }
121
-
122
- // min
123
- if ("min" in opts) {
124
- setMin(options, opts.min);
125
- } else if (!negativeValues(series)) {
126
- setMin(options, 0);
127
- }
128
-
129
- // max
130
- if (opts.max) {
131
- setMax(options, opts.max);
132
- }
133
-
134
- if ("stacked" in opts) {
135
- setStacked(options, opts.stacked);
136
- }
137
-
138
- if (opts.colors) {
139
- options.colors = opts.colors;
140
- }
141
-
142
- if (opts.xtitle) {
143
- setXtitle(options, opts.xtitle);
144
- }
145
-
146
- if (opts.ytitle) {
147
- setYtitle(options, opts.ytitle);
148
- }
149
-
150
- // merge library last
151
- options = merge(options, opts.library || {});
152
-
153
- return options;
154
- };
155
- }
156
-
157
- function setText(element, text) {
158
- if (document.body.innerText) {
159
- element.innerText = text;
160
- } else {
161
- element.textContent = text;
162
- }
163
- }
164
-
165
- function chartError(element, message) {
166
- setText(element, "Error Loading Chart: " + message);
167
- element.style.color = "#ff0000";
168
- }
169
-
170
- function pushRequest(element, url, success) {
171
- pendingRequests.push([element, url, success]);
172
- runNext();
173
- }
174
-
175
- function runNext() {
176
- if (runningRequests < maxRequests) {
177
- var request = pendingRequests.shift();
178
- if (request) {
179
- runningRequests++;
180
- getJSON(request[0], request[1], request[2]);
181
- runNext();
182
- }
183
- }
184
- }
185
-
186
- function requestComplete() {
187
- runningRequests--;
188
- runNext();
189
- }
190
-
191
- function getJSON(element, url, success) {
192
- ajaxCall(url, success, function (jqXHR, textStatus, errorThrown) {
193
- // PATCH_BEGIN
194
- var message = jqXHR.getResponseHeader("X-Status-Reason");
195
- if (jqXHR.status === 413) {
196
- message = message || "Request Entity Too Large";
197
- }
198
- message = message || ((typeof errorThrown === "string") ? errorThrown : errorThrown.message);
199
- // PATCH_END
200
- chartError(element, message);
201
- });
202
- }
203
-
204
- function ajaxCall(url, success, error) {
205
- var $ = window.jQuery || window.Zepto || window.$;
206
-
207
- if ($) {
208
- $.ajax({
209
- dataType: "json",
210
- url: url,
211
- success: success,
212
- error: error,
213
- complete: requestComplete
214
- });
215
- } else {
216
- var xhr = new XMLHttpRequest();
217
- xhr.open("GET", url, true);
218
- xhr.setRequestHeader("Content-Type", "application/json");
219
- xhr.onload = function () {
220
- requestComplete();
221
- if (xhr.status === 200) {
222
- success(JSON.parse(xhr.responseText), xhr.statusText, xhr);
223
- } else {
224
- error(xhr, "error", xhr.statusText);
225
- }
226
- };
227
- xhr.send();
228
- }
229
- }
230
-
231
- function errorCatcher(chart, callback) {
232
- try {
233
- callback(chart);
234
- } catch (err) {
235
- chartError(chart.element, err.message);
236
- throw err;
237
- }
238
- }
239
-
240
- function fetchDataSource(chart, callback, dataSource) {
241
- if (typeof dataSource === "string") {
242
- pushRequest(chart.element, dataSource, function (data, textStatus, jqXHR) {
243
- chart.rawData = data;
244
- errorCatcher(chart, callback);
245
- });
246
- } else {
247
- chart.rawData = dataSource;
248
- errorCatcher(chart, callback);
249
- }
250
- }
251
-
252
- function addDownloadButton(chart) {
253
- var element = chart.element;
254
- var link = document.createElement("a");
255
- link.download = chart.options.download === true ? "chart.png" : chart.options.download; // http://caniuse.com/download
256
- link.style.position = "absolute";
257
- link.style.top = "20px";
258
- link.style.right = "20px";
259
- link.style.zIndex = 1000;
260
- link.style.lineHeight = "20px";
261
- link.target = "_blank"; // for safari
262
- var image = document.createElement("img");
263
- image.alt = "Download";
264
- image.style.border = "none";
265
- // icon from font-awesome
266
- // http://fa2png.io/
267
- image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABCFBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMywEsqxAAAAV3RSTlMAAQIDBggJCgsMDQ4PERQaHB0eISIjJCouLzE0OTo/QUJHSUpLTU5PUllhYmltcHh5foWLjI+SlaCio6atr7S1t7m6vsHHyM7R2tze5Obo7fHz9ff5+/1hlxK2AAAA30lEQVQYGUXBhVYCQQBA0TdYWAt2d3d3YWAHyur7/z9xgD16Lw0DW+XKx+1GgX+FRzM3HWQWrHl5N/oapW5RPe0PkBu+UYeICvozTWZVK23Ao04B79oJrOsJDOoxkZoQPWgX29pHpCZEk7rEvQYiNSFq1UMqvlCjJkRBS1R8hb00Vb/TajtBL7nTHE1X1vyMQF732dQhyF2o6SAwrzP06iUQzvwsArlnzcOdrgBhJyHa1QOgO9U1GsKuvjUTjavliZYQ8nNPapG6sap/3nrIdJ6bOWzmX/fy0XVpfzZP3S8OJT3g9EEiJwAAAABJRU5ErkJggg==";
268
- link.appendChild(image);
269
- element.style.position = "relative";
270
-
271
- chart.downloadAttached = true;
272
-
273
- // mouseenter
274
- addEvent(element, "mouseover", function(e) {
275
- var related = e.relatedTarget;
276
- // check download option again to ensure it wasn't changed
277
- if (!related || (related !== this && !childOf(this, related)) && chart.options.download) {
278
- link.href = chart.toImage();
279
- element.appendChild(link);
280
- }
281
- });
282
-
283
- // mouseleave
284
- addEvent(element, "mouseout", function(e) {
285
- var related = e.relatedTarget;
286
- if (!related || (related !== this && !childOf(this, related))) {
287
- if (link.parentNode) {
288
- link.parentNode.removeChild(link);
289
- }
290
- }
291
- });
292
- }
293
-
294
- // http://stackoverflow.com/questions/10149963/adding-event-listener-cross-browser
295
- function addEvent(elem, event, fn) {
296
- if (elem.addEventListener) {
297
- elem.addEventListener(event, fn, false);
298
- } else {
299
- elem.attachEvent("on" + event, function() {
300
- // set the this pointer same as addEventListener when fn is called
301
- return(fn.call(elem, window.event));
302
- });
303
- }
304
- }
305
-
306
- // https://gist.github.com/shawnbot/4166283
307
- function childOf(p, c) {
308
- if (p === c) return false;
309
- while (c && c !== p) c = c.parentNode;
310
- return c === p;
311
- }
312
-
313
- // type conversions
314
-
315
- function toStr(n) {
316
- return "" + n;
317
- }
318
-
319
- function toFloat(n) {
320
- return parseFloat(n);
321
- }
322
-
323
- function toDate(n) {
324
- var matches, year, month, day;
325
- if (typeof n !== "object") {
326
- if (typeof n === "number") {
327
- n = new Date(n * 1000); // ms
328
- } else {
329
- n = toStr(n);
330
- if ((matches = n.match(DATE_PATTERN))) {
331
- year = parseInt(matches[1], 10);
332
- month = parseInt(matches[3], 10) - 1;
333
- day = parseInt(matches[5], 10);
334
- return new Date(year, month, day);
335
- } else { // str
336
- // try our best to get the str into iso8601
337
- // TODO be smarter about this
338
- var str = n.replace(/ /, "T").replace(" ", "").replace("UTC", "Z");
339
- n = parseISO8601(str) || new Date(n);
340
- }
341
- }
342
- }
343
- return n;
344
- }
345
-
346
- function toArr(n) {
347
- if (!isArray(n)) {
348
- var arr = [], i;
349
- for (i in n) {
350
- if (n.hasOwnProperty(i)) {
351
- arr.push([i, n[i]]);
352
- }
353
- }
354
- n = arr;
355
- }
356
- return n;
357
- }
358
-
359
- function sortByTime(a, b) {
360
- return a[0].getTime() - b[0].getTime();
361
- }
362
-
363
- function sortByNumberSeries(a, b) {
364
- return a[0] - b[0];
365
- }
366
-
367
- function sortByNumber(a, b) {
368
- return a - b;
369
- }
370
-
371
- function loadAdapters() {
372
- if (!ChartjsAdapter && "Chart" in window) {
373
- ChartjsAdapter = (function () {
374
- var Chart = window.Chart;
375
-
376
- var baseOptions = {
377
- maintainAspectRatio: false,
378
- animation: false,
379
- tooltips: {
380
- displayColors: false
381
- },
382
- legend: {},
383
- title: {fontSize: 20, fontColor: "#333"}
384
- };
385
-
386
- var defaultOptions = {
387
- scales: {
388
- yAxes: [
389
- {
390
- ticks: {
391
- maxTicksLimit: 4
392
- },
393
- scaleLabel: {
394
- fontSize: 16,
395
- // fontStyle: "bold",
396
- fontColor: "#333"
397
- }
398
- }
399
- ],
400
- xAxes: [
401
- {
402
- gridLines: {
403
- drawOnChartArea: false
404
- },
405
- scaleLabel: {
406
- fontSize: 16,
407
- // fontStyle: "bold",
408
- fontColor: "#333"
409
- },
410
- time: {},
411
- ticks: {}
412
- }
413
- ]
414
- }
415
- };
416
-
417
- // http://there4.io/2012/05/02/google-chart-color-list/
418
- var defaultColors = [
419
- "#3366CC", "#DC3912", "#FF9900", "#109618", "#990099", "#3B3EAC", "#0099C6",
420
- "#DD4477", "#66AA00", "#B82E2E", "#316395", "#994499", "#22AA99", "#AAAA11",
421
- "#6633CC", "#E67300", "#8B0707", "#329262", "#5574A6", "#651067"
422
- ];
423
-
424
- var hideLegend = function (options, legend, hideLegend) {
425
- if (legend !== undefined) {
426
- options.legend.display = !!legend;
427
- if (legend && legend !== true) {
428
- options.legend.position = legend;
429
- }
430
- } else if (hideLegend) {
431
- options.legend.display = false;
432
- }
433
- };
434
-
435
- var setTitle = function (options, title) {
436
- options.title.display = true;
437
- options.title.text = title;
438
- };
439
-
440
- var setMin = function (options, min) {
441
- if (min !== null) {
442
- options.scales.yAxes[0].ticks.min = toFloat(min);
443
- }
444
- };
445
-
446
- var setMax = function (options, max) {
447
- options.scales.yAxes[0].ticks.max = toFloat(max);
448
- };
449
-
450
- var setBarMin = function (options, min) {
451
- if (min !== null) {
452
- options.scales.xAxes[0].ticks.min = toFloat(min);
453
- }
454
- };
455
-
456
- var setBarMax = function (options, max) {
457
- options.scales.xAxes[0].ticks.max = toFloat(max);
458
- };
459
-
460
- var setStacked = function (options, stacked) {
461
- options.scales.xAxes[0].stacked = !!stacked;
462
- options.scales.yAxes[0].stacked = !!stacked;
463
- };
464
-
465
- var setXtitle = function (options, title) {
466
- options.scales.xAxes[0].scaleLabel.display = true;
467
- options.scales.xAxes[0].scaleLabel.labelString = title;
468
- };
469
-
470
- var setYtitle = function (options, title) {
471
- options.scales.yAxes[0].scaleLabel.display = true;
472
- options.scales.yAxes[0].scaleLabel.labelString = title;
473
- };
474
-
475
- var drawChart = function(chart, type, data, options) {
476
- if (chart.chart) {
477
- chart.chart.destroy();
478
- } else {
479
- chart.element.innerHTML = "<canvas></canvas>";
480
- }
481
-
482
- var ctx = chart.element.getElementsByTagName("CANVAS")[0];
483
- chart.chart = new Chart(ctx, {
484
- type: type,
485
- data: data,
486
- options: options
487
- });
488
- };
489
-
490
- // http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
491
- var addOpacity = function(hex, opacity) {
492
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
493
- return result ? "rgba(" + parseInt(result[1], 16) + ", " + parseInt(result[2], 16) + ", " + parseInt(result[3], 16) + ", " + opacity + ")" : hex;
494
- };
495
-
496
- var setLabelSize = function (chart, data, options) {
497
- var maxLabelSize = Math.ceil(chart.element.offsetWidth / 4.0 / data.labels.length);
498
- if (maxLabelSize > 25) {
499
- maxLabelSize = 25;
500
- }
501
- options.scales.xAxes[0].ticks.callback = function (value) {
502
- value = toStr(value);
503
- if (value.length > maxLabelSize) {
504
- return value.substring(0, maxLabelSize - 2) + "...";
505
- } else {
506
- return value;
507
- }
508
- };
509
- };
510
-
511
- var jsOptions = jsOptionsFunc(merge(baseOptions, defaultOptions), hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);
512
-
513
- var createDataTable = function (chart, options, chartType) {
514
- var datasets = [];
515
- var labels = [];
516
-
517
- var colors = chart.options.colors || defaultColors;
518
-
519
- var day = true;
520
- var week = true;
521
- var dayOfWeek;
522
- var month = true;
523
- var year = true;
524
- var hour = true;
525
- var minute = true;
526
- var detectType = (chartType === "line" || chartType === "area") && !chart.discrete;
527
-
528
- var series = chart.data;
529
-
530
- var sortedLabels = [];
531
-
532
- var i, j, s, d, key, rows = [];
533
- for (i = 0; i < series.length; i++) {
534
- s = series[i];
535
-
536
- for (j = 0; j < s.data.length; j++) {
537
- d = s.data[j];
538
- key = detectType ? d[0].getTime() : d[0];
539
- if (!rows[key]) {
540
- rows[key] = new Array(series.length);
541
- }
542
- rows[key][i] = toFloat(d[1]);
543
- if (sortedLabels.indexOf(key) === -1) {
544
- sortedLabels.push(key);
545
- }
546
- }
547
- }
548
-
549
- if (detectType || chart.options.xtype === "number") {
550
- sortedLabels.sort(sortByNumber);
551
- }
552
-
553
- var rows2 = [];
554
- for (j = 0; j < series.length; j++) {
555
- rows2.push([]);
556
- }
557
-
558
- var value;
559
- var k;
560
- for (k = 0; k < sortedLabels.length; k++) {
561
- i = sortedLabels[k];
562
- if (detectType) {
563
- value = new Date(toFloat(i));
564
- // TODO make this efficient
565
- day = day && isDay(value);
566
- if (!dayOfWeek) {
567
- dayOfWeek = value.getDay();
568
- }
569
- week = week && isWeek(value, dayOfWeek);
570
- month = month && isMonth(value);
571
- year = year && isYear(value);
572
- hour = hour && isHour(value);
573
- minute = minute && isMinute(value);
574
- } else {
575
- value = i;
576
- }
577
- labels.push(value);
578
- for (j = 0; j < series.length; j++) {
579
- // Chart.js doesn't like undefined
580
- rows2[j].push(rows[i][j] === undefined ? null : rows[i][j]);
581
- }
582
- }
583
-
584
- for (i = 0; i < series.length; i++) {
585
- s = series[i];
586
-
587
- var color = s.color || colors[i];
588
- var backgroundColor = chartType !== "line" ? addOpacity(color, 0.5) : color;
589
-
590
- var dataset = {
591
- label: s.name,
592
- data: rows2[i],
593
- fill: chartType === "area",
594
- borderColor: color,
595
- backgroundColor: backgroundColor,
596
- pointBackgroundColor: color,
597
- borderWidth: 2
598
- };
599
-
600
- if (s.stack) {
601
- dataset.stack = s.stack;
602
- }
603
-
604
- // PATCH_BEGIN
605
- if (chart.options.y2 === true) {
606
- dataset.yAxisID = (s.y2 === true) ? 'y-axis-right' : 'y-axis-left';
607
- options.scales.yAxes = [
608
- { id: 'y-axis-left', position: 'left' },
609
- { id: 'y-axis-right', position: 'right' }
610
- ];
611
- }
612
- // PATCH_END
613
-
614
- if (chart.options.curve === false) {
615
- dataset.lineTension = 0;
616
- }
617
-
618
- if (chart.options.points === false) {
619
- dataset.pointRadius = 0;
620
- dataset.pointHitRadius = 5;
621
- }
622
-
623
- datasets.push(merge(dataset, s.library || {}));
624
- }
625
-
626
- if (detectType && labels.length > 0) {
627
- var minTime = labels[0].getTime();
628
- var maxTime = labels[0].getTime();
629
- for (i = 1; i < labels.length; i++) {
630
- value = labels[i].getTime();
631
- if (value < minTime) {
632
- minTime = value;
633
- }
634
- if (value > maxTime) {
635
- maxTime = value;
636
- }
637
- }
638
-
639
- var timeDiff = (maxTime - minTime) / (86400 * 1000.0);
640
-
641
- if (!options.scales.xAxes[0].time.unit) {
642
- var step;
643
- if (year || timeDiff > 365 * 10) {
644
- options.scales.xAxes[0].time.unit = "year";
645
- step = 365;
646
- } else if (month || timeDiff > 30 * 10) {
647
- options.scales.xAxes[0].time.unit = "month";
648
- step = 30;
649
- } else if (day || timeDiff > 10) {
650
- options.scales.xAxes[0].time.unit = "day";
651
- step = 1;
652
- } else if (hour || timeDiff > 0.5) {
653
- options.scales.xAxes[0].time.displayFormats = {hour: "MMM D, h a"};
654
- options.scales.xAxes[0].time.unit = "hour";
655
- step = 1 / 24.0;
656
- } else if (minute) {
657
- options.scales.xAxes[0].time.displayFormats = {minute: "h:mm a"};
658
- options.scales.xAxes[0].time.unit = "minute";
659
- step = 1 / 24.0 / 60.0;
660
- }
661
-
662
- if (step && timeDiff > 0) {
663
- var unitStepSize = Math.ceil(timeDiff / step / (chart.element.offsetWidth / 100.0));
664
- if (week && step === 1) {
665
- unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
666
- }
667
- options.scales.xAxes[0].time.unitStepSize = unitStepSize;
668
- }
669
- }
670
-
671
- if (!options.scales.xAxes[0].time.tooltipFormat) {
672
- if (day) {
673
- options.scales.xAxes[0].time.tooltipFormat = "ll";
674
- } else if (hour) {
675
- options.scales.xAxes[0].time.tooltipFormat = "MMM D, h a";
676
- } else if (minute) {
677
- options.scales.xAxes[0].time.tooltipFormat = "h:mm a";
678
- }
679
- }
680
- }
681
-
682
- var data = {
683
- labels: labels,
684
- datasets: datasets
685
- };
686
-
687
- return data;
688
- };
689
-
690
- var renderLineChart = function (chart, chartType) {
691
- if (chart.options.xtype === "number") {
692
- return renderScatterChart(chart, chartType, true);
693
- }
694
-
695
- var chartOptions = {};
696
- if (chartType === "area") {
697
- // TODO fix area stacked
698
- // chartOptions.stacked = true;
699
- }
700
- // fix for https://github.com/chartjs/Chart.js/issues/2441
701
- if (!chart.options.max && allZeros(chart.data)) {
702
- chartOptions.max = 1;
703
- }
704
-
705
- var options = jsOptions(chart, merge(chartOptions, chart.options));
706
-
707
- var data = createDataTable(chart, options, chartType || "line");
708
-
709
- options.scales.xAxes[0].type = chart.discrete ? "category" : "time";
710
-
711
- drawChart(chart, "line", data, options);
712
- };
713
-
714
- var renderPieChart = function (chart) {
715
- var options = merge({}, baseOptions);
716
- if (chart.options.donut) {
717
- options.cutoutPercentage = 50;
718
- }
719
-
720
- if ("legend" in chart.options) {
721
- hideLegend(options, chart.options.legend);
722
- }
723
-
724
- if (chart.options.title) {
725
- setTitle(options, chart.options.title);
726
- }
727
-
728
- options = merge(options, chart.options.library || {});
729
-
730
- var labels = [];
731
- var values = [];
732
- for (var i = 0; i < chart.data.length; i++) {
733
- var point = chart.data[i];
734
- labels.push(point[0]);
735
- values.push(point[1]);
736
- }
737
-
738
- var data = {
739
- labels: labels,
740
- datasets: [
741
- {
742
- data: values,
743
- backgroundColor: chart.options.colors || defaultColors
744
- }
745
- ]
746
- };
747
-
748
- drawChart(chart, "pie", data, options);
749
- };
750
-
751
- var renderColumnChart = function (chart, chartType) {
752
- var options;
753
- if (chartType === "bar") {
754
- options = jsOptionsFunc(merge(baseOptions, defaultOptions), hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options);
755
- } else {
756
- options = jsOptions(chart, chart.options);
757
- }
758
- var data = createDataTable(chart, options, "column");
759
- setLabelSize(chart, data, options);
760
- drawChart(chart, (chartType === "bar" ? "horizontalBar" : "bar"), data, options);
761
- };
762
-
763
- var renderAreaChart = function (chart) {
764
- renderLineChart(chart, "area");
765
- };
766
-
767
- var renderBarChart = function (chart) {
768
- renderColumnChart(chart, "bar");
769
- };
770
-
771
- var renderScatterChart = function (chart, chartType, lineChart) {
772
- chartType = chartType || "line";
773
-
774
- var options = jsOptions(chart, chart.options);
775
-
776
- var colors = chart.options.colors || defaultColors;
777
-
778
- var datasets = [];
779
- var series = chart.data;
780
- for (var i = 0; i < series.length; i++) {
781
- var s = series[i];
782
- var d = [];
783
- for (var j = 0; j < s.data.length; j++) {
784
- var point = {
785
- x: toFloat(s.data[j][0]),
786
- y: toFloat(s.data[j][1])
787
- };
788
- if (chartType === "bubble") {
789
- point.r = toFloat(s.data[j][2]);
790
- }
791
- d.push(point);
792
- }
793
-
794
- var color = s.color || colors[i];
795
- var backgroundColor = chartType === "area" ? addOpacity(color, 0.5) : color;
796
-
797
- datasets.push({
798
- label: s.name,
799
- showLine: lineChart || false,
800
- data: d,
801
- borderColor: color,
802
- backgroundColor: backgroundColor,
803
- pointBackgroundColor: color,
804
- fill: chartType === "area"
805
- });
806
- }
807
-
808
- if (chartType === "area") {
809
- chartType = "line";
810
- }
811
-
812
- var data = {datasets: datasets};
813
-
814
- options.scales.xAxes[0].type = "linear";
815
- options.scales.xAxes[0].position = "bottom";
816
-
817
- drawChart(chart, chartType, data, options);
818
- };
819
-
820
- var renderBubbleChart = function (chart) {
821
- renderScatterChart(chart, "bubble");
822
- };
823
-
824
- return {
825
- name: "chartjs",
826
- renderLineChart: renderLineChart,
827
- renderPieChart: renderPieChart,
828
- renderColumnChart: renderColumnChart,
829
- renderBarChart: renderBarChart,
830
- renderAreaChart: renderAreaChart,
831
- renderScatterChart: renderScatterChart,
832
- renderBubbleChart: renderBubbleChart
833
- };
834
- })();
835
-
836
- adapters.push(ChartjsAdapter);
837
- }
838
-
839
- if (!HighchartsAdapter && "Highcharts" in window) {
840
- HighchartsAdapter = (function () {
841
- var Highcharts = window.Highcharts;
842
-
843
- var defaultOptions = {
844
- chart: {},
845
- xAxis: {
846
- title: {
847
- text: null
848
- },
849
- labels: {
850
- style: {
851
- fontSize: "12px"
852
- }
853
- }
854
- },
855
- yAxis: {
856
- title: {
857
- text: null
858
- },
859
- labels: {
860
- style: {
861
- fontSize: "12px"
862
- }
863
- }
864
- },
865
- title: {
866
- text: null
867
- },
868
- credits: {
869
- enabled: false
870
- },
871
- legend: {
872
- borderWidth: 0
873
- },
874
- tooltip: {
875
- style: {
876
- fontSize: "12px"
877
- }
878
- },
879
- plotOptions: {
880
- areaspline: {},
881
- series: {
882
- marker: {}
883
- }
884
- }
885
- };
886
-
887
- var hideLegend = function (options, legend, hideLegend) {
888
- if (legend !== undefined) {
889
- options.legend.enabled = !!legend;
890
- if (legend && legend !== true) {
891
- if (legend === "top" || legend === "bottom") {
892
- options.legend.verticalAlign = legend;
893
- } else {
894
- options.legend.layout = "vertical";
895
- options.legend.verticalAlign = "middle";
896
- options.legend.align = legend;
897
- }
898
- }
899
- } else if (hideLegend) {
900
- options.legend.enabled = false;
901
- }
902
- };
903
-
904
- var setTitle = function (options, title) {
905
- options.title.text = title;
906
- };
907
-
908
- var setMin = function (options, min) {
909
- options.yAxis.min = min;
910
- };
911
-
912
- var setMax = function (options, max) {
913
- options.yAxis.max = max;
914
- };
915
-
916
- var setStacked = function (options, stacked) {
917
- options.plotOptions.series.stacking = stacked ? "normal" : null;
918
- };
919
-
920
- var setXtitle = function (options, title) {
921
- options.xAxis.title.text = title;
922
- };
923
-
924
- var setYtitle = function (options, title) {
925
- options.yAxis.title.text = title;
926
- };
927
-
928
- var jsOptions = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);
929
-
930
- var drawChart = function(chart, data, options) {
931
- if (chart.chart) {
932
- chart.chart.destroy();
933
- }
934
-
935
- options.chart.renderTo = chart.element.id;
936
- options.series = data;
937
- chart.chart = new Highcharts.Chart(options);
938
- };
939
-
940
- var renderLineChart = function (chart, chartType) {
941
- chartType = chartType || "spline";
942
- var chartOptions = {};
943
- if (chartType === "areaspline") {
944
- chartOptions = {
945
- plotOptions: {
946
- areaspline: {
947
- stacking: "normal"
948
- },
949
- area: {
950
- stacking: "normal"
951
- },
952
- series: {
953
- marker: {
954
- enabled: false
955
- }
956
- }
957
- }
958
- };
959
- }
960
-
961
- if (chart.options.curve === false) {
962
- if (chartType === "areaspline") {
963
- chartType = "area";
964
- } else if (chartType === "spline") {
965
- chartType = "line";
966
- }
967
- }
968
-
969
- var options = jsOptions(chart, chart.options, chartOptions), data, i, j;
970
- options.xAxis.type = chart.discrete ? "category" : "datetime";
971
- if (!options.chart.type) {
972
- options.chart.type = chartType;
973
- }
974
-
975
- var series = chart.data;
976
- for (i = 0; i < series.length; i++) {
977
- data = series[i].data;
978
- if (!chart.discrete) {
979
- for (j = 0; j < data.length; j++) {
980
- data[j][0] = data[j][0].getTime();
981
- }
982
- }
983
- series[i].marker = {symbol: "circle"};
984
- if (chart.options.points === false) {
985
- series[i].marker.enabled = false;
986
- }
987
- }
988
-
989
- drawChart(chart, series, options);
990
- };
991
-
992
- var renderScatterChart = function (chart) {
993
- var options = jsOptions(chart, chart.options, {});
994
- options.chart.type = "scatter";
995
- drawChart(chart, chart.data, options);
996
- };
997
-
998
- var renderPieChart = function (chart) {
999
- var chartOptions = merge(defaultOptions, {});
1000
-
1001
- if (chart.options.colors) {
1002
- chartOptions.colors = chart.options.colors;
1003
- }
1004
- if (chart.options.donut) {
1005
- chartOptions.plotOptions = {pie: {innerSize: "50%"}};
1006
- }
1007
-
1008
- if ("legend" in chart.options) {
1009
- hideLegend(chartOptions, chart.options.legend);
1010
- }
1011
-
1012
- if (chart.options.title) {
1013
- setTitle(chartOptions, chart.options.title);
1014
- }
1015
-
1016
- var options = merge(chartOptions, chart.options.library || {});
1017
- var series = [{
1018
- type: "pie",
1019
- name: chart.options.label || "Value",
1020
- data: chart.data
1021
- }];
1022
-
1023
- drawChart(chart, series, options);
1024
- };
1025
-
1026
- var renderColumnChart = function (chart, chartType) {
1027
- chartType = chartType || "column";
1028
- var series = chart.data;
1029
- var options = jsOptions(chart, chart.options), i, j, s, d, rows = [], categories = [];
1030
- options.chart.type = chartType;
1031
-
1032
- for (i = 0; i < series.length; i++) {
1033
- s = series[i];
1034
-
1035
- for (j = 0; j < s.data.length; j++) {
1036
- d = s.data[j];
1037
- if (!rows[d[0]]) {
1038
- rows[d[0]] = new Array(series.length);
1039
- categories.push(d[0]);
1040
- }
1041
- rows[d[0]][i] = d[1];
1042
- }
1043
- }
1044
-
1045
- if (chart.options.xtype === "number") {
1046
- categories.sort(sortByNumber);
1047
- }
1048
-
1049
- options.xAxis.categories = categories;
1050
-
1051
- var newSeries = [], d2;
1052
- for (i = 0; i < series.length; i++) {
1053
- d = [];
1054
- for (j = 0; j < categories.length; j++) {
1055
- d.push(rows[categories[j]][i] || 0);
1056
- }
1057
-
1058
- d2 = {
1059
- name: series[i].name,
1060
- data: d
1061
- };
1062
- if (series[i].stack) {
1063
- d2.stack = series[i].stack;
1064
- }
1065
-
1066
- newSeries.push(d2);
1067
- }
1068
-
1069
- drawChart(chart, newSeries, options);
1070
- };
1071
-
1072
- var renderBarChart = function (chart) {
1073
- renderColumnChart(chart, "bar");
1074
- };
1075
-
1076
- var renderAreaChart = function (chart) {
1077
- renderLineChart(chart, "areaspline");
1078
- };
1079
-
1080
- return {
1081
- name: "highcharts",
1082
- renderLineChart: renderLineChart,
1083
- renderPieChart: renderPieChart,
1084
- renderColumnChart: renderColumnChart,
1085
- renderBarChart: renderBarChart,
1086
- renderAreaChart: renderAreaChart,
1087
- renderScatterChart: renderScatterChart
1088
- };
1089
- })();
1090
- adapters.push(HighchartsAdapter);
1091
- }
1092
- if (!GoogleChartsAdapter && window.google && (window.google.setOnLoadCallback || window.google.charts)) {
1093
- GoogleChartsAdapter = (function () {
1094
- var google = window.google;
1095
-
1096
- var loaded = {};
1097
- var callbacks = [];
1098
-
1099
- var runCallbacks = function () {
1100
- var cb, call;
1101
- for (var i = 0; i < callbacks.length; i++) {
1102
- cb = callbacks[i];
1103
- call = google.visualization && ((cb.pack === "corechart" && google.visualization.LineChart) || (cb.pack === "timeline" && google.visualization.Timeline));
1104
- if (call) {
1105
- cb.callback();
1106
- callbacks.splice(i, 1);
1107
- i--;
1108
- }
1109
- }
1110
- };
1111
-
1112
- var waitForLoaded = function (pack, callback) {
1113
- if (!callback) {
1114
- callback = pack;
1115
- pack = "corechart";
1116
- }
1117
-
1118
- callbacks.push({pack: pack, callback: callback});
1119
-
1120
- if (loaded[pack]) {
1121
- runCallbacks();
1122
- } else {
1123
- loaded[pack] = true;
1124
-
1125
- // https://groups.google.com/forum/#!topic/google-visualization-api/fMKJcyA2yyI
1126
- var loadOptions = {
1127
- packages: [pack],
1128
- callback: runCallbacks
1129
- };
1130
- if (config.language) {
1131
- loadOptions.language = config.language;
1132
- }
1133
- if (pack === "corechart" && config.mapsApiKey) {
1134
- loadOptions.mapsApiKey = config.mapsApiKey;
1135
- }
1136
-
1137
- if (window.google.setOnLoadCallback) {
1138
- google.load("visualization", "1", loadOptions);
1139
- } else {
1140
- google.charts.load("current", loadOptions);
1141
- }
1142
- }
1143
- };
1144
-
1145
- // Set chart options
1146
- var defaultOptions = {
1147
- chartArea: {},
1148
- fontName: "'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif",
1149
- pointSize: 6,
1150
- legend: {
1151
- textStyle: {
1152
- fontSize: 12,
1153
- color: "#444"
1154
- },
1155
- alignment: "center",
1156
- position: "right"
1157
- },
1158
- curveType: "function",
1159
- hAxis: {
1160
- textStyle: {
1161
- color: "#666",
1162
- fontSize: 12
1163
- },
1164
- titleTextStyle: {},
1165
- gridlines: {
1166
- color: "transparent"
1167
- },
1168
- baselineColor: "#ccc",
1169
- viewWindow: {}
1170
- },
1171
- vAxis: {
1172
- textStyle: {
1173
- color: "#666",
1174
- fontSize: 12
1175
- },
1176
- titleTextStyle: {},
1177
- baselineColor: "#ccc",
1178
- viewWindow: {}
1179
- },
1180
- tooltip: {
1181
- textStyle: {
1182
- color: "#666",
1183
- fontSize: 12
1184
- }
1185
- }
1186
- };
1187
-
1188
- var hideLegend = function (options, legend, hideLegend) {
1189
- if (legend !== undefined) {
1190
- var position;
1191
- if (!legend) {
1192
- position = "none";
1193
- } else if (legend === true) {
1194
- position = "right";
1195
- } else {
1196
- position = legend;
1197
- }
1198
- options.legend.position = position;
1199
- } else if (hideLegend) {
1200
- options.legend.position = "none";
1201
- }
1202
- };
1203
-
1204
- var setTitle = function (options, title) {
1205
- options.title = title;
1206
- options.titleTextStyle = {color: "#333", fontSize: "20px"};
1207
- };
1208
-
1209
- var setMin = function (options, min) {
1210
- options.vAxis.viewWindow.min = min;
1211
- };
1212
-
1213
- var setMax = function (options, max) {
1214
- options.vAxis.viewWindow.max = max;
1215
- };
1216
-
1217
- var setBarMin = function (options, min) {
1218
- options.hAxis.viewWindow.min = min;
1219
- };
1220
-
1221
- var setBarMax = function (options, max) {
1222
- options.hAxis.viewWindow.max = max;
1223
- };
1224
-
1225
- var setStacked = function (options, stacked) {
1226
- options.isStacked = !!stacked;
1227
- };
1228
-
1229
- var setXtitle = function (options, title) {
1230
- options.hAxis.title = title;
1231
- options.hAxis.titleTextStyle.italic = false;
1232
- };
1233
-
1234
- var setYtitle = function (options, title) {
1235
- options.vAxis.title = title;
1236
- options.vAxis.titleTextStyle.italic = false;
1237
- };
1238
-
1239
- var jsOptions = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);
1240
-
1241
- // cant use object as key
1242
- var createDataTable = function (series, columnType, xtype) {
1243
- var i, j, s, d, key, rows = [], sortedLabels = [];
1244
- for (i = 0; i < series.length; i++) {
1245
- s = series[i];
1246
-
1247
- for (j = 0; j < s.data.length; j++) {
1248
- d = s.data[j];
1249
- key = (columnType === "datetime") ? d[0].getTime() : d[0];
1250
- if (!rows[key]) {
1251
- rows[key] = new Array(series.length);
1252
- sortedLabels.push(key);
1253
- }
1254
- rows[key][i] = toFloat(d[1]);
1255
- }
1256
- }
1257
-
1258
- var rows2 = [];
1259
- var day = true;
1260
- var value;
1261
- for (j = 0; j < sortedLabels.length; j++) {
1262
- i = sortedLabels[j];
1263
- if (columnType === "datetime") {
1264
- value = new Date(toFloat(i));
1265
- day = day && isDay(value);
1266
- } else if (columnType === "number") {
1267
- value = toFloat(i);
1268
- } else {
1269
- value = i;
1270
- }
1271
- rows2.push([value].concat(rows[i]));
1272
- }
1273
- if (columnType === "datetime") {
1274
- rows2.sort(sortByTime);
1275
- } else if (columnType === "number") {
1276
- rows2.sort(sortByNumberSeries);
1277
- }
1278
-
1279
- if (xtype === "number") {
1280
- rows2.sort(sortByNumberSeries);
1281
-
1282
- for (i = 0; i < rows2.length; i++) {
1283
- rows2[i][0] = toStr(rows2[i][0]);
1284
- }
1285
- }
1286
-
1287
- // create datatable
1288
- var data = new google.visualization.DataTable();
1289
- columnType = columnType === "datetime" && day ? "date" : columnType;
1290
- data.addColumn(columnType, "");
1291
- for (i = 0; i < series.length; i++) {
1292
- data.addColumn("number", series[i].name);
1293
- }
1294
- data.addRows(rows2);
1295
-
1296
- return data;
1297
- };
1298
-
1299
- var resize = function (callback) {
1300
- if (window.attachEvent) {
1301
- window.attachEvent("onresize", callback);
1302
- } else if (window.addEventListener) {
1303
- window.addEventListener("resize", callback, true);
1304
- }
1305
- callback();
1306
- };
1307
-
1308
- var drawChart = function(chart, type, data, options) {
1309
- if (chart.chart) {
1310
- chart.chart.clearChart();
1311
- }
1312
-
1313
- chart.chart = new type(chart.element);
1314
- resize(function () {
1315
- chart.chart.draw(data, options);
1316
- });
1317
- };
1318
-
1319
- var renderLineChart = function (chart) {
1320
- waitForLoaded(function () {
1321
- var chartOptions = {};
1322
-
1323
- if (chart.options.curve === false) {
1324
- chartOptions.curveType = "none";
1325
- }
1326
-
1327
- if (chart.options.points === false) {
1328
- chartOptions.pointSize = 0;
1329
- }
1330
-
1331
- var options = jsOptions(chart, chart.options, chartOptions);
1332
- var columnType = chart.discrete ? "string" : "datetime";
1333
- if (chart.options.xtype === "number") {
1334
- columnType = "number";
1335
- }
1336
- var data = createDataTable(chart.data, columnType);
1337
-
1338
- drawChart(chart, google.visualization.LineChart, data, options);
1339
- });
1340
- };
1341
-
1342
- var renderPieChart = function (chart) {
1343
- waitForLoaded(function () {
1344
- var chartOptions = {
1345
- chartArea: {
1346
- top: "10%",
1347
- height: "80%"
1348
- },
1349
- legend: {}
1350
- };
1351
- if (chart.options.colors) {
1352
- chartOptions.colors = chart.options.colors;
1353
- }
1354
- if (chart.options.donut) {
1355
- chartOptions.pieHole = 0.5;
1356
- }
1357
- if ("legend" in chart.options) {
1358
- hideLegend(chartOptions, chart.options.legend);
1359
- }
1360
- if (chart.options.title) {
1361
- setTitle(chartOptions, chart.options.title);
1362
- }
1363
- var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});
1364
-
1365
- var data = new google.visualization.DataTable();
1366
- data.addColumn("string", "");
1367
- data.addColumn("number", "Value");
1368
- data.addRows(chart.data);
1369
-
1370
- drawChart(chart, google.visualization.PieChart, data, options);
1371
- });
1372
- };
1373
-
1374
- var renderColumnChart = function (chart) {
1375
- waitForLoaded(function () {
1376
- var options = jsOptions(chart, chart.options);
1377
- var data = createDataTable(chart.data, "string", chart.options.xtype);
1378
-
1379
- drawChart(chart, google.visualization.ColumnChart, data, options);
1380
- });
1381
- };
1382
-
1383
- var renderBarChart = function (chart) {
1384
- waitForLoaded(function () {
1385
- var chartOptions = {
1386
- hAxis: {
1387
- gridlines: {
1388
- color: "#ccc"
1389
- }
1390
- }
1391
- };
1392
- var options = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options, chartOptions);
1393
- var data = createDataTable(chart.data, "string", chart.options.xtype);
1394
-
1395
- drawChart(chart, google.visualization.BarChart, data, options);
1396
- });
1397
- };
1398
-
1399
- var renderAreaChart = function (chart) {
1400
- waitForLoaded(function () {
1401
- var chartOptions = {
1402
- isStacked: true,
1403
- pointSize: 0,
1404
- areaOpacity: 0.5
1405
- };
1406
-
1407
- var options = jsOptions(chart, chart.options, chartOptions);
1408
- var columnType = chart.discrete ? "string" : "datetime";
1409
- if (chart.options.xtype === "number") {
1410
- columnType = "number";
1411
- }
1412
- var data = createDataTable(chart.data, columnType);
1413
-
1414
- drawChart(chart, google.visualization.AreaChart, data, options);
1415
- });
1416
- };
1417
-
1418
- var renderGeoChart = function (chart) {
1419
- waitForLoaded(function () {
1420
- var chartOptions = {
1421
- legend: "none",
1422
- colorAxis: {
1423
- colors: chart.options.colors || ["#f6c7b6", "#ce502d"]
1424
- }
1425
- };
1426
- var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});
1427
-
1428
- var data = new google.visualization.DataTable();
1429
- data.addColumn("string", "");
1430
- data.addColumn("number", chart.options.label || "Value");
1431
- data.addRows(chart.data);
1432
-
1433
- drawChart(chart, google.visualization.GeoChart, data, options);
1434
- });
1435
- };
1436
-
1437
- var renderScatterChart = function (chart) {
1438
- waitForLoaded(function () {
1439
- var chartOptions = {};
1440
- var options = jsOptions(chart, chart.options, chartOptions);
1441
-
1442
- var series = chart.data, rows2 = [], i, j, data, d;
1443
- for (i = 0; i < series.length; i++) {
1444
- d = series[i].data;
1445
- for (j = 0; j < d.length; j++) {
1446
- var row = new Array(series.length + 1);
1447
- row[0] = d[j][0];
1448
- row[i + 1] = d[j][1];
1449
- rows2.push(row);
1450
- }
1451
- }
1452
-
1453
- data = new google.visualization.DataTable();
1454
- data.addColumn("number", "");
1455
- for (i = 0; i < series.length; i++) {
1456
- data.addColumn("number", series[i].name);
1457
- }
1458
- data.addRows(rows2);
1459
-
1460
- drawChart(chart, google.visualization.ScatterChart, data, options);
1461
- });
1462
- };
1463
-
1464
- var renderTimeline = function (chart) {
1465
- waitForLoaded("timeline", function () {
1466
- var chartOptions = {
1467
- legend: "none"
1468
- };
1469
-
1470
- if (chart.options.colors) {
1471
- chartOptions.colors = chart.options.colors;
1472
- }
1473
- var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});
1474
-
1475
- var data = new google.visualization.DataTable();
1476
- data.addColumn({type: "string", id: "Name"});
1477
- data.addColumn({type: "date", id: "Start"});
1478
- data.addColumn({type: "date", id: "End"});
1479
- data.addRows(chart.data);
1480
-
1481
- chart.element.style.lineHeight = "normal";
1482
-
1483
- drawChart(chart, google.visualization.Timeline, data, options);
1484
- });
1485
- };
1486
-
1487
- return {
1488
- name: "google",
1489
- renderLineChart: renderLineChart,
1490
- renderPieChart: renderPieChart,
1491
- renderColumnChart: renderColumnChart,
1492
- renderBarChart: renderBarChart,
1493
- renderAreaChart: renderAreaChart,
1494
- renderScatterChart: renderScatterChart,
1495
- renderGeoChart: renderGeoChart,
1496
- renderTimeline: renderTimeline
1497
- };
1498
- })();
1499
-
1500
- adapters.push(GoogleChartsAdapter);
1501
- }
1502
- }
1503
-
1504
- function dataEmpty(data, chartType) {
1505
- if (chartType === "PieChart" || chartType === "GeoChart" || chartType === "Timeline") {
1506
- return data.length === 0;
1507
- } else {
1508
- for (var i = 0; i < data.length; i++) {
1509
- if (data[i].data.length > 0) {
1510
- return false;
1511
- }
1512
- }
1513
- return true;
1514
- }
1515
- }
1516
-
1517
- function renderChart(chartType, chart) {
1518
- if (chart.options.messages && chart.options.messages.empty && dataEmpty(chart.data, chartType)) {
1519
- setText(chart.element, chart.options.messages.empty);
1520
- } else {
1521
- callAdapter(chartType, chart);
1522
- if (chart.options.download && !chart.downloadAttached && chart.adapter === "chartjs") {
1523
- addDownloadButton(chart);
1524
- }
1525
- }
1526
- }
1527
-
1528
- // TODO remove chartType if cross-browser way
1529
- // to get the name of the chart class
1530
- function callAdapter(chartType, chart) {
1531
- var i, adapter, fnName, adapterName;
1532
- fnName = "render" + chartType;
1533
- adapterName = chart.options.adapter;
1534
-
1535
- loadAdapters();
1536
-
1537
- for (i = 0; i < adapters.length; i++) {
1538
- adapter = adapters[i];
1539
- if ((!adapterName || adapterName === adapter.name) && isFunction(adapter[fnName])) {
1540
- chart.adapter = adapter.name;
1541
- return adapter[fnName](chart);
1542
- }
1543
- }
1544
- throw new Error("No adapter found");
1545
- }
1546
-
1547
- // process data
1548
-
1549
- var toFormattedKey = function (key, keyType) {
1550
- if (keyType === "number") {
1551
- key = toFloat(key);
1552
- } else if (keyType === "datetime") {
1553
- key = toDate(key);
1554
- } else {
1555
- key = toStr(key);
1556
- }
1557
- return key;
1558
- };
1559
-
1560
- var formatSeriesData = function (data, keyType) {
1561
- var r = [], key, j;
1562
- for (j = 0; j < data.length; j++) {
1563
- if (keyType === "bubble") {
1564
- r.push([toFloat(data[j][0]), toFloat(data[j][1]), toFloat(data[j][2])]);
1565
- } else {
1566
- key = toFormattedKey(data[j][0], keyType);
1567
- r.push([key, toFloat(data[j][1])]);
1568
- }
1569
- }
1570
- if (keyType === "datetime") {
1571
- r.sort(sortByTime);
1572
- } else if (keyType === "number") {
1573
- r.sort(sortByNumberSeries);
1574
- }
1575
- return r;
1576
- };
1577
-
1578
- function isMinute(d) {
1579
- return d.getMilliseconds() === 0 && d.getSeconds() === 0;
1580
- }
1581
-
1582
- function isHour(d) {
1583
- return isMinute(d) && d.getMinutes() === 0;
1584
- }
1585
-
1586
- function isDay(d) {
1587
- return isHour(d) && d.getHours() === 0;
1588
- }
1589
-
1590
- function isWeek(d, dayOfWeek) {
1591
- return isDay(d) && d.getDay() === dayOfWeek;
1592
- }
1593
-
1594
- function isMonth(d) {
1595
- return isDay(d) && d.getDate() === 1;
1596
- }
1597
-
1598
- function isYear(d) {
1599
- return isMonth(d) && d.getMonth() === 0;
1600
- }
1601
-
1602
- function isDate(obj) {
1603
- return !isNaN(toDate(obj)) && toStr(obj).length >= 6;
1604
- }
1605
-
1606
- function allZeros(data) {
1607
- var i, j, d;
1608
- for (i = 0; i < data.length; i++) {
1609
- d = data[i].data;
1610
- for (j = 0; j < d.length; j++) {
1611
- if (d[j][1] != 0) {
1612
- return false;
1613
- }
1614
- }
1615
- }
1616
- return true;
1617
- }
1618
-
1619
- function detectDiscrete(series) {
1620
- var i, j, data;
1621
- for (i = 0; i < series.length; i++) {
1622
- data = toArr(series[i].data);
1623
- for (j = 0; j < data.length; j++) {
1624
- if (!isDate(data[j][0])) {
1625
- return true;
1626
- }
1627
- }
1628
- }
1629
- return false;
1630
- }
1631
-
1632
- // creates a shallow copy of each element of the array
1633
- // elements are expected to be objects
1634
- function copySeries(series) {
1635
- var newSeries = [], i, j;
1636
- for (i = 0; i < series.length; i++) {
1637
- var copy = {};
1638
- for (j in series[i]) {
1639
- if (series[i].hasOwnProperty(j)) {
1640
- copy[j] = series[i][j];
1641
- }
1642
- }
1643
- newSeries.push(copy);
1644
- }
1645
- return newSeries;
1646
- }
1647
-
1648
- function processSeries(chart, keyType) {
1649
- var i;
1650
-
1651
- var opts = chart.options;
1652
- var series = chart.rawData;
1653
-
1654
- // see if one series or multiple
1655
- if (!isArray(series) || typeof series[0] !== "object" || isArray(series[0])) {
1656
- series = [{name: opts.label || "Value", data: series}];
1657
- chart.hideLegend = true;
1658
- } else {
1659
- chart.hideLegend = false;
1660
- }
1661
- if ((opts.discrete === null || opts.discrete === undefined) && keyType !== "bubble" && keyType !== "number") {
1662
- chart.discrete = detectDiscrete(series);
1663
- } else {
1664
- chart.discrete = opts.discrete;
1665
- }
1666
- if (chart.discrete) {
1667
- keyType = "string";
1668
- }
1669
- if (chart.options.xtype) {
1670
- keyType = chart.options.xtype;
1671
- }
1672
-
1673
- // right format
1674
- series = copySeries(series);
1675
- for (i = 0; i < series.length; i++) {
1676
- series[i].data = formatSeriesData(toArr(series[i].data), keyType);
1677
- }
1678
-
1679
- return series;
1680
- }
1681
-
1682
- function processSimple(chart) {
1683
- var perfectData = toArr(chart.rawData), i;
1684
- for (i = 0; i < perfectData.length; i++) {
1685
- perfectData[i] = [toStr(perfectData[i][0]), toFloat(perfectData[i][1])];
1686
- }
1687
- return perfectData;
1688
- }
1689
-
1690
- function processTime(chart)
1691
- {
1692
- var i, data = chart.rawData;
1693
- for (i = 0; i < data.length; i++) {
1694
- data[i][1] = toDate(data[i][1]);
1695
- data[i][2] = toDate(data[i][2]);
1696
- }
1697
- return data;
1698
- }
1699
-
1700
- function processLineData(chart) {
1701
- return processSeries(chart, "datetime");
1702
- }
1703
-
1704
- function processColumnData(chart) {
1705
- return processSeries(chart, "string");
1706
- }
1707
-
1708
- function processBarData(chart) {
1709
- return processSeries(chart, "string");
1710
- }
1711
-
1712
- function processAreaData(chart) {
1713
- return processSeries(chart, "datetime");
1714
- }
1715
-
1716
- function processScatterData(chart) {
1717
- return processSeries(chart, "number");
1718
- }
1719
-
1720
- function processBubbleData(chart) {
1721
- return processSeries(chart, "bubble");
1722
- }
1723
-
1724
- function createChart(chartType, chart, element, dataSource, opts, processData) {
1725
- var elementId;
1726
- if (typeof element === "string") {
1727
- elementId = element;
1728
- element = document.getElementById(element);
1729
- if (!element) {
1730
- throw new Error("No element with id " + elementId);
1731
- }
1732
- }
1733
-
1734
- chart.element = element;
1735
- opts = merge(Chartkick.options, opts || {});
1736
- chart.options = opts;
1737
- chart.dataSource = dataSource;
1738
-
1739
- if (!processData) {
1740
- processData = function (chart) {
1741
- return chart.rawData;
1742
- };
1743
- }
1744
-
1745
- // getters
1746
- chart.getElement = function () {
1747
- return element;
1748
- };
1749
- chart.getDataSource = function () {
1750
- return chart.dataSource;
1751
- };
1752
- chart.getData = function () {
1753
- return chart.data;
1754
- };
1755
- chart.getOptions = function () {
1756
- return chart.options;
1757
- };
1758
- chart.getChartObject = function () {
1759
- return chart.chart;
1760
- };
1761
- chart.getAdapter = function () {
1762
- return chart.adapter;
1763
- };
1764
-
1765
- var callback = function () {
1766
- chart.data = processData(chart);
1767
- renderChart(chartType, chart);
1768
- };
1769
-
1770
- // functions
1771
- chart.updateData = function (dataSource, options) {
1772
- chart.dataSource = dataSource;
1773
- if (options) {
1774
- chart.options = merge(Chartkick.options, options);
1775
- }
1776
- fetchDataSource(chart, callback, dataSource);
1777
- };
1778
- chart.setOptions = function (options) {
1779
- chart.options = merge(Chartkick.options, options);
1780
- chart.redraw();
1781
- };
1782
- chart.redraw = function() {
1783
- fetchDataSource(chart, callback, chart.rawData);
1784
- };
1785
- chart.refreshData = function () {
1786
- if (typeof chart.dataSource === "string") {
1787
- // prevent browser from caching
1788
- var sep = chart.dataSource.indexOf("?") === -1 ? "?" : "&";
1789
- var url = chart.dataSource + sep + "_=" + (new Date()).getTime();
1790
- fetchDataSource(chart, callback, url);
1791
- }
1792
- };
1793
- chart.stopRefresh = function () {
1794
- if (chart.intervalId) {
1795
- clearInterval(chart.intervalId);
1796
- }
1797
- };
1798
- chart.toImage = function () {
1799
- if (chart.adapter === "chartjs") {
1800
- return chart.chart.toBase64Image();
1801
- } else {
1802
- return null;
1803
- }
1804
- };
1805
-
1806
- Chartkick.charts[element.id] = chart;
1807
-
1808
- fetchDataSource(chart, callback, dataSource);
1809
-
1810
- if (opts.refresh) {
1811
- chart.intervalId = setInterval( function () {
1812
- chart.refreshData();
1813
- }, opts.refresh * 1000);
1814
- }
1815
- }
1816
-
1817
- // define classes
1818
-
1819
- Chartkick = {
1820
- LineChart: function (element, dataSource, options) {
1821
- createChart("LineChart", this, element, dataSource, options, processLineData);
1822
- },
1823
- PieChart: function (element, dataSource, options) {
1824
- createChart("PieChart", this, element, dataSource, options, processSimple);
1825
- },
1826
- ColumnChart: function (element, dataSource, options) {
1827
- createChart("ColumnChart", this, element, dataSource, options, processColumnData);
1828
- },
1829
- BarChart: function (element, dataSource, options) {
1830
- createChart("BarChart", this, element, dataSource, options, processBarData);
1831
- },
1832
- AreaChart: function (element, dataSource, options) {
1833
- createChart("AreaChart", this, element, dataSource, options, processAreaData);
1834
- },
1835
- GeoChart: function (element, dataSource, options) {
1836
- createChart("GeoChart", this, element, dataSource, options, processSimple);
1837
- },
1838
- ScatterChart: function (element, dataSource, options) {
1839
- createChart("ScatterChart", this, element, dataSource, options, processScatterData);
1840
- },
1841
- BubbleChart: function (element, dataSource, options) {
1842
- createChart("BubbleChart", this, element, dataSource, options, processBubbleData);
1843
- },
1844
- Timeline: function (element, dataSource, options) {
1845
- createChart("Timeline", this, element, dataSource, options, processTime);
1846
- },
1847
- charts: {},
1848
- configure: function (options) {
1849
- for (var key in options) {
1850
- if (options.hasOwnProperty(key)) {
1851
- config[key] = options[key];
1852
- }
1853
- }
1854
- },
1855
- eachChart: function (callback) {
1856
- for (var chartId in Chartkick.charts) {
1857
- if (Chartkick.charts.hasOwnProperty(chartId)) {
1858
- callback(Chartkick.charts[chartId]);
1859
- }
1860
- }
1861
- },
1862
- options: {},
1863
- adapters: adapters,
1864
- createChart: createChart
1865
- };
1866
-
1867
- if (typeof module === "object" && typeof module.exports === "object") {
1868
- module.exports = Chartkick;
1869
- } else {
1870
- window.Chartkick = Chartkick;
1871
- }
1872
- }(window));