ezii-os 1.1.0 → 2.0.1

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