ext_sprockets 0.1.1

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