smartxtrader 3.8.1-xm.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1270) hide show
  1. package/.babelrc +20 -0
  2. package/.dockerignore +5 -0
  3. package/.eslintignore +6 -0
  4. package/.eslintrc.js +81 -0
  5. package/.gitattributes +6 -0
  6. package/.stylelintrc.js +33 -0
  7. package/Dockerfile +14 -0
  8. package/Gruntfile.js +38 -0
  9. package/LICENSE +201 -0
  10. package/README.md +191 -0
  11. package/api/_lib/http_utils.js +150 -0
  12. package/api/_lib/legal_consent_store.js +108 -0
  13. package/api/_lib/telegram_session_store.js +182 -0
  14. package/api/_lib/telegram_subscription.js +507 -0
  15. package/api/deriv/auth.js +501 -0
  16. package/api/legal/accept.js +99 -0
  17. package/api/legal/delete.js +77 -0
  18. package/api/legal/status.js +71 -0
  19. package/api/logout.js +58 -0
  20. package/api/session-status.js +74 -0
  21. package/api/telegram/auth.js +117 -0
  22. package/api/telegram/control.js +10 -0
  23. package/api/telegram/logout.js +69 -0
  24. package/api/telegram/notify-login.js +79 -0
  25. package/api/telegram/status.js +153 -0
  26. package/api/telegram/webhook.js +1361 -0
  27. package/binary.com.conf +22 -0
  28. package/build/aliases.yaml +66 -0
  29. package/build/babel.js +19 -0
  30. package/build/checkDependencies.js +10 -0
  31. package/build/clean.js +5 -0
  32. package/build/concurrent.js +8 -0
  33. package/build/config/constants.js +54 -0
  34. package/build/config/helpers.js +37 -0
  35. package/build/config/init.js +48 -0
  36. package/build/connect.js +103 -0
  37. package/build/copy.js +30 -0
  38. package/build/cssmin.js +20 -0
  39. package/build/eslint.js +15 -0
  40. package/build/gh-pages.js +27 -0
  41. package/build/hashres.js +17 -0
  42. package/build/mochaTest.js +20 -0
  43. package/build/postcss.js +20 -0
  44. package/build/sass.js +17 -0
  45. package/build/shell.js +194 -0
  46. package/build/stylelint.js +13 -0
  47. package/build/watch.js +21 -0
  48. package/build/webpack/config_app.js +23 -0
  49. package/build/webpack/config_common.js +77 -0
  50. package/build/webpack/helpers.js +19 -0
  51. package/build/webpack/paths.js +11 -0
  52. package/build/webpack/plugins.js +84 -0
  53. package/build/webpack.js +23 -0
  54. package/crowdin.yaml +6 -0
  55. package/cyberpunk-ui/index.html +14 -0
  56. package/cyberpunk-ui/package-lock.json +6321 -0
  57. package/cyberpunk-ui/package.json +37 -0
  58. package/cyberpunk-ui/public/icons/icon-192.svg +21 -0
  59. package/cyberpunk-ui/public/icons/icon-512.svg +21 -0
  60. package/cyberpunk-ui/public/manifest.webmanifest +22 -0
  61. package/cyberpunk-ui/src/App.jsx +49 -0
  62. package/cyberpunk-ui/src/api/client.js +53 -0
  63. package/cyberpunk-ui/src/api/session.ts +42 -0
  64. package/cyberpunk-ui/src/components/chart/DigitDistributionTable.jsx +522 -0
  65. package/cyberpunk-ui/src/components/chart/TradingChart.jsx +45 -0
  66. package/cyberpunk-ui/src/components/common/InstrumentBadge.jsx +28 -0
  67. package/cyberpunk-ui/src/components/common/KeyboardShortcuts.jsx +47 -0
  68. package/cyberpunk-ui/src/components/common/NotificationsCenter.jsx +24 -0
  69. package/cyberpunk-ui/src/components/common/SubscriptionGate.jsx +388 -0
  70. package/cyberpunk-ui/src/components/layout/SplitLayout.jsx +65 -0
  71. package/cyberpunk-ui/src/components/layout/TradingBackground.jsx +210 -0
  72. package/cyberpunk-ui/src/components/legal/LegalGate.jsx +250 -0
  73. package/cyberpunk-ui/src/components/navigation/BottomNav.jsx +45 -0
  74. package/cyberpunk-ui/src/components/navigation/TopBar.jsx +98 -0
  75. package/cyberpunk-ui/src/components/panels/ChartPanel.jsx +92 -0
  76. package/cyberpunk-ui/src/components/panels/PositionsHistory.jsx +94 -0
  77. package/cyberpunk-ui/src/components/panels/TradePanel.jsx +450 -0
  78. package/cyberpunk-ui/src/components/panels/TransformerRangeModal.jsx +184 -0
  79. package/cyberpunk-ui/src/components/panels/Watchlist.jsx +81 -0
  80. package/cyberpunk-ui/src/components/settings/ChartSettingsPortal.jsx +66 -0
  81. package/cyberpunk-ui/src/components/settings/SettingsSheet.jsx +76 -0
  82. package/cyberpunk-ui/src/config/legal.js +104 -0
  83. package/cyberpunk-ui/src/config/smartanalizer.js +128 -0
  84. package/cyberpunk-ui/src/hooks/useAppLayout.js +34 -0
  85. package/cyberpunk-ui/src/main.jsx +21 -0
  86. package/cyberpunk-ui/src/pages/AuthPage.tsx +265 -0
  87. package/cyberpunk-ui/src/pages/Dashboard.jsx +55 -0
  88. package/cyberpunk-ui/src/pages/Markets.jsx +15 -0
  89. package/cyberpunk-ui/src/pages/RegisterPage.tsx +202 -0
  90. package/cyberpunk-ui/src/pages/SettingsPage.jsx +180 -0
  91. package/cyberpunk-ui/src/pages/Trades.jsx +12 -0
  92. package/cyberpunk-ui/src/routes/AppRouter.jsx +21 -0
  93. package/cyberpunk-ui/src/store/sessionSlice.js +94 -0
  94. package/cyberpunk-ui/src/store/settingsSlice.js +68 -0
  95. package/cyberpunk-ui/src/store/store.js +18 -0
  96. package/cyberpunk-ui/src/store/symbolsSlice.js +93 -0
  97. package/cyberpunk-ui/src/store/uiSlice.js +80 -0
  98. package/cyberpunk-ui/src/styles/global.css +1404 -0
  99. package/cyberpunk-ui/src/theme/ThemeProvider.jsx +47 -0
  100. package/cyberpunk-ui/src/utils/authToken.ts +99 -0
  101. package/cyberpunk-ui/src/utils/instrumentIcons.js +24 -0
  102. package/cyberpunk-ui/src/utils/persist.js +24 -0
  103. package/cyberpunk-ui/src/vite-env.d.ts +9 -0
  104. package/cyberpunk-ui/tsconfig.json +21 -0
  105. package/cyberpunk-ui/tsconfig.node.json +9 -0
  106. package/cyberpunk-ui/vite.config.js +34 -0
  107. package/docker-compose.portainer.yml +13 -0
  108. package/docker-compose.yml +13 -0
  109. package/docs/canvasjs-candlesticks.md +138 -0
  110. package/docs/portainer-deployment.md +22 -0
  111. package/docs/telegram-bridge.md +207 -0
  112. package/docs/telegram_bot_integration.md +172 -0
  113. package/docs/value-distribution-scheme.ru.md +35 -0
  114. package/favicon.ico +0 -0
  115. package/mobile/App.js +138 -0
  116. package/mobile/chartHtml.js +147 -0
  117. package/mobile/components/AnimatedBackground.js +145 -0
  118. package/mobile/components/ChartWebView.js +113 -0
  119. package/mobile/components/Controls.js +245 -0
  120. package/mobile/metro.config.js +17 -0
  121. package/mobile/theme.js +57 -0
  122. package/package.json +181 -0
  123. package/packages/canvasjs-runtime/LICENSE +201 -0
  124. package/packages/canvasjs-runtime/README.md +7 -0
  125. package/packages/canvasjs-runtime/index.js +18 -0
  126. package/packages/canvasjs-runtime/package.json +18 -0
  127. package/packages/webtrader-charts/.gitattributes +3 -0
  128. package/packages/webtrader-charts/LICENSE +201 -0
  129. package/packages/webtrader-charts/README.md +154 -0
  130. package/packages/webtrader-charts/package.json +17 -0
  131. package/packages/webtrader-charts/rollup.config.iife.mjs +6 -0
  132. package/packages/webtrader-charts/rollup.config.mjs +144 -0
  133. package/packages/webtrader-charts/src/chartDraw.js +171 -0
  134. package/packages/webtrader-charts/src/chartOptions.html +173 -0
  135. package/packages/webtrader-charts/src/chartOptions.js +412 -0
  136. package/packages/webtrader-charts/src/chartOptions.scss +368 -0
  137. package/packages/webtrader-charts/src/chartTemplateManager.html +74 -0
  138. package/packages/webtrader-charts/src/chartTemplateManager.js +305 -0
  139. package/packages/webtrader-charts/src/chartWindow.html +12 -0
  140. package/packages/webtrader-charts/src/chartWindow.js +224 -0
  141. package/packages/webtrader-charts/src/charts.js +689 -0
  142. package/packages/webtrader-charts/src/charts.scss +128 -0
  143. package/packages/webtrader-charts/src/common/chartingRequestMap.js +381 -0
  144. package/packages/webtrader-charts/src/common/currentprice.js +155 -0
  145. package/packages/webtrader-charts/src/common/globals.js +15 -0
  146. package/packages/webtrader-charts/src/common/highchartsMousewheel.js +50 -0
  147. package/packages/webtrader-charts/src/common/indicators.js +340 -0
  148. package/packages/webtrader-charts/src/common/liveapi.js +194 -0
  149. package/packages/webtrader-charts/src/common/notification.js +37 -0
  150. package/packages/webtrader-charts/src/common/ohlc_handler.js +160 -0
  151. package/packages/webtrader-charts/src/common/rivetsExtra.js +163 -0
  152. package/packages/webtrader-charts/src/common/stream_handler.js +164 -0
  153. package/packages/webtrader-charts/src/common/utils.js +121 -0
  154. package/packages/webtrader-charts/src/crosshair.js +24 -0
  155. package/packages/webtrader-charts/src/draw/horizontal_line.js +124 -0
  156. package/packages/webtrader-charts/src/draw/properties_selector.html +4 -0
  157. package/packages/webtrader-charts/src/draw/properties_selector.js +87 -0
  158. package/packages/webtrader-charts/src/draw/vertical_line.js +123 -0
  159. package/packages/webtrader-charts/src/i18n/ach.json +102 -0
  160. package/packages/webtrader-charts/src/i18n/ar.json +96 -0
  161. package/packages/webtrader-charts/src/i18n/build.js +35 -0
  162. package/packages/webtrader-charts/src/i18n/de.json +102 -0
  163. package/packages/webtrader-charts/src/i18n/dictionary.json +1 -0
  164. package/packages/webtrader-charts/src/i18n/en.json +102 -0
  165. package/packages/webtrader-charts/src/i18n/es.json +102 -0
  166. package/packages/webtrader-charts/src/i18n/fr.json +102 -0
  167. package/packages/webtrader-charts/src/i18n/id.json +102 -0
  168. package/packages/webtrader-charts/src/i18n/it.json +102 -0
  169. package/packages/webtrader-charts/src/i18n/ja.json +102 -0
  170. package/packages/webtrader-charts/src/i18n/pl.json +102 -0
  171. package/packages/webtrader-charts/src/i18n/pt.json +102 -0
  172. package/packages/webtrader-charts/src/i18n/ru.json +102 -0
  173. package/packages/webtrader-charts/src/i18n/th.json +102 -0
  174. package/packages/webtrader-charts/src/i18n/vi.json +102 -0
  175. package/packages/webtrader-charts/src/i18n/zh_cn.json +102 -0
  176. package/packages/webtrader-charts/src/i18n/zh_tw.json +102 -0
  177. package/packages/webtrader-charts/src/images/Dash.svg +1 -0
  178. package/packages/webtrader-charts/src/images/DashDot.svg +1 -0
  179. package/packages/webtrader-charts/src/images/Dot.svg +1 -0
  180. package/packages/webtrader-charts/src/images/LongDash.svg +1 -0
  181. package/packages/webtrader-charts/src/images/LongDashDot.svg +1 -0
  182. package/packages/webtrader-charts/src/images/LongDashDotDot.svg +1 -0
  183. package/packages/webtrader-charts/src/images/ShortDash.svg +1 -0
  184. package/packages/webtrader-charts/src/images/ShortDashDot.svg +1 -0
  185. package/packages/webtrader-charts/src/images/ShortDashDotDot.svg +1 -0
  186. package/packages/webtrader-charts/src/images/ShortDot.svg +1 -0
  187. package/packages/webtrader-charts/src/images/Solid.svg +1 -0
  188. package/packages/webtrader-charts/src/images/back-arrow-w.svg +1 -0
  189. package/packages/webtrader-charts/src/images/back-arrow.svg +1 -0
  190. package/packages/webtrader-charts/src/images/blogger.svg +1 -0
  191. package/packages/webtrader-charts/src/images/blue_up_arrow.svg +1 -0
  192. package/packages/webtrader-charts/src/images/circle-close.svg +1 -0
  193. package/packages/webtrader-charts/src/images/close-blue.svg +1 -0
  194. package/packages/webtrader-charts/src/images/close-white.svg +1 -0
  195. package/packages/webtrader-charts/src/images/close.svg +1 -0
  196. package/packages/webtrader-charts/src/images/favorite-active.svg +1 -0
  197. package/packages/webtrader-charts/src/images/favorite-normal.svg +1 -0
  198. package/packages/webtrader-charts/src/images/fb.svg +1 -0
  199. package/packages/webtrader-charts/src/images/g-plus.svg +1 -0
  200. package/packages/webtrader-charts/src/images/horizontal_line.svg +1 -0
  201. package/packages/webtrader-charts/src/images/ic-edit.svg +1 -0
  202. package/packages/webtrader-charts/src/images/ic-search.svg +1 -0
  203. package/packages/webtrader-charts/src/images/ic-tip.svg +1 -0
  204. package/packages/webtrader-charts/src/images/images.js +33 -0
  205. package/packages/webtrader-charts/src/images/indicators/Abandoned_baby.svg +1 -0
  206. package/packages/webtrader-charts/src/images/indicators/Advance_block.svg +1 -0
  207. package/packages/webtrader-charts/src/images/indicators/Bet_hold.svg +1 -0
  208. package/packages/webtrader-charts/src/images/indicators/Bullish Piercing.svg +1 -0
  209. package/packages/webtrader-charts/src/images/indicators/Dark_cloud_cover.svg +1 -0
  210. package/packages/webtrader-charts/src/images/indicators/Doji.svg +1 -0
  211. package/packages/webtrader-charts/src/images/indicators/Doji_star.svg +1 -0
  212. package/packages/webtrader-charts/src/images/indicators/Download.svg +1 -0
  213. package/packages/webtrader-charts/src/images/indicators/Dragonfly_doji.svg +1 -0
  214. package/packages/webtrader-charts/src/images/indicators/Engulfing_pattern.svg +1 -0
  215. package/packages/webtrader-charts/src/images/indicators/Inverted-hammer.svg +1 -0
  216. package/packages/webtrader-charts/src/images/indicators/breakaway_pattern.svg +1 -0
  217. package/packages/webtrader-charts/src/images/indicators/closing_marubozu.svg +1 -0
  218. package/packages/webtrader-charts/src/images/indicators/counterattack.svg +1 -0
  219. package/packages/webtrader-charts/src/images/indicators/down_fractal.svg +1 -0
  220. package/packages/webtrader-charts/src/images/indicators/evening_doji_star.svg +1 -0
  221. package/packages/webtrader-charts/src/images/indicators/evening_star.svg +1 -0
  222. package/packages/webtrader-charts/src/images/indicators/gap_three_methods.svg +1 -0
  223. package/packages/webtrader-charts/src/images/indicators/gravestone_doji.svg +1 -0
  224. package/packages/webtrader-charts/src/images/indicators/hammer.svg +1 -0
  225. package/packages/webtrader-charts/src/images/indicators/hanging_man.svg +1 -0
  226. package/packages/webtrader-charts/src/images/indicators/harami_cross.svg +1 -0
  227. package/packages/webtrader-charts/src/images/indicators/harami_pattern.svg +1 -0
  228. package/packages/webtrader-charts/src/images/indicators/high_wave.svg +1 -0
  229. package/packages/webtrader-charts/src/images/indicators/hikkake.svg +1 -0
  230. package/packages/webtrader-charts/src/images/indicators/homing_pigeon.svg +1 -0
  231. package/packages/webtrader-charts/src/images/indicators/identical_three_crows.svg +1 -0
  232. package/packages/webtrader-charts/src/images/indicators/in-neck.svg +1 -0
  233. package/packages/webtrader-charts/src/images/indicators/indicatorImages.js +126 -0
  234. package/packages/webtrader-charts/src/images/indicators/kicking.svg +1 -0
  235. package/packages/webtrader-charts/src/images/indicators/ladder-bottom.svg +1 -0
  236. package/packages/webtrader-charts/src/images/indicators/long-legged-doji.svg +1 -0
  237. package/packages/webtrader-charts/src/images/indicators/long-line-candles.svg +1 -0
  238. package/packages/webtrader-charts/src/images/indicators/marubozu.svg +1 -0
  239. package/packages/webtrader-charts/src/images/indicators/mat-hold.svg +1 -0
  240. package/packages/webtrader-charts/src/images/indicators/matching-low.svg +1 -0
  241. package/packages/webtrader-charts/src/images/indicators/morning-doji-start.svg +1 -0
  242. package/packages/webtrader-charts/src/images/indicators/morning-star.svg +1 -0
  243. package/packages/webtrader-charts/src/images/indicators/on-neck.svg +1 -0
  244. package/packages/webtrader-charts/src/images/indicators/rickshaw man.svg +1 -0
  245. package/packages/webtrader-charts/src/images/indicators/rising falling three methods.svg +1 -0
  246. package/packages/webtrader-charts/src/images/indicators/salled pattern.svg +1 -0
  247. package/packages/webtrader-charts/src/images/indicators/separating lines.svg +1 -0
  248. package/packages/webtrader-charts/src/images/indicators/shooting star.svg +1 -0
  249. package/packages/webtrader-charts/src/images/indicators/short line candle.svg +1 -0
  250. package/packages/webtrader-charts/src/images/indicators/side by side white line.svg +1 -0
  251. package/packages/webtrader-charts/src/images/indicators/spinning top.svg +1 -0
  252. package/packages/webtrader-charts/src/images/indicators/stick sandwich.svg +1 -0
  253. package/packages/webtrader-charts/src/images/indicators/takuri line.svg +1 -0
  254. package/packages/webtrader-charts/src/images/indicators/tasuki gap.svg +1 -0
  255. package/packages/webtrader-charts/src/images/indicators/three_black_crows.svg +1 -0
  256. package/packages/webtrader-charts/src/images/indicators/three_inside_up_down.svg +1 -0
  257. package/packages/webtrader-charts/src/images/indicators/three_line_strike.svg +1 -0
  258. package/packages/webtrader-charts/src/images/indicators/three_outside_up_down.svg +1 -0
  259. package/packages/webtrader-charts/src/images/indicators/three_river.svg +1 -0
  260. package/packages/webtrader-charts/src/images/indicators/three_stars_in_the_south.svg +1 -0
  261. package/packages/webtrader-charts/src/images/indicators/three_white_soldiers.svg +1 -0
  262. package/packages/webtrader-charts/src/images/indicators/thrusting_pattern.svg +1 -0
  263. package/packages/webtrader-charts/src/images/indicators/tristar.svg +1 -0
  264. package/packages/webtrader-charts/src/images/indicators/two_crows.svg +1 -0
  265. package/packages/webtrader-charts/src/images/indicators/typprice.svg +1 -0
  266. package/packages/webtrader-charts/src/images/indicators/up_fractal.svg +1 -0
  267. package/packages/webtrader-charts/src/images/indicators/upside_gap_two_crows.svg +1 -0
  268. package/packages/webtrader-charts/src/images/maximize.svg +1 -0
  269. package/packages/webtrader-charts/src/images/minimize.svg +1 -0
  270. package/packages/webtrader-charts/src/images/orange_down_arrow.svg +1 -0
  271. package/packages/webtrader-charts/src/images/twitter.svg +1 -0
  272. package/packages/webtrader-charts/src/images/vertical_line.svg +1 -0
  273. package/packages/webtrader-charts/src/images/vk.svg +1 -0
  274. package/packages/webtrader-charts/src/index.js +61 -0
  275. package/packages/webtrader-charts/src/index.scss +5 -0
  276. package/packages/webtrader-charts/src/indicatorBuilder.html +141 -0
  277. package/packages/webtrader-charts/src/indicatorBuilder.js +157 -0
  278. package/packages/webtrader-charts/src/indicatorBuilder.scss +386 -0
  279. package/packages/webtrader-charts/src/indicatorManagement.html +123 -0
  280. package/packages/webtrader-charts/src/indicatorManagement.js +217 -0
  281. package/packages/webtrader-charts/src/indicatorManagement.scss +264 -0
  282. package/packages/webtrader-charts/src/indicators/ATR.js +130 -0
  283. package/packages/webtrader-charts/src/indicators/BOP.js +86 -0
  284. package/packages/webtrader-charts/src/indicators/IndicatorBase.js +119 -0
  285. package/packages/webtrader-charts/src/indicators/NATR.js +63 -0
  286. package/packages/webtrader-charts/src/indicators/ROCP.js +64 -0
  287. package/packages/webtrader-charts/src/indicators/ROCR.js +64 -0
  288. package/packages/webtrader-charts/src/indicators/STDDEV.js +107 -0
  289. package/packages/webtrader-charts/src/indicators/WILLR.js +64 -0
  290. package/packages/webtrader-charts/src/indicators/adx.js +115 -0
  291. package/packages/webtrader-charts/src/indicators/adxr.js +53 -0
  292. package/packages/webtrader-charts/src/indicators/alligator.js +140 -0
  293. package/packages/webtrader-charts/src/indicators/alma.js +80 -0
  294. package/packages/webtrader-charts/src/indicators/ao.js +119 -0
  295. package/packages/webtrader-charts/src/indicators/apo.js +57 -0
  296. package/packages/webtrader-charts/src/indicators/aroon.js +173 -0
  297. package/packages/webtrader-charts/src/indicators/aroonosc.js +75 -0
  298. package/packages/webtrader-charts/src/indicators/bbands.js +204 -0
  299. package/packages/webtrader-charts/src/indicators/cc.js +51 -0
  300. package/packages/webtrader-charts/src/indicators/cci.js +97 -0
  301. package/packages/webtrader-charts/src/indicators/cdl-mangled-props.js +1135 -0
  302. package/packages/webtrader-charts/src/indicators/cdl.js +1694 -0
  303. package/packages/webtrader-charts/src/indicators/chop.js +79 -0
  304. package/packages/webtrader-charts/src/indicators/cks.js +190 -0
  305. package/packages/webtrader-charts/src/indicators/cmo.js +104 -0
  306. package/packages/webtrader-charts/src/indicators/dc.js +175 -0
  307. package/packages/webtrader-charts/src/indicators/dema.js +70 -0
  308. package/packages/webtrader-charts/src/indicators/dx.js +162 -0
  309. package/packages/webtrader-charts/src/indicators/ema.js +66 -0
  310. package/packages/webtrader-charts/src/indicators/fractal.js +162 -0
  311. package/packages/webtrader-charts/src/indicators/hma.js +74 -0
  312. package/packages/webtrader-charts/src/indicators/ichimoku.js +246 -0
  313. package/packages/webtrader-charts/src/indicators/index.js +73 -0
  314. package/packages/webtrader-charts/src/indicators/kama.js +83 -0
  315. package/packages/webtrader-charts/src/indicators/lsma.js +71 -0
  316. package/packages/webtrader-charts/src/indicators/lwma.js +75 -0
  317. package/packages/webtrader-charts/src/indicators/macd.js +188 -0
  318. package/packages/webtrader-charts/src/indicators/mama.js +178 -0
  319. package/packages/webtrader-charts/src/indicators/mass.js +93 -0
  320. package/packages/webtrader-charts/src/indicators/max.js +61 -0
  321. package/packages/webtrader-charts/src/indicators/min.js +61 -0
  322. package/packages/webtrader-charts/src/indicators/mom.js +63 -0
  323. package/packages/webtrader-charts/src/indicators/ppo.js +200 -0
  324. package/packages/webtrader-charts/src/indicators/roc.js +63 -0
  325. package/packages/webtrader-charts/src/indicators/rsi.js +75 -0
  326. package/packages/webtrader-charts/src/indicators/sar.js +216 -0
  327. package/packages/webtrader-charts/src/indicators/sma.js +71 -0
  328. package/packages/webtrader-charts/src/indicators/smma.js +81 -0
  329. package/packages/webtrader-charts/src/indicators/stoch.js +169 -0
  330. package/packages/webtrader-charts/src/indicators/stochf.js +140 -0
  331. package/packages/webtrader-charts/src/indicators/stochrsi.js +70 -0
  332. package/packages/webtrader-charts/src/indicators/stochs.js +141 -0
  333. package/packages/webtrader-charts/src/indicators/sum.js +60 -0
  334. package/packages/webtrader-charts/src/indicators/t3.js +119 -0
  335. package/packages/webtrader-charts/src/indicators/tema.js +81 -0
  336. package/packages/webtrader-charts/src/indicators/trange.js +75 -0
  337. package/packages/webtrader-charts/src/indicators/trima.js +73 -0
  338. package/packages/webtrader-charts/src/indicators/typprice.js +50 -0
  339. package/packages/webtrader-charts/src/indicators/ultosc.js +103 -0
  340. package/packages/webtrader-charts/src/indicators/var.js +96 -0
  341. package/packages/webtrader-charts/src/indicators/wclprice.js +51 -0
  342. package/packages/webtrader-charts/src/indicators/wma.js +79 -0
  343. package/packages/webtrader-charts/src/indicators-config.js +2138 -0
  344. package/packages/webtrader-charts/src/lib/jquery.ddslick.js +361 -0
  345. package/packages/webtrader-charts/src/lib/leanModal.js +81 -0
  346. package/packages/webtrader-charts/src/lib/leanModal.scss +52 -0
  347. package/packages/webtrader-charts/src/lib/spectrum.js +2323 -0
  348. package/packages/webtrader-charts/src/lib/spectrum.scss +507 -0
  349. package/packages/webtrader-charts/src/lib/toastr.js +380 -0
  350. package/packages/webtrader-charts/src/lib/toastr.scss +161 -0
  351. package/packages/webtrader-charts/src/mobileview.scss +29 -0
  352. package/packages/webtrader-charts/src/overlayManagement.html +30 -0
  353. package/packages/webtrader-charts/src/overlayManagement.js +297 -0
  354. package/packages/webtrader-charts/src/overlayManagement.scss +77 -0
  355. package/packages/webtrader-charts/src/tableView.html +28 -0
  356. package/packages/webtrader-charts/src/tableView.js +166 -0
  357. package/packages/webtrader-charts/src/tableView.scss +15 -0
  358. package/scripts/README.md +68 -0
  359. package/scripts/__tests__/static_strings.js +32 -0
  360. package/scripts/__tests__/svg_test.js +47 -0
  361. package/scripts/common.js +93 -0
  362. package/scripts/config/pages.js +124 -0
  363. package/scripts/config/sitemap_urls.js +56 -0
  364. package/scripts/extract_js_texts.js +180 -0
  365. package/scripts/gettext.js +155 -0
  366. package/scripts/js_texts/extracted_strings_app.js +520 -0
  367. package/scripts/js_texts/static_strings_app.js +62 -0
  368. package/scripts/js_translation.js +99 -0
  369. package/scripts/render.js +406 -0
  370. package/scripts/sitemap.js +68 -0
  371. package/scripts/ssr-scriptjs-shim.js +5 -0
  372. package/scripts/update_translations.sh +76 -0
  373. package/src/download/fonts/binary_symbols.woff +0 -0
  374. package/src/download/fonts/guide/casino_hand-webfont.eot +0 -0
  375. package/src/download/fonts/guide/casino_hand-webfont.svg +243 -0
  376. package/src/download/fonts/guide/casino_hand-webfont.ttf +0 -0
  377. package/src/download/fonts/guide/casino_hand-webfont.woff +0 -0
  378. package/src/images/common/authenticated.svg +1 -0
  379. package/src/images/common/close_icon.svg +1 -0
  380. package/src/images/common/email_sent.svg +1 -0
  381. package/src/images/common/globe-with_logo.svg +1 -0
  382. package/src/images/common/ic-anchor.svg +1 -0
  383. package/src/images/common/livechat.svg +1 -0
  384. package/src/images/common/logos/ic-brand-binarybot (2).svg +18 -0
  385. package/src/images/common/logos/ic-brand-binarybot.svg +21 -0
  386. package/src/images/common/logos/ic-brand-dbot.svg +1 -0
  387. package/src/images/common/logos/ic-brand-dmt5.svg +1 -0
  388. package/src/images/common/logos/ic-brand-dtrade2.svg +1 -0
  389. package/src/images/common/logos/ic-brand-dtrader.svg +36 -0
  390. package/src/images/common/logos/ic-brand-dxtrade.svg +1 -0
  391. package/src/images/common/logos/icon_smarttrader.svg +1 -0
  392. package/src/images/common/logos/xxhdpi.png +0 -0
  393. package/src/images/common/og_image.gif +0 -0
  394. package/src/images/common/plus.svg +1 -0
  395. package/src/images/common/scrollup_icon.svg +1 -0
  396. package/src/images/languages/ic-flag-de.svg +1 -0
  397. package/src/images/languages/ic-flag-en.svg +1 -0
  398. package/src/images/languages/ic-flag-es.svg +1 -0
  399. package/src/images/languages/ic-flag-fr.svg +1 -0
  400. package/src/images/languages/ic-flag-id.svg +1 -0
  401. package/src/images/languages/ic-flag-it.svg +1 -0
  402. package/src/images/languages/ic-flag-pl.svg +1 -0
  403. package/src/images/languages/ic-flag-pt.svg +1 -0
  404. package/src/images/languages/ic-flag-ru.svg +1 -0
  405. package/src/images/languages/ic-flag-th.svg +1 -0
  406. package/src/images/languages/ic-flag-uk.svg +1 -0
  407. package/src/images/languages/ic-flag-vi.svg +1 -0
  408. package/src/images/languages/ic-flag-zh_cn.svg +1 -0
  409. package/src/images/languages/ic-flag-zh_tw.svg +1 -0
  410. package/src/images/pages/contact/chat-icon.svg +1 -0
  411. package/src/images/pages/contact/search-icon.svg +1 -0
  412. package/src/images/pages/footer/ic-fullscreen.svg +1 -0
  413. package/src/images/pages/footer/ic-help-centre.svg +66 -0
  414. package/src/images/pages/footer/ic-livechat.svg +4 -0
  415. package/src/images/pages/footer/ic-whatsapp.svg +6 -0
  416. package/src/images/pages/header/copytrader.png +0 -0
  417. package/src/images/pages/header/copytrader.svg +8 -0
  418. package/src/images/pages/header/deriv-com-logo.svg +1 -0
  419. package/src/images/pages/header/deriv-com-logo1.svg +1 -0
  420. package/src/images/pages/header/deriv-logo.svg +8 -0
  421. package/src/images/pages/header/header.svg +63 -0
  422. package/src/images/pages/header/ic-add-account.svg +1 -0
  423. package/src/images/pages/header/ic-alert-danger.svg +1 -0
  424. package/src/images/pages/header/ic-alert-info.svg +1 -0
  425. package/src/images/pages/header/ic-alert-success.svg +1 -0
  426. package/src/images/pages/header/ic-alert-warning.svg +1 -0
  427. package/src/images/pages/header/ic-appstore-home.svg +1 -0
  428. package/src/images/pages/header/ic-bell.svg +1 -0
  429. package/src/images/pages/header/ic-box.svg +1 -0
  430. package/src/images/pages/header/ic-brand-binarybot.svg +21 -0
  431. package/src/images/pages/header/ic-brand-dbot.svg +31 -0
  432. package/src/images/pages/header/ic-brand-dtrader.svg +25 -0
  433. package/src/images/pages/header/ic-cashier.svg +1 -0
  434. package/src/images/pages/header/ic-chevron-down.svg +1 -0
  435. package/src/images/pages/header/ic-chevron-left.svg +1 -0
  436. package/src/images/pages/header/ic-chevron-right.svg +1 -0
  437. package/src/images/pages/header/ic-close.svg +1 -0
  438. package/src/images/pages/header/ic-currency-aud.svg +1 -0
  439. package/src/images/pages/header/ic-currency-bch.svg +1 -0
  440. package/src/images/pages/header/ic-currency-btc.svg +1 -0
  441. package/src/images/pages/header/ic-currency-dai.svg +1 -0
  442. package/src/images/pages/header/ic-currency-eth.svg +1 -0
  443. package/src/images/pages/header/ic-currency-eur.svg +1 -0
  444. package/src/images/pages/header/ic-currency-eusdt.svg +1 -0
  445. package/src/images/pages/header/ic-currency-gbp.svg +1 -0
  446. package/src/images/pages/header/ic-currency-ltc.svg +1 -0
  447. package/src/images/pages/header/ic-currency-tusdt.svg +1 -0
  448. package/src/images/pages/header/ic-currency-unknown.svg +1 -0
  449. package/src/images/pages/header/ic-currency-usd.svg +1 -0
  450. package/src/images/pages/header/ic-currency-usdc.svg +1 -0
  451. package/src/images/pages/header/ic-currency-ust.svg +1 -0
  452. package/src/images/pages/header/ic-currency-virtual.svg +1 -0
  453. package/src/images/pages/header/ic-hamburger.svg +1 -0
  454. package/src/images/pages/header/ic-help-centre.svg +66 -0
  455. package/src/images/pages/header/ic-livechat.svg +1 -0
  456. package/src/images/pages/header/ic-logout.svg +1 -0
  457. package/src/images/pages/header/ic-portfolio.svg +1 -0
  458. package/src/images/pages/header/ic-profit-table.svg +1 -0
  459. package/src/images/pages/header/ic-reports.svg +1 -0
  460. package/src/images/pages/header/ic-statement.svg +1 -0
  461. package/src/images/pages/header/ic-trade.svg +23 -0
  462. package/src/images/pages/header/ic-user-outline.svg +1 -0
  463. package/src/images/pages/header/ic-whatsapp.svg +1 -0
  464. package/src/images/pages/header/logo_smart_trader.svg +1811 -0
  465. package/src/images/pages/header/mobile-menu/mobile-menu-appstore.svg +5 -0
  466. package/src/images/pages/header/mobile-menu/mobile-menu-arrow-down.svg +3 -0
  467. package/src/images/pages/header/mobile-menu/mobile-menu-arrow-left.svg +3 -0
  468. package/src/images/pages/header/mobile-menu/mobile-menu-arrow-right.svg +3 -0
  469. package/src/images/pages/header/mobile-menu/mobile-menu-gmail.svg +4 -0
  470. package/src/images/pages/header/mobile-menu/mobile-menu-kodxyz.svg +5 -0
  471. package/src/images/pages/header/mobile-menu/mobile-menu-livechat.svg +6 -0
  472. package/src/images/pages/header/mobile-menu/mobile-menu-logo.svg +5 -0
  473. package/src/images/pages/header/mobile-menu/mobile-menu-logout.svg +5 -0
  474. package/src/images/pages/header/mobile-menu/mobile-menu-platform-dbot.svg +6 -0
  475. package/src/images/pages/header/mobile-menu/mobile-menu-platform-dtrader.svg +4 -0
  476. package/src/images/pages/header/mobile-menu/mobile-menu-platform-smarttrader.svg +4 -0
  477. package/src/images/pages/header/mobile-menu/mobile-menu-portfolio.svg +4 -0
  478. package/src/images/pages/header/mobile-menu/mobile-menu-profit.svg +4 -0
  479. package/src/images/pages/header/mobile-menu/mobile-menu-reports.svg +4 -0
  480. package/src/images/pages/header/mobile-menu/mobile-menu-statement.svg +6 -0
  481. package/src/images/pages/header/mobile-menu/mobile-menu-trade.svg +5 -0
  482. package/src/images/pages/header/wallets/ic-wallets-combined-aud.svg +1 -0
  483. package/src/images/pages/header/wallets/ic-wallets-combined-btc.svg +1 -0
  484. package/src/images/pages/header/wallets/ic-wallets-combined-eth.svg +1 -0
  485. package/src/images/pages/header/wallets/ic-wallets-combined-eur.svg +1 -0
  486. package/src/images/pages/header/wallets/ic-wallets-combined-eusdt.svg +1 -0
  487. package/src/images/pages/header/wallets/ic-wallets-combined-gbp.svg +1 -0
  488. package/src/images/pages/header/wallets/ic-wallets-combined-ltc.svg +1 -0
  489. package/src/images/pages/header/wallets/ic-wallets-combined-tusdt.svg +1 -0
  490. package/src/images/pages/header/wallets/ic-wallets-combined-usd.svg +1 -0
  491. package/src/images/pages/header/wallets/ic-wallets-combined-usdc.svg +1 -0
  492. package/src/images/pages/header/wallets/ic-wallets-combined-virtual.svg +1 -0
  493. package/src/images/pages/header/wallets/ic-wallets-currency-aud.svg +1 -0
  494. package/src/images/pages/header/wallets/ic-wallets-currency-btc.svg +1 -0
  495. package/src/images/pages/header/wallets/ic-wallets-currency-eth.svg +1 -0
  496. package/src/images/pages/header/wallets/ic-wallets-currency-eur.svg +1 -0
  497. package/src/images/pages/header/wallets/ic-wallets-currency-eusdt.svg +1 -0
  498. package/src/images/pages/header/wallets/ic-wallets-currency-gbp.svg +1 -0
  499. package/src/images/pages/header/wallets/ic-wallets-currency-ltc.svg +1 -0
  500. package/src/images/pages/header/wallets/ic-wallets-currency-tusdt.svg +1 -0
  501. package/src/images/pages/header/wallets/ic-wallets-currency-usd.svg +1 -0
  502. package/src/images/pages/header/wallets/ic-wallets-currency-usdc.svg +1 -0
  503. package/src/images/pages/header/wallets/ic-wallets-currency-virtual.svg +1 -0
  504. package/src/images/pages/header/wallets/ic-wallets-deriv-apps.svg +8 -0
  505. package/src/images/pages/header/wallets/wallet-apps-logo.svg +1 -0
  506. package/src/images/pages/header/wallets/wallet-deriv-logo.svg +8 -0
  507. package/src/images/pages/home/arrow_left.svg +1 -0
  508. package/src/images/pages/home/arrow_right.svg +1 -0
  509. package/src/images/pages/set_currency/aud.svg +1 -0
  510. package/src/images/pages/set_currency/bch.svg +1 -0
  511. package/src/images/pages/set_currency/btc.svg +1 -0
  512. package/src/images/pages/set_currency/busd.svg +1 -0
  513. package/src/images/pages/set_currency/dai.svg +1 -0
  514. package/src/images/pages/set_currency/etc.svg +1 -0
  515. package/src/images/pages/set_currency/eth.svg +1 -0
  516. package/src/images/pages/set_currency/eur.svg +1 -0
  517. package/src/images/pages/set_currency/eurs.svg +1 -0
  518. package/src/images/pages/set_currency/eusdt.svg +1 -0
  519. package/src/images/pages/set_currency/gbp.svg +1 -0
  520. package/src/images/pages/set_currency/idk.svg +1 -0
  521. package/src/images/pages/set_currency/ltc.svg +1 -0
  522. package/src/images/pages/set_currency/pax.svg +1 -0
  523. package/src/images/pages/set_currency/tick-normal.svg +1 -0
  524. package/src/images/pages/set_currency/tick-selected.svg +1 -0
  525. package/src/images/pages/set_currency/tusd.svg +1 -0
  526. package/src/images/pages/set_currency/usb.svg +1 -0
  527. package/src/images/pages/set_currency/usd.svg +1 -0
  528. package/src/images/pages/set_currency/usdc.svg +1 -0
  529. package/src/images/pages/set_currency/usdk.svg +1 -0
  530. package/src/images/pages/set_currency/ust.svg +1 -0
  531. package/src/images/pages/trade/call_spread.svg +1 -0
  532. package/src/images/pages/trade/chart_payout_range.svg +1 -0
  533. package/src/images/pages/trade/ic_arrow_dropdown_light.svg +1 -0
  534. package/src/images/pages/trade/put_spread.svg +1 -0
  535. package/src/images/pages/trade-explanation/de/close-low.svg +1 -0
  536. package/src/images/pages/trade-explanation/de/differs.svg +1 -0
  537. package/src/images/pages/trade-explanation/de/down.svg +1 -0
  538. package/src/images/pages/trade-explanation/de/ends-between.svg +1 -0
  539. package/src/images/pages/trade-explanation/de/ends-outside.svg +1 -0
  540. package/src/images/pages/trade-explanation/de/even.svg +1 -0
  541. package/src/images/pages/trade-explanation/de/falls.svg +1 -0
  542. package/src/images/pages/trade-explanation/de/goes-outside.svg +1 -0
  543. package/src/images/pages/trade-explanation/de/high-close.svg +1 -0
  544. package/src/images/pages/trade-explanation/de/high-low.svg +1 -0
  545. package/src/images/pages/trade-explanation/de/high-tick.svg +1 -0
  546. package/src/images/pages/trade-explanation/de/higher.svg +1 -0
  547. package/src/images/pages/trade-explanation/de/low-tick.svg +1 -0
  548. package/src/images/pages/trade-explanation/de/lower.svg +1 -0
  549. package/src/images/pages/trade-explanation/de/matches.svg +1 -0
  550. package/src/images/pages/trade-explanation/de/no-touch.svg +1 -0
  551. package/src/images/pages/trade-explanation/de/odd.svg +1 -0
  552. package/src/images/pages/trade-explanation/de/only-downs.svg +1 -0
  553. package/src/images/pages/trade-explanation/de/only-ups.svg +1 -0
  554. package/src/images/pages/trade-explanation/de/over.svg +1 -0
  555. package/src/images/pages/trade-explanation/de/reset-call.svg +1 -0
  556. package/src/images/pages/trade-explanation/de/reset-put.svg +1 -0
  557. package/src/images/pages/trade-explanation/de/rises.svg +1 -0
  558. package/src/images/pages/trade-explanation/de/stays-between.svg +1 -0
  559. package/src/images/pages/trade-explanation/de/touch.svg +1 -0
  560. package/src/images/pages/trade-explanation/de/under.svg +1 -0
  561. package/src/images/pages/trade-explanation/de/up.svg +1 -0
  562. package/src/images/pages/trade-explanation/en/call-spread.svg +1 -0
  563. package/src/images/pages/trade-explanation/en/close-low.svg +1 -0
  564. package/src/images/pages/trade-explanation/en/differs.svg +1 -0
  565. package/src/images/pages/trade-explanation/en/down.svg +1 -0
  566. package/src/images/pages/trade-explanation/en/ends-between.svg +1 -0
  567. package/src/images/pages/trade-explanation/en/ends-outside.svg +1 -0
  568. package/src/images/pages/trade-explanation/en/even.svg +1 -0
  569. package/src/images/pages/trade-explanation/en/falls.svg +1 -0
  570. package/src/images/pages/trade-explanation/en/goes-outside.svg +1 -0
  571. package/src/images/pages/trade-explanation/en/high-close.svg +1 -0
  572. package/src/images/pages/trade-explanation/en/high-low.svg +1 -0
  573. package/src/images/pages/trade-explanation/en/high-tick.svg +1 -0
  574. package/src/images/pages/trade-explanation/en/higher.svg +1 -0
  575. package/src/images/pages/trade-explanation/en/low-tick.svg +1 -0
  576. package/src/images/pages/trade-explanation/en/lower.svg +1 -0
  577. package/src/images/pages/trade-explanation/en/matches.svg +1 -0
  578. package/src/images/pages/trade-explanation/en/no-touch.svg +1 -0
  579. package/src/images/pages/trade-explanation/en/odd.svg +1 -0
  580. package/src/images/pages/trade-explanation/en/only-downs.svg +1 -0
  581. package/src/images/pages/trade-explanation/en/only-ups.svg +1 -0
  582. package/src/images/pages/trade-explanation/en/over.svg +1 -0
  583. package/src/images/pages/trade-explanation/en/put-spread.svg +1 -0
  584. package/src/images/pages/trade-explanation/en/reset-call.svg +1 -0
  585. package/src/images/pages/trade-explanation/en/reset-put.svg +1 -0
  586. package/src/images/pages/trade-explanation/en/rises.svg +1 -0
  587. package/src/images/pages/trade-explanation/en/stays-between.svg +1 -0
  588. package/src/images/pages/trade-explanation/en/touch.svg +1 -0
  589. package/src/images/pages/trade-explanation/en/under.svg +1 -0
  590. package/src/images/pages/trade-explanation/en/up.svg +1 -0
  591. package/src/images/pages/trade-explanation/es/close-low.svg +1 -0
  592. package/src/images/pages/trade-explanation/es/differs.svg +1 -0
  593. package/src/images/pages/trade-explanation/es/down.svg +1 -0
  594. package/src/images/pages/trade-explanation/es/ends-between.svg +1 -0
  595. package/src/images/pages/trade-explanation/es/ends-outside.svg +1 -0
  596. package/src/images/pages/trade-explanation/es/even.svg +1 -0
  597. package/src/images/pages/trade-explanation/es/falls.svg +1 -0
  598. package/src/images/pages/trade-explanation/es/goes-outside.svg +1 -0
  599. package/src/images/pages/trade-explanation/es/high-close.svg +1 -0
  600. package/src/images/pages/trade-explanation/es/high-low.svg +1 -0
  601. package/src/images/pages/trade-explanation/es/high-tick.svg +1 -0
  602. package/src/images/pages/trade-explanation/es/higher.svg +1 -0
  603. package/src/images/pages/trade-explanation/es/low-tick.svg +1 -0
  604. package/src/images/pages/trade-explanation/es/lower.svg +1 -0
  605. package/src/images/pages/trade-explanation/es/matches.svg +1 -0
  606. package/src/images/pages/trade-explanation/es/no-touch.svg +1 -0
  607. package/src/images/pages/trade-explanation/es/odd.svg +1 -0
  608. package/src/images/pages/trade-explanation/es/only-downs.svg +1 -0
  609. package/src/images/pages/trade-explanation/es/only-ups.svg +1 -0
  610. package/src/images/pages/trade-explanation/es/over.svg +1 -0
  611. package/src/images/pages/trade-explanation/es/reset-call.svg +1 -0
  612. package/src/images/pages/trade-explanation/es/reset-put.svg +1 -0
  613. package/src/images/pages/trade-explanation/es/rises.svg +1 -0
  614. package/src/images/pages/trade-explanation/es/stays-between.svg +1 -0
  615. package/src/images/pages/trade-explanation/es/touch.svg +1 -0
  616. package/src/images/pages/trade-explanation/es/under.svg +1 -0
  617. package/src/images/pages/trade-explanation/es/up.svg +1 -0
  618. package/src/images/pages/trade-explanation/fr/close-low.svg +1 -0
  619. package/src/images/pages/trade-explanation/fr/differs.svg +1 -0
  620. package/src/images/pages/trade-explanation/fr/down.svg +1 -0
  621. package/src/images/pages/trade-explanation/fr/ends-between.svg +1 -0
  622. package/src/images/pages/trade-explanation/fr/ends-outside.svg +1 -0
  623. package/src/images/pages/trade-explanation/fr/even.svg +1 -0
  624. package/src/images/pages/trade-explanation/fr/falls.svg +1 -0
  625. package/src/images/pages/trade-explanation/fr/goes-outside.svg +1 -0
  626. package/src/images/pages/trade-explanation/fr/high-close.svg +1 -0
  627. package/src/images/pages/trade-explanation/fr/high-low.svg +1 -0
  628. package/src/images/pages/trade-explanation/fr/high-tick.svg +1 -0
  629. package/src/images/pages/trade-explanation/fr/higher.svg +1 -0
  630. package/src/images/pages/trade-explanation/fr/low-tick.svg +1 -0
  631. package/src/images/pages/trade-explanation/fr/lower.svg +1 -0
  632. package/src/images/pages/trade-explanation/fr/matches.svg +1 -0
  633. package/src/images/pages/trade-explanation/fr/no-touch.svg +1 -0
  634. package/src/images/pages/trade-explanation/fr/odd.svg +1 -0
  635. package/src/images/pages/trade-explanation/fr/only-downs.svg +1 -0
  636. package/src/images/pages/trade-explanation/fr/only-ups.svg +1 -0
  637. package/src/images/pages/trade-explanation/fr/over.svg +1 -0
  638. package/src/images/pages/trade-explanation/fr/reset-call.svg +1 -0
  639. package/src/images/pages/trade-explanation/fr/reset-put.svg +1 -0
  640. package/src/images/pages/trade-explanation/fr/rises.svg +1 -0
  641. package/src/images/pages/trade-explanation/fr/stays-between.svg +1 -0
  642. package/src/images/pages/trade-explanation/fr/touch.svg +1 -0
  643. package/src/images/pages/trade-explanation/fr/under.svg +1 -0
  644. package/src/images/pages/trade-explanation/fr/up.svg +1 -0
  645. package/src/images/pages/trade-explanation/id/close-low.svg +1 -0
  646. package/src/images/pages/trade-explanation/id/differs.svg +1 -0
  647. package/src/images/pages/trade-explanation/id/down.svg +1 -0
  648. package/src/images/pages/trade-explanation/id/ends-between.svg +1 -0
  649. package/src/images/pages/trade-explanation/id/ends-outside.svg +1 -0
  650. package/src/images/pages/trade-explanation/id/even.svg +1 -0
  651. package/src/images/pages/trade-explanation/id/falls.svg +1 -0
  652. package/src/images/pages/trade-explanation/id/goes-outside.svg +1 -0
  653. package/src/images/pages/trade-explanation/id/high-close.svg +1 -0
  654. package/src/images/pages/trade-explanation/id/high-low.svg +1 -0
  655. package/src/images/pages/trade-explanation/id/high-tick.svg +1 -0
  656. package/src/images/pages/trade-explanation/id/higher.svg +1 -0
  657. package/src/images/pages/trade-explanation/id/low-tick.svg +1 -0
  658. package/src/images/pages/trade-explanation/id/lower.svg +1 -0
  659. package/src/images/pages/trade-explanation/id/matches.svg +1 -0
  660. package/src/images/pages/trade-explanation/id/no-touch.svg +1 -0
  661. package/src/images/pages/trade-explanation/id/odd.svg +1 -0
  662. package/src/images/pages/trade-explanation/id/only-downs.svg +1 -0
  663. package/src/images/pages/trade-explanation/id/only-ups.svg +1 -0
  664. package/src/images/pages/trade-explanation/id/over.svg +1 -0
  665. package/src/images/pages/trade-explanation/id/reset-call.svg +1 -0
  666. package/src/images/pages/trade-explanation/id/reset-put.svg +1 -0
  667. package/src/images/pages/trade-explanation/id/rises.svg +1 -0
  668. package/src/images/pages/trade-explanation/id/stays-between.svg +1 -0
  669. package/src/images/pages/trade-explanation/id/touch.svg +1 -0
  670. package/src/images/pages/trade-explanation/id/under.svg +1 -0
  671. package/src/images/pages/trade-explanation/id/up.svg +1 -0
  672. package/src/images/pages/trade-explanation/it/close-low.svg +1 -0
  673. package/src/images/pages/trade-explanation/it/differs.svg +1 -0
  674. package/src/images/pages/trade-explanation/it/down.svg +1 -0
  675. package/src/images/pages/trade-explanation/it/ends-between.svg +1 -0
  676. package/src/images/pages/trade-explanation/it/ends-outside.svg +1 -0
  677. package/src/images/pages/trade-explanation/it/even.svg +1 -0
  678. package/src/images/pages/trade-explanation/it/falls.svg +1 -0
  679. package/src/images/pages/trade-explanation/it/goes-outside.svg +1 -0
  680. package/src/images/pages/trade-explanation/it/high-close.svg +1 -0
  681. package/src/images/pages/trade-explanation/it/high-low.svg +1 -0
  682. package/src/images/pages/trade-explanation/it/high-tick.svg +1 -0
  683. package/src/images/pages/trade-explanation/it/higher.svg +1 -0
  684. package/src/images/pages/trade-explanation/it/low-tick.svg +1 -0
  685. package/src/images/pages/trade-explanation/it/lower.svg +1 -0
  686. package/src/images/pages/trade-explanation/it/matches.svg +1 -0
  687. package/src/images/pages/trade-explanation/it/no-touch.svg +1 -0
  688. package/src/images/pages/trade-explanation/it/odd.svg +1 -0
  689. package/src/images/pages/trade-explanation/it/only-downs.svg +1 -0
  690. package/src/images/pages/trade-explanation/it/only-ups.svg +1 -0
  691. package/src/images/pages/trade-explanation/it/over.svg +1 -0
  692. package/src/images/pages/trade-explanation/it/reset-call.svg +1 -0
  693. package/src/images/pages/trade-explanation/it/reset-put.svg +1 -0
  694. package/src/images/pages/trade-explanation/it/rises.svg +1 -0
  695. package/src/images/pages/trade-explanation/it/stays-between.svg +1 -0
  696. package/src/images/pages/trade-explanation/it/touch.svg +1 -0
  697. package/src/images/pages/trade-explanation/it/under.svg +1 -0
  698. package/src/images/pages/trade-explanation/it/up.svg +1 -0
  699. package/src/images/pages/trade-explanation/pl/close-low.svg +1 -0
  700. package/src/images/pages/trade-explanation/pl/differs.svg +1 -0
  701. package/src/images/pages/trade-explanation/pl/down.svg +1 -0
  702. package/src/images/pages/trade-explanation/pl/ends-between.svg +1 -0
  703. package/src/images/pages/trade-explanation/pl/ends-outside.svg +1 -0
  704. package/src/images/pages/trade-explanation/pl/even.svg +1 -0
  705. package/src/images/pages/trade-explanation/pl/falls.svg +1 -0
  706. package/src/images/pages/trade-explanation/pl/goes-outside.svg +1 -0
  707. package/src/images/pages/trade-explanation/pl/high-close.svg +1 -0
  708. package/src/images/pages/trade-explanation/pl/high-low.svg +1 -0
  709. package/src/images/pages/trade-explanation/pl/high-tick.svg +1 -0
  710. package/src/images/pages/trade-explanation/pl/higher.svg +1 -0
  711. package/src/images/pages/trade-explanation/pl/low-tick.svg +1 -0
  712. package/src/images/pages/trade-explanation/pl/lower.svg +1 -0
  713. package/src/images/pages/trade-explanation/pl/matches.svg +1 -0
  714. package/src/images/pages/trade-explanation/pl/no-touch.svg +1 -0
  715. package/src/images/pages/trade-explanation/pl/odd.svg +1 -0
  716. package/src/images/pages/trade-explanation/pl/only-downs.svg +1 -0
  717. package/src/images/pages/trade-explanation/pl/only-ups.svg +1 -0
  718. package/src/images/pages/trade-explanation/pl/over.svg +1 -0
  719. package/src/images/pages/trade-explanation/pl/reset-call.svg +1 -0
  720. package/src/images/pages/trade-explanation/pl/reset-put.svg +1 -0
  721. package/src/images/pages/trade-explanation/pl/rises.svg +1 -0
  722. package/src/images/pages/trade-explanation/pl/stays-between.svg +1 -0
  723. package/src/images/pages/trade-explanation/pl/touch.svg +1 -0
  724. package/src/images/pages/trade-explanation/pl/under.svg +1 -0
  725. package/src/images/pages/trade-explanation/pl/up.svg +1 -0
  726. package/src/images/pages/trade-explanation/pt/close-low.svg +1 -0
  727. package/src/images/pages/trade-explanation/pt/differs.svg +1 -0
  728. package/src/images/pages/trade-explanation/pt/down.svg +1 -0
  729. package/src/images/pages/trade-explanation/pt/ends-between.svg +1 -0
  730. package/src/images/pages/trade-explanation/pt/ends-outside.svg +1 -0
  731. package/src/images/pages/trade-explanation/pt/even.svg +1 -0
  732. package/src/images/pages/trade-explanation/pt/falls.svg +1 -0
  733. package/src/images/pages/trade-explanation/pt/goes-outside.svg +1 -0
  734. package/src/images/pages/trade-explanation/pt/high-close.svg +1 -0
  735. package/src/images/pages/trade-explanation/pt/high-low.svg +1 -0
  736. package/src/images/pages/trade-explanation/pt/high-tick.svg +1 -0
  737. package/src/images/pages/trade-explanation/pt/higher.svg +1 -0
  738. package/src/images/pages/trade-explanation/pt/low-tick.svg +1 -0
  739. package/src/images/pages/trade-explanation/pt/lower.svg +1 -0
  740. package/src/images/pages/trade-explanation/pt/matches.svg +1 -0
  741. package/src/images/pages/trade-explanation/pt/no-touch.svg +1 -0
  742. package/src/images/pages/trade-explanation/pt/odd.svg +1 -0
  743. package/src/images/pages/trade-explanation/pt/only-downs.svg +1 -0
  744. package/src/images/pages/trade-explanation/pt/only-ups.svg +1 -0
  745. package/src/images/pages/trade-explanation/pt/over.svg +1 -0
  746. package/src/images/pages/trade-explanation/pt/reset-call.svg +1 -0
  747. package/src/images/pages/trade-explanation/pt/reset-put.svg +1 -0
  748. package/src/images/pages/trade-explanation/pt/rises.svg +1 -0
  749. package/src/images/pages/trade-explanation/pt/stays-between.svg +1 -0
  750. package/src/images/pages/trade-explanation/pt/touch.svg +1 -0
  751. package/src/images/pages/trade-explanation/pt/under.svg +1 -0
  752. package/src/images/pages/trade-explanation/pt/up.svg +1 -0
  753. package/src/images/pages/trade-explanation/ru/close-low.svg +1 -0
  754. package/src/images/pages/trade-explanation/ru/differs.svg +1 -0
  755. package/src/images/pages/trade-explanation/ru/down.svg +1 -0
  756. package/src/images/pages/trade-explanation/ru/ends-between.svg +1 -0
  757. package/src/images/pages/trade-explanation/ru/ends-outside.svg +1 -0
  758. package/src/images/pages/trade-explanation/ru/even.svg +1 -0
  759. package/src/images/pages/trade-explanation/ru/falls.svg +1 -0
  760. package/src/images/pages/trade-explanation/ru/goes-outside.svg +1 -0
  761. package/src/images/pages/trade-explanation/ru/high-close.svg +1 -0
  762. package/src/images/pages/trade-explanation/ru/high-low.svg +1 -0
  763. package/src/images/pages/trade-explanation/ru/high-tick.svg +1 -0
  764. package/src/images/pages/trade-explanation/ru/higher.svg +1 -0
  765. package/src/images/pages/trade-explanation/ru/low-tick.svg +1 -0
  766. package/src/images/pages/trade-explanation/ru/lower.svg +1 -0
  767. package/src/images/pages/trade-explanation/ru/matches.svg +1 -0
  768. package/src/images/pages/trade-explanation/ru/no-touch.svg +1 -0
  769. package/src/images/pages/trade-explanation/ru/odd.svg +1 -0
  770. package/src/images/pages/trade-explanation/ru/only-downs.svg +1 -0
  771. package/src/images/pages/trade-explanation/ru/only-ups.svg +1 -0
  772. package/src/images/pages/trade-explanation/ru/over.svg +1 -0
  773. package/src/images/pages/trade-explanation/ru/reset-call.svg +1 -0
  774. package/src/images/pages/trade-explanation/ru/reset-put.svg +1 -0
  775. package/src/images/pages/trade-explanation/ru/rises.svg +1 -0
  776. package/src/images/pages/trade-explanation/ru/stays-between.svg +1 -0
  777. package/src/images/pages/trade-explanation/ru/touch.svg +1 -0
  778. package/src/images/pages/trade-explanation/ru/under.svg +1 -0
  779. package/src/images/pages/trade-explanation/ru/up.svg +1 -0
  780. package/src/images/pages/trade-explanation/th/close-low.svg +1 -0
  781. package/src/images/pages/trade-explanation/th/differs.svg +1 -0
  782. package/src/images/pages/trade-explanation/th/down.svg +1 -0
  783. package/src/images/pages/trade-explanation/th/ends-between.svg +1 -0
  784. package/src/images/pages/trade-explanation/th/ends-outside.svg +1 -0
  785. package/src/images/pages/trade-explanation/th/even.svg +1 -0
  786. package/src/images/pages/trade-explanation/th/falls.svg +1 -0
  787. package/src/images/pages/trade-explanation/th/goes-outside.svg +1 -0
  788. package/src/images/pages/trade-explanation/th/high-close.svg +1 -0
  789. package/src/images/pages/trade-explanation/th/high-low.svg +1 -0
  790. package/src/images/pages/trade-explanation/th/high-tick.svg +1 -0
  791. package/src/images/pages/trade-explanation/th/higher.svg +1 -0
  792. package/src/images/pages/trade-explanation/th/low-tick.svg +1 -0
  793. package/src/images/pages/trade-explanation/th/lower.svg +1 -0
  794. package/src/images/pages/trade-explanation/th/matches.svg +1 -0
  795. package/src/images/pages/trade-explanation/th/no-touch.svg +1 -0
  796. package/src/images/pages/trade-explanation/th/odd.svg +1 -0
  797. package/src/images/pages/trade-explanation/th/only-downs.svg +1 -0
  798. package/src/images/pages/trade-explanation/th/only-ups.svg +1 -0
  799. package/src/images/pages/trade-explanation/th/over.svg +1 -0
  800. package/src/images/pages/trade-explanation/th/reset-call.svg +1 -0
  801. package/src/images/pages/trade-explanation/th/reset-put.svg +1 -0
  802. package/src/images/pages/trade-explanation/th/rises.svg +1 -0
  803. package/src/images/pages/trade-explanation/th/stays-between.svg +1 -0
  804. package/src/images/pages/trade-explanation/th/touch.svg +1 -0
  805. package/src/images/pages/trade-explanation/th/under.svg +1 -0
  806. package/src/images/pages/trade-explanation/th/up.svg +1 -0
  807. package/src/images/pages/trade-explanation/vi/close-low.svg +1 -0
  808. package/src/images/pages/trade-explanation/vi/differs.svg +1 -0
  809. package/src/images/pages/trade-explanation/vi/down.svg +1 -0
  810. package/src/images/pages/trade-explanation/vi/ends-between.svg +1 -0
  811. package/src/images/pages/trade-explanation/vi/ends-outside.svg +1 -0
  812. package/src/images/pages/trade-explanation/vi/even.svg +1 -0
  813. package/src/images/pages/trade-explanation/vi/falls.svg +1 -0
  814. package/src/images/pages/trade-explanation/vi/goes-outside.svg +1 -0
  815. package/src/images/pages/trade-explanation/vi/high-close.svg +1 -0
  816. package/src/images/pages/trade-explanation/vi/high-low.svg +1 -0
  817. package/src/images/pages/trade-explanation/vi/high-tick.svg +1 -0
  818. package/src/images/pages/trade-explanation/vi/higher.svg +1 -0
  819. package/src/images/pages/trade-explanation/vi/low-tick.svg +1 -0
  820. package/src/images/pages/trade-explanation/vi/lower.svg +1 -0
  821. package/src/images/pages/trade-explanation/vi/matches.svg +1 -0
  822. package/src/images/pages/trade-explanation/vi/no-touch.svg +1 -0
  823. package/src/images/pages/trade-explanation/vi/odd.svg +1 -0
  824. package/src/images/pages/trade-explanation/vi/only-downs.svg +1 -0
  825. package/src/images/pages/trade-explanation/vi/only-ups.svg +1 -0
  826. package/src/images/pages/trade-explanation/vi/over.svg +1 -0
  827. package/src/images/pages/trade-explanation/vi/reset-call.svg +1 -0
  828. package/src/images/pages/trade-explanation/vi/reset-put.svg +1 -0
  829. package/src/images/pages/trade-explanation/vi/rises.svg +1 -0
  830. package/src/images/pages/trade-explanation/vi/stays-between.svg +1 -0
  831. package/src/images/pages/trade-explanation/vi/touch.svg +1 -0
  832. package/src/images/pages/trade-explanation/vi/under.svg +1 -0
  833. package/src/images/pages/trade-explanation/vi/up.svg +1 -0
  834. package/src/images/pages/trade-explanation/zh_cn/close-low.svg +1 -0
  835. package/src/images/pages/trade-explanation/zh_cn/differs.svg +1 -0
  836. package/src/images/pages/trade-explanation/zh_cn/down.svg +1 -0
  837. package/src/images/pages/trade-explanation/zh_cn/ends-between.svg +1 -0
  838. package/src/images/pages/trade-explanation/zh_cn/ends-outside.svg +1 -0
  839. package/src/images/pages/trade-explanation/zh_cn/even.svg +1 -0
  840. package/src/images/pages/trade-explanation/zh_cn/falls.svg +1 -0
  841. package/src/images/pages/trade-explanation/zh_cn/goes-outside.svg +1 -0
  842. package/src/images/pages/trade-explanation/zh_cn/high-close.svg +1 -0
  843. package/src/images/pages/trade-explanation/zh_cn/high-low.svg +1 -0
  844. package/src/images/pages/trade-explanation/zh_cn/high-tick.svg +1 -0
  845. package/src/images/pages/trade-explanation/zh_cn/higher.svg +1 -0
  846. package/src/images/pages/trade-explanation/zh_cn/low-tick.svg +1 -0
  847. package/src/images/pages/trade-explanation/zh_cn/lower.svg +1 -0
  848. package/src/images/pages/trade-explanation/zh_cn/matches.svg +1 -0
  849. package/src/images/pages/trade-explanation/zh_cn/no-touch.svg +1 -0
  850. package/src/images/pages/trade-explanation/zh_cn/odd.svg +1 -0
  851. package/src/images/pages/trade-explanation/zh_cn/only-downs.svg +1 -0
  852. package/src/images/pages/trade-explanation/zh_cn/only-ups.svg +1 -0
  853. package/src/images/pages/trade-explanation/zh_cn/over.svg +1 -0
  854. package/src/images/pages/trade-explanation/zh_cn/reset-call.svg +1 -0
  855. package/src/images/pages/trade-explanation/zh_cn/reset-put.svg +1 -0
  856. package/src/images/pages/trade-explanation/zh_cn/rises.svg +1 -0
  857. package/src/images/pages/trade-explanation/zh_cn/stays-between.svg +1 -0
  858. package/src/images/pages/trade-explanation/zh_cn/touch.svg +1 -0
  859. package/src/images/pages/trade-explanation/zh_cn/under.svg +1 -0
  860. package/src/images/pages/trade-explanation/zh_cn/up.svg +1 -0
  861. package/src/images/pages/trade-explanation/zh_tw/close-low.svg +1 -0
  862. package/src/images/pages/trade-explanation/zh_tw/differs.svg +1 -0
  863. package/src/images/pages/trade-explanation/zh_tw/down.svg +1 -0
  864. package/src/images/pages/trade-explanation/zh_tw/ends-between.svg +1 -0
  865. package/src/images/pages/trade-explanation/zh_tw/ends-outside.svg +1 -0
  866. package/src/images/pages/trade-explanation/zh_tw/even.svg +1 -0
  867. package/src/images/pages/trade-explanation/zh_tw/falls.svg +1 -0
  868. package/src/images/pages/trade-explanation/zh_tw/goes-outside.svg +1 -0
  869. package/src/images/pages/trade-explanation/zh_tw/high-close.svg +1 -0
  870. package/src/images/pages/trade-explanation/zh_tw/high-low.svg +1 -0
  871. package/src/images/pages/trade-explanation/zh_tw/high-tick.svg +1 -0
  872. package/src/images/pages/trade-explanation/zh_tw/higher.svg +1 -0
  873. package/src/images/pages/trade-explanation/zh_tw/low-tick.svg +1 -0
  874. package/src/images/pages/trade-explanation/zh_tw/lower.svg +1 -0
  875. package/src/images/pages/trade-explanation/zh_tw/matches.svg +1 -0
  876. package/src/images/pages/trade-explanation/zh_tw/no-touch.svg +1 -0
  877. package/src/images/pages/trade-explanation/zh_tw/odd.svg +1 -0
  878. package/src/images/pages/trade-explanation/zh_tw/only-downs.svg +1 -0
  879. package/src/images/pages/trade-explanation/zh_tw/only-ups.svg +1 -0
  880. package/src/images/pages/trade-explanation/zh_tw/over.svg +1 -0
  881. package/src/images/pages/trade-explanation/zh_tw/reset-call.svg +1 -0
  882. package/src/images/pages/trade-explanation/zh_tw/reset-put.svg +1 -0
  883. package/src/images/pages/trade-explanation/zh_tw/rises.svg +1 -0
  884. package/src/images/pages/trade-explanation/zh_tw/stays-between.svg +1 -0
  885. package/src/images/pages/trade-explanation/zh_tw/touch.svg +1 -0
  886. package/src/images/pages/trade-explanation/zh_tw/under.svg +1 -0
  887. package/src/images/pages/trade-explanation/zh_tw/up.svg +1 -0
  888. package/src/javascript/README.md +147 -0
  889. package/src/javascript/_autogenerated/ach.js +2 -0
  890. package/src/javascript/_autogenerated/app_2/ach.js +2 -0
  891. package/src/javascript/_autogenerated/app_2/de.js +2 -0
  892. package/src/javascript/_autogenerated/app_2/en.js +2 -0
  893. package/src/javascript/_autogenerated/app_2/es.js +2 -0
  894. package/src/javascript/_autogenerated/app_2/fr.js +2 -0
  895. package/src/javascript/_autogenerated/app_2/id.js +2 -0
  896. package/src/javascript/_autogenerated/app_2/it.js +2 -0
  897. package/src/javascript/_autogenerated/app_2/ja.js +2 -0
  898. package/src/javascript/_autogenerated/app_2/ko.js +2 -0
  899. package/src/javascript/_autogenerated/app_2/pl.js +2 -0
  900. package/src/javascript/_autogenerated/app_2/pt.js +2 -0
  901. package/src/javascript/_autogenerated/app_2/ru.js +2 -0
  902. package/src/javascript/_autogenerated/app_2/th.js +2 -0
  903. package/src/javascript/_autogenerated/app_2/vi.js +2 -0
  904. package/src/javascript/_autogenerated/app_2/zh_cn.js +2 -0
  905. package/src/javascript/_autogenerated/app_2/zh_tw.js +2 -0
  906. package/src/javascript/_autogenerated/de.js +2 -0
  907. package/src/javascript/_autogenerated/en.js +2 -0
  908. package/src/javascript/_autogenerated/es.js +2 -0
  909. package/src/javascript/_autogenerated/fr.js +2 -0
  910. package/src/javascript/_autogenerated/id.js +2 -0
  911. package/src/javascript/_autogenerated/it.js +2 -0
  912. package/src/javascript/_autogenerated/ko.js +2 -0
  913. package/src/javascript/_autogenerated/pl.js +2 -0
  914. package/src/javascript/_autogenerated/pt.js +2 -0
  915. package/src/javascript/_autogenerated/ru.js +2 -0
  916. package/src/javascript/_autogenerated/th.js +2 -0
  917. package/src/javascript/_autogenerated/vi.js +2 -0
  918. package/src/javascript/_autogenerated/zh_cn.js +2 -0
  919. package/src/javascript/_autogenerated/zh_tw.js +2 -0
  920. package/src/javascript/_common/__tests__/check_new_release.js +16 -0
  921. package/src/javascript/_common/__tests__/common_functions.js +90 -0
  922. package/src/javascript/_common/__tests__/language.js +68 -0
  923. package/src/javascript/_common/__tests__/string_util.js +80 -0
  924. package/src/javascript/_common/__tests__/tests_common.js +22 -0
  925. package/src/javascript/_common/__tests__/url.js +142 -0
  926. package/src/javascript/_common/__tests__/utility.js +175 -0
  927. package/src/javascript/_common/analytics.js +21 -0
  928. package/src/javascript/_common/auth.js +174 -0
  929. package/src/javascript/_common/base/__tests__/client_base.js +299 -0
  930. package/src/javascript/_common/base/__tests__/currency_base.js +126 -0
  931. package/src/javascript/_common/base/client_base.js +517 -0
  932. package/src/javascript/_common/base/currency_base.js +182 -0
  933. package/src/javascript/_common/base/elevio.js +148 -0
  934. package/src/javascript/_common/base/gtm.js +13 -0
  935. package/src/javascript/_common/base/livechat.js +136 -0
  936. package/src/javascript/_common/base/login.js +64 -0
  937. package/src/javascript/_common/base/network_monitor_base.js +151 -0
  938. package/src/javascript/_common/base/server_time.js +66 -0
  939. package/src/javascript/_common/base/socket_base.js +325 -0
  940. package/src/javascript/_common/base/socket_cache.js +132 -0
  941. package/src/javascript/_common/base/subscription_manager.js +248 -0
  942. package/src/javascript/_common/chat.js +57 -0
  943. package/src/javascript/_common/check_new_release.js +35 -0
  944. package/src/javascript/_common/check_password.js +103 -0
  945. package/src/javascript/_common/common_functions.js +104 -0
  946. package/src/javascript/_common/crowdin.js +34 -0
  947. package/src/javascript/_common/gtm.js +7 -0
  948. package/src/javascript/_common/language.js +98 -0
  949. package/src/javascript/_common/lib/guide.enjoyhint.js +1034 -0
  950. package/src/javascript/_common/lib/jquery.sparkline.js +3085 -0
  951. package/src/javascript/_common/lib/loadCSS.js +32 -0
  952. package/src/javascript/_common/lib/loadJS.js +13 -0
  953. package/src/javascript/_common/lib/mmenu/jquery.mmenu.min.all.js +84 -0
  954. package/src/javascript/_common/lib/plugins.js +55 -0
  955. package/src/javascript/_common/lib/polyfills/array.includes.js +28 -0
  956. package/src/javascript/_common/lib/polyfills/element.closest.js +11 -0
  957. package/src/javascript/_common/lib/polyfills/element.matches.js +14 -0
  958. package/src/javascript/_common/lib/polyfills/nodelist.foreach.js +8 -0
  959. package/src/javascript/_common/lib/polyfills/string.includes.js +6 -0
  960. package/src/javascript/_common/lib/zxcvbn/zxcvbn.js +30 -0
  961. package/src/javascript/_common/lib/zxcvbn/zxcvbn.js.map +27 -0
  962. package/src/javascript/_common/localize.js +55 -0
  963. package/src/javascript/_common/menu_selector.js +69 -0
  964. package/src/javascript/_common/os_detect.js +72 -0
  965. package/src/javascript/_common/remote_config.json +2 -0
  966. package/src/javascript/_common/scroll.js +124 -0
  967. package/src/javascript/_common/scroll_to_anchor.js +99 -0
  968. package/src/javascript/_common/storage.js +274 -0
  969. package/src/javascript/_common/string_util.js +50 -0
  970. package/src/javascript/_common/tab_selector.js +196 -0
  971. package/src/javascript/_common/third_party_links.js +96 -0
  972. package/src/javascript/_common/url.js +199 -0
  973. package/src/javascript/_common/utility.js +317 -0
  974. package/src/javascript/app/base/__tests__/client.js +49 -0
  975. package/src/javascript/app/base/binary_loader.js +290 -0
  976. package/src/javascript/app/base/binary_pages.js +151 -0
  977. package/src/javascript/app/base/binary_pjax.js +231 -0
  978. package/src/javascript/app/base/callback.js +16 -0
  979. package/src/javascript/app/base/client.js +207 -0
  980. package/src/javascript/app/base/clock.js +53 -0
  981. package/src/javascript/app/base/contents.js +16 -0
  982. package/src/javascript/app/base/header.js +1572 -0
  983. package/src/javascript/app/base/logged_in.js +338 -0
  984. package/src/javascript/app/base/menu.js +66 -0
  985. package/src/javascript/app/base/network_monitor.js +32 -0
  986. package/src/javascript/app/base/page.js +307 -0
  987. package/src/javascript/app/base/redirect.js +27 -0
  988. package/src/javascript/app/base/socket.js +4 -0
  989. package/src/javascript/app/base/socket_general.js +181 -0
  990. package/src/javascript/app/common/__tests__/active_symbols.js +166 -0
  991. package/src/javascript/app/common/__tests__/content_visibility.js +127 -0
  992. package/src/javascript/app/common/__tests__/get_app_details.js +29 -0
  993. package/src/javascript/app/common/account_opening.js +333 -0
  994. package/src/javascript/app/common/active_symbols.js +273 -0
  995. package/src/javascript/app/common/attach_dom/birth_date_picker.js +25 -0
  996. package/src/javascript/app/common/attach_dom/date_to.js +87 -0
  997. package/src/javascript/app/common/attach_dom/dialog.js +97 -0
  998. package/src/javascript/app/common/attach_dom/flextable.js +71 -0
  999. package/src/javascript/app/common/attach_dom/language_dropdown.js +36 -0
  1000. package/src/javascript/app/common/attach_dom/popup.js +77 -0
  1001. package/src/javascript/app/common/attach_dom/table.js +120 -0
  1002. package/src/javascript/app/common/cashier_modal.js +795 -0
  1003. package/src/javascript/app/common/chart_settings.js +254 -0
  1004. package/src/javascript/app/common/content_visibility.js +194 -0
  1005. package/src/javascript/app/common/contract_type_icons.js +76 -0
  1006. package/src/javascript/app/common/country_base.js +36 -0
  1007. package/src/javascript/app/common/currency.js +46 -0
  1008. package/src/javascript/app/common/data_manager.js +165 -0
  1009. package/src/javascript/app/common/deriv_banner.js +67 -0
  1010. package/src/javascript/app/common/deriv_cashier_service.js +124 -0
  1011. package/src/javascript/app/common/disclaimer.js +74 -0
  1012. package/src/javascript/app/common/event_handler.js +16 -0
  1013. package/src/javascript/app/common/form_manager.js +164 -0
  1014. package/src/javascript/app/common/form_validation.js +397 -0
  1015. package/src/javascript/app/common/getFeatureFlag.js +18 -0
  1016. package/src/javascript/app/common/get_app_details.js +37 -0
  1017. package/src/javascript/app/common/guide.js +136 -0
  1018. package/src/javascript/app/common/helpers.js +151 -0
  1019. package/src/javascript/app/common/open_positions_modal.js +160 -0
  1020. package/src/javascript/app/common/request_middleware.js +89 -0
  1021. package/src/javascript/app/common/session_duration_limit.js +66 -0
  1022. package/src/javascript/app/common/statements_modal.js +197 -0
  1023. package/src/javascript/app/common/telegram_auth.js +682 -0
  1024. package/src/javascript/app/common/trade_reports_modal.js +665 -0
  1025. package/src/javascript/app/common/traffic_source.js +88 -0
  1026. package/src/javascript/app/components/date_picker.js +156 -0
  1027. package/src/javascript/app/components/loading-spinner.js +46 -0
  1028. package/src/javascript/app/components/time_picker.js +146 -0
  1029. package/src/javascript/app/hooks/events.js +88 -0
  1030. package/src/javascript/app/hooks/useFreshChat.js +42 -0
  1031. package/src/javascript/app/hooks/useGrowthbookGetFeatureValue.js +36 -0
  1032. package/src/javascript/app/hooks/useInterComChat.js +22 -0
  1033. package/src/javascript/app/hooks/useRemoteConfig.js +59 -0
  1034. package/src/javascript/app/pages/bottom/data/explanation.js +347 -0
  1035. package/src/javascript/app/pages/bottom/explanation.jsx +231 -0
  1036. package/src/javascript/app/pages/bottom/graph.jsx +35 -0
  1037. package/src/javascript/app/pages/bottom/tabs.jsx +71 -0
  1038. package/src/javascript/app/pages/callback/callback.jsx +145 -0
  1039. package/src/javascript/app/pages/endpoint.js +32 -0
  1040. package/src/javascript/app/pages/form/barrier-fields.jsx +136 -0
  1041. package/src/javascript/app/pages/form/contract-form-wrapper.jsx +10 -0
  1042. package/src/javascript/app/pages/form/currency-dropdown.jsx +49 -0
  1043. package/src/javascript/app/pages/form/dropdown-component.jsx +47 -0
  1044. package/src/javascript/app/pages/form/form-component.jsx +786 -0
  1045. package/src/javascript/app/pages/form/numbers-dropdown.jsx +75 -0
  1046. package/src/javascript/app/pages/form/time-selection.jsx +102 -0
  1047. package/src/javascript/app/pages/livechat.jsx +61 -0
  1048. package/src/javascript/app/pages/loader.jsx +15 -0
  1049. package/src/javascript/app/pages/portal.jsx +24 -0
  1050. package/src/javascript/app/pages/trade/__tests__/common.test.js +244 -0
  1051. package/src/javascript/app/pages/trade/analysis.js +231 -0
  1052. package/src/javascript/app/pages/trade/barriers.js +244 -0
  1053. package/src/javascript/app/pages/trade/callputspread.js +241 -0
  1054. package/src/javascript/app/pages/trade/charts/digit_info.js +274 -0
  1055. package/src/javascript/app/pages/trade/charts/highchart.js +781 -0
  1056. package/src/javascript/app/pages/trade/charts/highchart.ui.js +66 -0
  1057. package/src/javascript/app/pages/trade/charts/webtrader_chart.js +278 -0
  1058. package/src/javascript/app/pages/trade/common.js +4501 -0
  1059. package/src/javascript/app/pages/trade/common_independent.js +160 -0
  1060. package/src/javascript/app/pages/trade/contract.js +263 -0
  1061. package/src/javascript/app/pages/trade/contracts.jsx +195 -0
  1062. package/src/javascript/app/pages/trade/currency.js +29 -0
  1063. package/src/javascript/app/pages/trade/defaults.js +108 -0
  1064. package/src/javascript/app/pages/trade/digit_grid.js +119 -0
  1065. package/src/javascript/app/pages/trade/digit_ticker.js +457 -0
  1066. package/src/javascript/app/pages/trade/digit_trade.js +174 -0
  1067. package/src/javascript/app/pages/trade/duration.js +799 -0
  1068. package/src/javascript/app/pages/trade/event.js +475 -0
  1069. package/src/javascript/app/pages/trade/get_active_tab.js +25 -0
  1070. package/src/javascript/app/pages/trade/get_ticks.js +88 -0
  1071. package/src/javascript/app/pages/trade/guide.jsx +43 -0
  1072. package/src/javascript/app/pages/trade/last_digit.jsx +39 -0
  1073. package/src/javascript/app/pages/trade/lookback.js +59 -0
  1074. package/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx +114 -0
  1075. package/src/javascript/app/pages/trade/markets/market-selector.jsx +97 -0
  1076. package/src/javascript/app/pages/trade/markets/markets-dropdown.jsx +671 -0
  1077. package/src/javascript/app/pages/trade/markets.jsx +705 -0
  1078. package/src/javascript/app/pages/trade/notifications.js +58 -0
  1079. package/src/javascript/app/pages/trade/price.js +521 -0
  1080. package/src/javascript/app/pages/trade/process.js +454 -0
  1081. package/src/javascript/app/pages/trade/purchase/contract-details.jsx +280 -0
  1082. package/src/javascript/app/pages/trade/purchase/contract-table.jsx +256 -0
  1083. package/src/javascript/app/pages/trade/purchase/purchase.jsx +1806 -0
  1084. package/src/javascript/app/pages/trade/purchase.js +429 -0
  1085. package/src/javascript/app/pages/trade/reset.js +87 -0
  1086. package/src/javascript/app/pages/trade/starttime.js +146 -0
  1087. package/src/javascript/app/pages/trade/symbols.js +116 -0
  1088. package/src/javascript/app/pages/trade/tick.js +218 -0
  1089. package/src/javascript/app/pages/trade/tick_trade.js +415 -0
  1090. package/src/javascript/app/pages/trade/tradepage.js +125 -0
  1091. package/src/javascript/app/pages/trade/update_values.js +78 -0
  1092. package/src/javascript/app/pages/user/account/__tests__/portfolio.js +91 -0
  1093. package/src/javascript/app/pages/user/account/portfolio/portfolio.init.js +243 -0
  1094. package/src/javascript/app/pages/user/account/portfolio/portfolio.js +57 -0
  1095. package/src/javascript/app/pages/user/account/settings/professional_client.js +140 -0
  1096. package/src/javascript/app/pages/user/account/settings/self_exclusion.js +408 -0
  1097. package/src/javascript/app/pages/user/account/top_up_virtual/pop_up.js +118 -0
  1098. package/src/javascript/app/pages/user/account/top_up_virtual/top_up_virtual.js +44 -0
  1099. package/src/javascript/app/pages/user/get_currency.js +110 -0
  1100. package/src/javascript/app/pages/user/reality_check/reality_check.data.js +87 -0
  1101. package/src/javascript/app/pages/user/reality_check/reality_check.js +43 -0
  1102. package/src/javascript/app/pages/user/reality_check/reality_check.ui.js +144 -0
  1103. package/src/javascript/app/pages/user/update_balance.js +109 -0
  1104. package/src/javascript/app/pages/user/update_total.js +39 -0
  1105. package/src/javascript/app/pages/user/view_popup/view_popup.js +1155 -0
  1106. package/src/javascript/app/pages/user/view_popup/view_popup.ui.js +194 -0
  1107. package/src/javascript/app/theme/palette.ts +71 -0
  1108. package/src/javascript/config.js +162 -0
  1109. package/src/javascript/index.js +114 -0
  1110. package/src/javascript/landing_pages/.eslintrc.js +11 -0
  1111. package/src/javascript/landing_pages/common.js +205 -0
  1112. package/src/javascript/manifest.json +66 -0
  1113. package/src/root_files/_common/404.html +105 -0
  1114. package/src/root_files/_common/robots.txt +2 -0
  1115. package/src/root_files/app/index.html +97 -0
  1116. package/src/root_files/app/sitemap.id.xml +37 -0
  1117. package/src/root_files/app/sitemap.xml +14 -0
  1118. package/src/sass/README.md +120 -0
  1119. package/src/sass/_common/base/animations.scss +48 -0
  1120. package/src/sass/_common/base/constants-deriv.scss +139 -0
  1121. package/src/sass/_common/base/constants.scss +66 -0
  1122. package/src/sass/_common/base/functions.scss +64 -0
  1123. package/src/sass/_common/base/language_base.scss +202 -0
  1124. package/src/sass/_common/base/media-queries.scss +72 -0
  1125. package/src/sass/_common/base/mixin.scss +175 -0
  1126. package/src/sass/_common/base/reset.scss +46 -0
  1127. package/src/sass/_common/base/theme.scss +348 -0
  1128. package/src/sass/_common/common.scss +1155 -0
  1129. package/src/sass/_common/common_import.scss +7 -0
  1130. package/src/sass/_common/components.scss +562 -0
  1131. package/src/sass/_common/external/_grid-settings-flex.scss +57 -0
  1132. package/src/sass/_common/external/_grid-settings.scss +60 -0
  1133. package/src/sass/_common/external/_variables.scss +28 -0
  1134. package/src/sass/_common/external/grid-flex.scss +42 -0
  1135. package/src/sass/_common/external/grid-mixins.scss +64 -0
  1136. package/src/sass/_common/external/grid.scss +63 -0
  1137. package/src/sass/_common/external/gridle/_api.scss +814 -0
  1138. package/src/sass/_common/external/gridle/_default-states.scss +37 -0
  1139. package/src/sass/_common/external/gridle/_driver-default.scss +432 -0
  1140. package/src/sass/_common/external/gridle/_driver-flex.scss +378 -0
  1141. package/src/sass/_common/external/gridle/_flexbox.scss +422 -0
  1142. package/src/sass/_common/external/gridle/_functions.scss +1108 -0
  1143. package/src/sass/_common/external/gridle/_generate-mixins.scss +645 -0
  1144. package/src/sass/_common/external/gridle/_gridle-flex.scss +60 -0
  1145. package/src/sass/_common/external/gridle/_gridle.scss +59 -0
  1146. package/src/sass/_common/external/gridle/_init.scss +147 -0
  1147. package/src/sass/_common/external/gridle/_mixins.scss +469 -0
  1148. package/src/sass/_common/external/gridle/_settings-mixins.scss +387 -0
  1149. package/src/sass/_common/external/gridle/_settings.scss +127 -0
  1150. package/src/sass/_common/external/mmenu/jquery.mmenu.all.scss +1276 -0
  1151. package/src/sass/_common/external/style.scss +361 -0
  1152. package/src/sass/_common/external/tests.scss +519 -0
  1153. package/src/sass/_common/external/third-party.scss +57 -0
  1154. package/src/sass/_common/external/tools/_reset.scss +47 -0
  1155. package/src/sass/_common/footer.scss +188 -0
  1156. package/src/sass/_common/header.scss +1799 -0
  1157. package/src/sass/_common/icons.scss +29 -0
  1158. package/src/sass/_common/img_lightbox.scss +59 -0
  1159. package/src/sass/_common/jquery_elements.scss +117 -0
  1160. package/src/sass/_common/reskin.scss +3928 -0
  1161. package/src/sass/_common/table.scss +104 -0
  1162. package/src/sass/_common/wallet_header.scss +224 -0
  1163. package/src/sass/app/components/account_transfer.scss +93 -0
  1164. package/src/sass/app/components/cashier-modal.scss +614 -0
  1165. package/src/sass/app/components/contract.scss +166 -0
  1166. package/src/sass/app/components/market.scss +442 -0
  1167. package/src/sass/app/components/peek_box.scss +391 -0
  1168. package/src/sass/app/components/stats-dialog.scss +46 -0
  1169. package/src/sass/app/components/trade-reports-modal.scss +771 -0
  1170. package/src/sass/app/reality_check.scss +99 -0
  1171. package/src/sass/app/sell_popup.scss +387 -0
  1172. package/src/sass/app/trade.scss +5012 -0
  1173. package/src/sass/app/trading.scss +127 -0
  1174. package/src/sass/app/websocket_pages.scss +210 -0
  1175. package/src/sass/app.scss +16 -0
  1176. package/src/sass/common.scss +27 -0
  1177. package/src/sass/reset.scss +27 -0
  1178. package/src/sass/static/animate-ui.css +215 -0
  1179. package/src/sass/static/guide.enjoyhint.scss +308 -0
  1180. package/src/sass/static/guide.scss +31 -0
  1181. package/src/sass/static/pages.scss +299 -0
  1182. package/src/sass/static.scss +5 -0
  1183. package/src/templates/.eslintrc.js +6 -0
  1184. package/src/templates/README.md +105 -0
  1185. package/src/templates/_common/_layout/head.jsx +61 -0
  1186. package/src/templates/_common/_layout/header.jsx +182 -0
  1187. package/src/templates/_common/_layout/layout.jsx +212 -0
  1188. package/src/templates/_common/_layout/wallet-header.jsx +121 -0
  1189. package/src/templates/_common/brand.config.js +25 -0
  1190. package/src/templates/_common/components/box_row.jsx +45 -0
  1191. package/src/templates/_common/components/cashier_modal.jsx +486 -0
  1192. package/src/templates/_common/components/elements.jsx +294 -0
  1193. package/src/templates/_common/components/forms.jsx +241 -0
  1194. package/src/templates/_common/components/html_comment.jsx +7 -0
  1195. package/src/templates/_common/components/language-menu-modal.jsx +17 -0
  1196. package/src/templates/_common/components/list_multiline.jsx +22 -0
  1197. package/src/templates/_common/components/list_nested.jsx +17 -0
  1198. package/src/templates/_common/components/loading.jsx +28 -0
  1199. package/src/templates/_common/components/mobile_menu.jsx +164 -0
  1200. package/src/templates/_common/components/notification.jsx +26 -0
  1201. package/src/templates/_common/components/open_positions_modal.jsx +55 -0
  1202. package/src/templates/_common/components/separator_line.jsx +27 -0
  1203. package/src/templates/_common/components/sidebar.jsx +42 -0
  1204. package/src/templates/_common/components/statements_modal.jsx +65 -0
  1205. package/src/templates/_common/components/step.jsx +15 -0
  1206. package/src/templates/_common/components/tabs.jsx +67 -0
  1207. package/src/templates/_common/components/title.jsx +8 -0
  1208. package/src/templates/_common/components/trade_reports_modal.jsx +213 -0
  1209. package/src/templates/_common/includes/anti_clickjack.jsx +20 -0
  1210. package/src/templates/_common/includes/elevio.jsx +23 -0
  1211. package/src/templates/_common/includes/favicons.jsx +42 -0
  1212. package/src/templates/_common/includes/google_optimizer.jsx +7 -0
  1213. package/src/templates/_common/includes/gtm.jsx +8 -0
  1214. package/src/templates/_common/includes/livechat.jsx +21 -0
  1215. package/src/templates/app/callback.jsx +30 -0
  1216. package/src/templates/app/dialog.jsx +23 -0
  1217. package/src/templates/app/endpoint.jsx +50 -0
  1218. package/src/templates/app/logged_in.jsx +337 -0
  1219. package/src/templates/app/trade/analysis.jsx +51 -0
  1220. package/src/templates/app/trade/explanation.jsx +336 -0
  1221. package/src/templates/app/trade/price-chart.jsx +103 -0
  1222. package/src/templates/app/trade/trading.jsx +1829 -0
  1223. package/src/templates/app/user/portfolio.jsx +59 -0
  1224. package/src/templates/app/user/reality_check/deriv_summary.jsx +77 -0
  1225. package/src/templates/app/user/reality_check/form.jsx +22 -0
  1226. package/src/templates/app/user/reality_check/frequency.jsx +13 -0
  1227. package/src/templates/app/user/reality_check/summary.jsx +53 -0
  1228. package/src/templates/app/user/reality_check/wrapper.jsx +15 -0
  1229. package/src/templates/static/404.jsx +22 -0
  1230. package/src/translations/ach_UG.po +1860 -0
  1231. package/src/translations/ar_SA.po +1860 -0
  1232. package/src/translations/bn_BD.po +1860 -0
  1233. package/src/translations/de_DE.po +1860 -0
  1234. package/src/translations/en.po +14817 -0
  1235. package/src/translations/es_ES.po +1860 -0
  1236. package/src/translations/fr_FR.po +1860 -0
  1237. package/src/translations/id_ID.po +3069 -0
  1238. package/src/translations/it_IT.po +1860 -0
  1239. package/src/translations/km_KH.po +1860 -0
  1240. package/src/translations/ko_KR.po +1860 -0
  1241. package/src/translations/messages.pot +1901 -0
  1242. package/src/translations/mn_MN.po +1860 -0
  1243. package/src/translations/pl_PL.po +1860 -0
  1244. package/src/translations/pt_PT.po +1860 -0
  1245. package/src/translations/ru_RU.po +1917 -0
  1246. package/src/translations/si_LK.po +1860 -0
  1247. package/src/translations/sw_KE.po +1860 -0
  1248. package/src/translations/th_TH.po +1860 -0
  1249. package/src/translations/tr_TR.po +1860 -0
  1250. package/src/translations/uz_UZ.po +1860 -0
  1251. package/src/translations/vi_VN.po +1860 -0
  1252. package/src/translations/zh_CN.po +1860 -0
  1253. package/src/translations/zh_TW.po +1860 -0
  1254. package/stagewise.json +6 -0
  1255. package/styles.scss +8 -0
  1256. package/vendor/deriv-com-analytics/LICENSE +21 -0
  1257. package/vendor/deriv-com-analytics/README.md +112 -0
  1258. package/vendor/deriv-com-analytics/lib/analytics.d.ts +58 -0
  1259. package/vendor/deriv-com-analytics/lib/analytics.js +258 -0
  1260. package/vendor/deriv-com-analytics/lib/growthbook.d.ts +29 -0
  1261. package/vendor/deriv-com-analytics/lib/growthbook.js +144 -0
  1262. package/vendor/deriv-com-analytics/lib/index.d.ts +2 -0
  1263. package/vendor/deriv-com-analytics/lib/index.js +5 -0
  1264. package/vendor/deriv-com-analytics/lib/rudderstack.d.ts +52 -0
  1265. package/vendor/deriv-com-analytics/lib/rudderstack.js +162 -0
  1266. package/vendor/deriv-com-analytics/lib/types.d.ts +334 -0
  1267. package/vendor/deriv-com-analytics/lib/types.js +2 -0
  1268. package/vendor/deriv-com-analytics/package.json +42 -0
  1269. package/vercel.dr.json +5 -0
  1270. package/vercel.json +8 -0
@@ -0,0 +1,3085 @@
1
+ /**
2
+ *
3
+ * jquery.sparkline.js
4
+ *
5
+ * v@VERSION@
6
+ * (c) Splunk, Inc
7
+ * Contact: Gareth Watts (gareth@splunk.com)
8
+ * http://omnipotent.net/jquery.sparkline/
9
+ *
10
+ * Generates inline sparkline charts from data supplied either to the method
11
+ * or inline in HTML
12
+ *
13
+ * Compatible with Internet Explorer 6.0+ and modern browsers equipped with the canvas tag
14
+ * (Firefox 2.0+, Safari, Opera, etc)
15
+ *
16
+ * License: New BSD License
17
+ *
18
+ * Copyright (c) 2012, Splunk Inc.
19
+ * All rights reserved.
20
+ *
21
+ * Redistribution and use in source and binary forms, with or without modification,
22
+ * are permitted provided that the following conditions are met:
23
+ *
24
+ * * Redistributions of source code must retain the above copyright notice,
25
+ * this list of conditions and the following disclaimer.
26
+ * * Redistributions in binary form must reproduce the above copyright notice,
27
+ * this list of conditions and the following disclaimer in the documentation
28
+ * and/or other materials provided with the distribution.
29
+ * * Neither the name of Splunk Inc nor the names of its contributors may
30
+ * be used to endorse or promote products derived from this software without
31
+ * specific prior written permission.
32
+ *
33
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
34
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
35
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
36
+ * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
38
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
+ *
43
+ *
44
+ * Usage:
45
+ * $(selector).sparkline(values, options)
46
+ *
47
+ * If values is undefined or set to 'html' then the data values are read from the specified tag:
48
+ * <p>Sparkline: <span class="sparkline">1,4,6,6,8,5,3,5</span></p>
49
+ * $('.sparkline').sparkline();
50
+ * There must be no spaces in the enclosed data set
51
+ *
52
+ * Otherwise values must be an array of numbers or null values
53
+ * <p>Sparkline: <span id="sparkline1">This text replaced if the browser is compatible</span></p>
54
+ * $('#sparkline1').sparkline([1,4,6,6,8,5,3,5])
55
+ * $('#sparkline2').sparkline([1,4,6,null,null,5,3,5])
56
+ *
57
+ * Values can also be specified in an HTML comment, or as a values attribute:
58
+ * <p>Sparkline: <span class="sparkline"><!--1,4,6,6,8,5,3,5 --></span></p>
59
+ * <p>Sparkline: <span class="sparkline" values="1,4,6,6,8,5,3,5"></span></p>
60
+ * $('.sparkline').sparkline();
61
+ *
62
+ * For line charts, x values can also be specified:
63
+ * <p>Sparkline: <span class="sparkline">1:1,2.7:4,3.4:6,5:6,6:8,8.7:5,9:3,10:5</span></p>
64
+ * $('#sparkline1').sparkline([ [1,1], [2.7,4], [3.4,6], [5,6], [6,8], [8.7,5], [9,3], [10,5] ])
65
+ *
66
+ * By default, options should be passed in as the second argument to the sparkline function:
67
+ * $('.sparkline').sparkline([1,2,3,4], {type: 'bar'})
68
+ *
69
+ * Options can also be set by passing them on the tag itself. This feature is disabled by default though
70
+ * as there's a slight performance overhead:
71
+ * $('.sparkline').sparkline([1,2,3,4], {enableTagOptions: true})
72
+ * <p>Sparkline: <span class="sparkline" sparkType="bar" sparkBarColor="red">loading</span></p>
73
+ * Prefix all options supplied as tag attribute with "spark" (configurable by setting tagOptionsPrefix)
74
+ *
75
+ * Supported options:
76
+ * lineColor - Color of the line used for the chart
77
+ * fillColor - Color used to fill in the chart - Set to '' or false for a transparent chart
78
+ * width - Width of the chart - Defaults to 3 times the number of values in pixels
79
+ * height - Height of the chart - Defaults to the height of the containing element
80
+ * chartRangeMin - Specify the minimum value to use for the Y range of the chart - Defaults to the minimum value supplied
81
+ * chartRangeMax - Specify the maximum value to use for the Y range of the chart - Defaults to the maximum value supplied
82
+ * chartRangeClip - Clip out of range values to the max/min specified by chartRangeMin and chartRangeMax
83
+ * chartRangeMinX - Specify the minimum value to use for the X range of the chart - Defaults to the minimum value supplied
84
+ * chartRangeMaxX - Specify the maximum value to use for the X range of the chart - Defaults to the maximum value supplied
85
+ * composite - If true then don't erase any existing chart attached to the tag, but draw
86
+ * another chart over the top - Note that width and height are ignored if an
87
+ * existing chart is detected.
88
+ * tagValuesAttribute - Name of tag attribute to check for data values - Defaults to 'values'
89
+ * enableTagOptions - Whether to check tags for sparkline options
90
+ * tagOptionsPrefix - Prefix used for options supplied as tag attributes - Defaults to 'spark'
91
+ * disableHiddenCheck - If set to true, then the plugin will assume that charts will never be drawn into a
92
+ * hidden dom element, avoding a browser reflow
93
+ * disableInteraction - If set to true then all mouseover/click interaction behaviour will be disabled,
94
+ * making the plugin perform much like it did in 1.x
95
+ * disableTooltips - If set to true then tooltips will be disabled - Defaults to false (tooltips enabled)
96
+ * disableHighlight - If set to true then highlighting of selected chart elements on mouseover will be disabled
97
+ * defaults to false (highlights enabled)
98
+ * highlightLighten - Factor to lighten/darken highlighted chart values by - Defaults to 1.4 for a 40% increase
99
+ * tooltipContainer - Specify which DOM element the tooltip should be rendered into - defaults to document.body
100
+ * tooltipClassname - Optional CSS classname to apply to tooltips - If not specified then a default style will be applied
101
+ * tooltipOffsetX - How many pixels away from the mouse pointer to render the tooltip on the X axis
102
+ * tooltipOffsetY - How many pixels away from the mouse pointer to render the tooltip on the r axis
103
+ * tooltipFormatter - Optional callback that allows you to override the HTML displayed in the tooltip
104
+ * callback is given arguments of (sparkline, options, fields)
105
+ * tooltipChartTitle - If specified then the tooltip uses the string specified by this setting as a title
106
+ * tooltipFormat - A format string or SPFormat object (or an array thereof for multiple entries)
107
+ * to control the format of the tooltip
108
+ * tooltipPrefix - A string to prepend to each field displayed in a tooltip
109
+ * tooltipSuffix - A string to append to each field displayed in a tooltip
110
+ * tooltipSkipNull - If true then null values will not have a tooltip displayed (defaults to true)
111
+ * tooltipValueLookups - An object or range map to map field values to tooltip strings
112
+ * (eg. to map -1 to "Lost", 0 to "Draw", and 1 to "Win")
113
+ * numberFormatter - Optional callback for formatting numbers in tooltips
114
+ * numberDigitGroupSep - Character to use for group separator in numbers "1,234" - Defaults to ","
115
+ * numberDecimalMark - Character to use for the decimal point when formatting numbers - Defaults to "."
116
+ * numberDigitGroupCount - Number of digits between group separator - Defaults to 3
117
+ *
118
+ * There are 7 types of sparkline, selected by supplying a "type" option of 'line' (default),
119
+ * 'bar', 'tristate', 'bullet', 'discrete', 'pie' or 'box'
120
+ * line - Line chart. Options:
121
+ * spotColor - Set to '' to not end each line in a circular spot
122
+ * minSpotColor - If set, color of spot at minimum value
123
+ * maxSpotColor - If set, color of spot at maximum value
124
+ * spotRadius - Radius in pixels
125
+ * lineWidth - Width of line in pixels
126
+ * normalRangeMin
127
+ * normalRangeMax - If set draws a filled horizontal bar between these two values marking the "normal"
128
+ * or expected range of values
129
+ * normalRangeColor - Color to use for the above bar
130
+ * drawNormalOnTop - Draw the normal range above the chart fill color if true
131
+ * defaultPixelsPerValue - Defaults to 3 pixels of width for each value in the chart
132
+ * highlightSpotColor - The color to use for drawing a highlight spot on mouseover - Set to null to disable
133
+ * highlightLineColor - The color to use for drawing a highlight line on mouseover - Set to null to disable
134
+ * valueSpots - Specify which points to draw spots on, and in which color. Accepts a range map
135
+ *
136
+ * bar - Bar chart. Options:
137
+ * barColor - Color of bars for postive values
138
+ * negBarColor - Color of bars for negative values
139
+ * zeroColor - Color of bars with zero values
140
+ * nullColor - Color of bars with null values - Defaults to omitting the bar entirely
141
+ * barWidth - Width of bars in pixels
142
+ * colorMap - Optional mappnig of values to colors to override the *BarColor values above
143
+ * can be an Array of values to control the color of individual bars or a range map
144
+ * to specify colors for individual ranges of values
145
+ * barSpacing - Gap between bars in pixels
146
+ * zeroAxis - Centers the y-axis around zero if true
147
+ *
148
+ * tristate - Charts values of win (>0), lose (<0) or draw (=0)
149
+ * posBarColor - Color of win values
150
+ * negBarColor - Color of lose values
151
+ * zeroBarColor - Color of draw values
152
+ * barWidth - Width of bars in pixels
153
+ * barSpacing - Gap between bars in pixels
154
+ * colorMap - Optional mappnig of values to colors to override the *BarColor values above
155
+ * can be an Array of values to control the color of individual bars or a range map
156
+ * to specify colors for individual ranges of values
157
+ *
158
+ * discrete - Options:
159
+ * lineHeight - Height of each line in pixels - Defaults to 30% of the graph height
160
+ * thesholdValue - Values less than this value will be drawn using thresholdColor instead of lineColor
161
+ * thresholdColor
162
+ *
163
+ * bullet - Values for bullet graphs msut be in the order: target, performance, range1, range2, range3, ...
164
+ * options:
165
+ * targetColor - The color of the vertical target marker
166
+ * targetWidth - The width of the target marker in pixels
167
+ * performanceColor - The color of the performance measure horizontal bar
168
+ * rangeColors - Colors to use for each qualitative range background color
169
+ *
170
+ * pie - Pie chart. Options:
171
+ * sliceColors - An array of colors to use for pie slices
172
+ * offset - Angle in degrees to offset the first slice - Try -90 or +90
173
+ * borderWidth - Width of border to draw around the pie chart, in pixels - Defaults to 0 (no border)
174
+ * borderColor - Color to use for the pie chart border - Defaults to #000
175
+ *
176
+ * box - Box plot. Options:
177
+ * raw - Set to true to supply pre-computed plot points as values
178
+ * values should be: low_outlier, low_whisker, q1, median, q3, high_whisker, high_outlier
179
+ * When set to false you can supply any number of values and the box plot will
180
+ * be computed for you. Default is false.
181
+ * showOutliers - Set to true (default) to display outliers as circles
182
+ * outlierIQR - Interquartile range used to determine outliers. Default 1.5
183
+ * boxLineColor - Outline color of the box
184
+ * boxFillColor - Fill color for the box
185
+ * whiskerColor - Line color used for whiskers
186
+ * outlierLineColor - Outline color of outlier circles
187
+ * outlierFillColor - Fill color of the outlier circles
188
+ * spotRadius - Radius of outlier circles
189
+ * medianColor - Line color of the median line
190
+ * target - Draw a target cross hair at the supplied value (default undefined)
191
+ *
192
+ *
193
+ *
194
+ * Examples:
195
+ * $('#sparkline1').sparkline(myvalues, { lineColor: '#f00', fillColor: false });
196
+ * $('.barsparks').sparkline('html', { type:'bar', height:'40px', barWidth:5 });
197
+ * $('#tristate').sparkline([1,1,-1,1,0,0,-1], { type:'tristate' }):
198
+ * $('#discrete').sparkline([1,3,4,5,5,3,4,5], { type:'discrete' });
199
+ * $('#bullet').sparkline([10,12,12,9,7], { type:'bullet' });
200
+ * $('#pie').sparkline([1,1,2], { type:'pie' });
201
+ */
202
+
203
+ /*jslint regexp: true, browser: true, jquery: true, white: true, nomen: false, plusplus: false, maxerr: 500, indent: 4 */
204
+
205
+ (function(document, Math, undefined) { // performance/minified-size optimization
206
+ (function(factory) {
207
+ if(typeof define === 'function' && define.amd) {
208
+ define(['jquery'], factory);
209
+ } else if (jQuery && !jQuery.fn.sparkline) {
210
+ factory(jQuery);
211
+ }
212
+ }
213
+ (function($) {
214
+ 'use strict';
215
+
216
+ var UNSET_OPTION = {},
217
+ getDefaults, createClass, SPFormat, clipval, quartile, normalizeValue, normalizeValues,
218
+ remove, isNumber, all, sum, addCSS, ensureArray, formatNumber, RangeMap,
219
+ MouseHandler, Tooltip, barHighlightMixin,
220
+ line, bar, tristate, discrete, bullet, pie, box, defaultStyles, initStyles,
221
+ VShape, VCanvas_base, VCanvas_canvas, VCanvas_vml, pending, shapeCount = 0;
222
+
223
+
224
+ /**
225
+ * Default configuration settings
226
+ */
227
+ getDefaults = function () {
228
+ return {
229
+ // Settings common to most/all chart types
230
+ common: {
231
+ type: 'line',
232
+ lineColor: '#00f',
233
+ fillColor: '#cdf',
234
+ defaultPixelsPerValue: 3,
235
+ width: 'auto',
236
+ height: 'auto',
237
+ composite: false,
238
+ tagValuesAttribute: 'values',
239
+ tagOptionsPrefix: 'spark',
240
+ enableTagOptions: false,
241
+ enableHighlight: true,
242
+ highlightLighten: 1.4,
243
+ tooltipSkipNull: true,
244
+ tooltipPrefix: '',
245
+ tooltipSuffix: '',
246
+ disableHiddenCheck: false,
247
+ numberFormatter: false,
248
+ numberDigitGroupCount: 3,
249
+ numberDigitGroupSep: ',',
250
+ numberDecimalMark: '.',
251
+ disableTooltips: false,
252
+ disableInteraction: false
253
+ },
254
+ // Defaults for line charts
255
+ line: {
256
+ spotColor: '#f80',
257
+ highlightSpotColor: '#5f5',
258
+ highlightLineColor: '#f22',
259
+ spotRadius: 1.5,
260
+ minSpotColor: '#f80',
261
+ maxSpotColor: '#f80',
262
+ lineWidth: 1,
263
+ normalRangeMin: undefined,
264
+ normalRangeMax: undefined,
265
+ normalRangeColor: '#ccc',
266
+ drawNormalOnTop: false,
267
+ chartRangeMin: undefined,
268
+ chartRangeMax: undefined,
269
+ chartRangeMinX: undefined,
270
+ chartRangeMaxX: undefined,
271
+ tooltipFormat: new SPFormat('<span style="color: {{color}}">&#9679;</span> {{prefix}}{{y}}{{suffix}}')
272
+ },
273
+ // Defaults for bar charts
274
+ bar: {
275
+ barColor: '#3366cc',
276
+ negBarColor: '#f44',
277
+ stackedBarColor: ['#3366cc', '#dc3912', '#ff9900', '#109618', '#66aa00',
278
+ '#dd4477', '#0099c6', '#990099'],
279
+ zeroColor: undefined,
280
+ nullColor: undefined,
281
+ zeroAxis: true,
282
+ barWidth: 4,
283
+ barSpacing: 1,
284
+ chartRangeMax: undefined,
285
+ chartRangeMin: undefined,
286
+ chartRangeClip: false,
287
+ colorMap: undefined,
288
+ tooltipFormat: new SPFormat('<span style="color: {{color}}">&#9679;</span> {{prefix}}{{value}}{{suffix}}')
289
+ },
290
+ // Defaults for tristate charts
291
+ tristate: {
292
+ barWidth: 4,
293
+ barSpacing: 1,
294
+ posBarColor: '#6f6',
295
+ negBarColor: '#f44',
296
+ zeroBarColor: '#999',
297
+ colorMap: {},
298
+ tooltipFormat: new SPFormat('<span style="color: {{color}}">&#9679;</span> {{value:map}}'),
299
+ tooltipValueLookups: { map: { '-1': 'Loss', '0': 'Draw', '1': 'Win' } }
300
+ },
301
+ // Defaults for discrete charts
302
+ discrete: {
303
+ lineHeight: 'auto',
304
+ thresholdColor: undefined,
305
+ thresholdValue: 0,
306
+ chartRangeMax: undefined,
307
+ chartRangeMin: undefined,
308
+ chartRangeClip: false,
309
+ tooltipFormat: new SPFormat('{{prefix}}{{value}}{{suffix}}')
310
+ },
311
+ // Defaults for bullet charts
312
+ bullet: {
313
+ targetColor: '#f33',
314
+ targetWidth: 3, // width of the target bar in pixels
315
+ performanceColor: '#33f',
316
+ rangeColors: ['#d3dafe', '#a8b6ff', '#7f94ff'],
317
+ base: undefined, // set this to a number to change the base start number
318
+ tooltipFormat: new SPFormat('{{fieldkey:fields}} - {{value}}'),
319
+ tooltipValueLookups: { fields: {r: 'Range', p: 'Performance', t: 'Target'} }
320
+ },
321
+ // Defaults for pie charts
322
+ pie: {
323
+ offset: 0,
324
+ sliceColors: ['#3366cc', '#dc3912', '#ff9900', '#109618', '#66aa00',
325
+ '#dd4477', '#0099c6', '#990099'],
326
+ borderWidth: 0,
327
+ borderColor: '#000',
328
+ tooltipFormat: new SPFormat('<span style="color: {{color}}">&#9679;</span> {{value}} ({{percent.1}}%)')
329
+ },
330
+ // Defaults for box plots
331
+ box: {
332
+ raw: false,
333
+ boxLineColor: '#000',
334
+ boxFillColor: '#cdf',
335
+ whiskerColor: '#000',
336
+ outlierLineColor: '#333',
337
+ outlierFillColor: '#fff',
338
+ medianColor: '#f00',
339
+ showOutliers: true,
340
+ outlierIQR: 1.5,
341
+ spotRadius: 1.5,
342
+ target: undefined,
343
+ targetColor: '#4a2',
344
+ chartRangeMax: undefined,
345
+ chartRangeMin: undefined,
346
+ tooltipFormat: new SPFormat('{{field:fields}}: {{value}}'),
347
+ tooltipFormatFieldlistKey: 'field',
348
+ tooltipValueLookups: { fields: { lq: 'Lower Quartile', med: 'Median',
349
+ uq: 'Upper Quartile', lo: 'Left Outlier', ro: 'Right Outlier',
350
+ lw: 'Left Whisker', rw: 'Right Whisker'} }
351
+ }
352
+ };
353
+ };
354
+
355
+ // You can have tooltips use a css class other than jqstooltip by specifying tooltipClassname
356
+ defaultStyles = '.jqstooltip { ' +
357
+ 'position: absolute;' +
358
+ 'left: 0;' +
359
+ 'top: 0;' +
360
+ 'visibility: hidden;' +
361
+ 'background: rgb(0, 0, 0) transparent;' +
362
+ 'background-color: rgba(0,0,0,0.6);' +
363
+ 'filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);' +
364
+ '-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";' +
365
+ 'color: white;' +
366
+ 'font: 10px arial, san serif;' +
367
+ 'text-align: left;' +
368
+ 'white-space: nowrap;' +
369
+ 'padding: 5px;' +
370
+ 'border: 1px solid white;' +
371
+ 'box-sizing: content-box;' +
372
+ 'z-index: 10000;' +
373
+ '}' +
374
+ '.jqsfield { ' +
375
+ 'color: white;' +
376
+ 'font: 10px arial, san serif;' +
377
+ 'text-align: left;' +
378
+ '}';
379
+
380
+
381
+ /**
382
+ * Utilities
383
+ */
384
+
385
+ createClass = function (/* [baseclass, [mixin, ...]], definition */) {
386
+ var Class, args;
387
+ Class = function () {
388
+ this.init.apply(this, arguments);
389
+ };
390
+ if (arguments.length > 1) {
391
+ if (arguments[0]) {
392
+ Class.prototype = $.extend(new arguments[0](), arguments[arguments.length - 1]);
393
+ Class._super = arguments[0].prototype;
394
+ } else {
395
+ Class.prototype = arguments[arguments.length - 1];
396
+ }
397
+ if (arguments.length > 2) {
398
+ args = Array.prototype.slice.call(arguments, 1, -1);
399
+ args.unshift(Class.prototype);
400
+ $.extend.apply($, args);
401
+ }
402
+ } else {
403
+ Class.prototype = arguments[0];
404
+ }
405
+ Class.prototype.cls = Class;
406
+ return Class;
407
+ };
408
+
409
+ /**
410
+ * Wraps a format string for tooltips
411
+ * {{x}}
412
+ * {{x.2}
413
+ * {{x:months}}
414
+ */
415
+ $.SPFormatClass = SPFormat = createClass({
416
+ fre: /\{\{([\w.]+?)(:(.+?))?\}\}/g,
417
+ precre: /(\w+)\.(\d+)/,
418
+
419
+ init: function (format, fclass) {
420
+ this.format = format;
421
+ this.fclass = fclass;
422
+ },
423
+
424
+ render: function (fieldset, lookups, options) {
425
+ var self = this,
426
+ fields = fieldset,
427
+ match, token, lookupkey, fieldvalue, prec;
428
+ return this.format.replace(this.fre, function () {
429
+ var lookup;
430
+ token = arguments[1];
431
+ lookupkey = arguments[3];
432
+ match = self.precre.exec(token);
433
+ if (match) {
434
+ prec = match[2];
435
+ token = match[1];
436
+ } else {
437
+ prec = false;
438
+ }
439
+ fieldvalue = fields[token];
440
+ if (fieldvalue === undefined) {
441
+ return '';
442
+ }
443
+ if (lookupkey && lookups && lookups[lookupkey]) {
444
+ lookup = lookups[lookupkey];
445
+ if (lookup.get) { // RangeMap
446
+ return lookups[lookupkey].get(fieldvalue) || fieldvalue;
447
+ } else {
448
+ return lookups[lookupkey][fieldvalue] || fieldvalue;
449
+ }
450
+ }
451
+ if (isNumber(fieldvalue)) {
452
+ if (options.get('numberFormatter')) {
453
+ fieldvalue = options.get('numberFormatter')(fieldvalue);
454
+ } else {
455
+ fieldvalue = formatNumber(fieldvalue, prec,
456
+ options.get('numberDigitGroupCount'),
457
+ options.get('numberDigitGroupSep'),
458
+ options.get('numberDecimalMark'));
459
+ }
460
+ }
461
+ return fieldvalue;
462
+ });
463
+ }
464
+ });
465
+
466
+ // convience method to avoid needing the new operator
467
+ $.spformat = function(format, fclass) {
468
+ return new SPFormat(format, fclass);
469
+ };
470
+
471
+ clipval = function (val, min, max) {
472
+ if (val < min) {
473
+ return min;
474
+ }
475
+ if (val > max) {
476
+ return max;
477
+ }
478
+ return val;
479
+ };
480
+
481
+ quartile = function (values, q) {
482
+ var vl;
483
+ if (q === 2) {
484
+ vl = Math.floor(values.length / 2);
485
+ return values.length % 2 ? values[vl] : (values[vl-1] + values[vl]) / 2;
486
+ } else {
487
+ if (values.length % 2 ) { // odd
488
+ vl = (values.length * q + q) / 4;
489
+ return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1];
490
+ } else { //even
491
+ vl = (values.length * q + 2) / 4;
492
+ return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1];
493
+
494
+ }
495
+ }
496
+ };
497
+
498
+ normalizeValue = function (val) {
499
+ var nf;
500
+ switch (val) {
501
+ case 'undefined':
502
+ val = undefined;
503
+ break;
504
+ case 'null':
505
+ val = null;
506
+ break;
507
+ case 'true':
508
+ val = true;
509
+ break;
510
+ case 'false':
511
+ val = false;
512
+ break;
513
+ default:
514
+ nf = parseFloat(val);
515
+ if (val == nf) {
516
+ val = nf;
517
+ }
518
+ }
519
+ return val;
520
+ };
521
+
522
+ normalizeValues = function (vals) {
523
+ var i, result = [];
524
+ for (i = vals.length; i--;) {
525
+ result[i] = normalizeValue(vals[i]);
526
+ }
527
+ return result;
528
+ };
529
+
530
+ remove = function (vals, filter) {
531
+ var i, vl, result = [];
532
+ for (i = 0, vl = vals.length; i < vl; i++) {
533
+ if (vals[i] !== filter) {
534
+ result.push(vals[i]);
535
+ }
536
+ }
537
+ return result;
538
+ };
539
+
540
+ isNumber = function (num) {
541
+ return !isNaN(parseFloat(num)) && isFinite(num);
542
+ };
543
+
544
+ formatNumber = function (num, prec, groupsize, groupsep, decsep) {
545
+ var p, i;
546
+ num = (prec === false ? parseFloat(num).toString() : num.toFixed(prec)).split('');
547
+ p = (p = $.inArray('.', num)) < 0 ? num.length : p;
548
+ if (p < num.length) {
549
+ num[p] = decsep;
550
+ }
551
+ for (i = p - groupsize; i > 0; i -= groupsize) {
552
+ num.splice(i, 0, groupsep);
553
+ }
554
+ return num.join('');
555
+ };
556
+
557
+ // determine if all values of an array match a value
558
+ // returns true if the array is empty
559
+ all = function (val, arr, ignoreNull) {
560
+ var i;
561
+ for (i = arr.length; i--; ) {
562
+ if (ignoreNull && arr[i] === null) continue;
563
+ if (arr[i] !== val) {
564
+ return false;
565
+ }
566
+ }
567
+ return true;
568
+ };
569
+
570
+ // sums the numeric values in an array, ignoring other values
571
+ sum = function (vals) {
572
+ var total = 0, i;
573
+ for (i = vals.length; i--;) {
574
+ total += typeof vals[i] === 'number' ? vals[i] : 0;
575
+ }
576
+ return total;
577
+ };
578
+
579
+ ensureArray = function (val) {
580
+ return $.isArray(val) ? val : [val];
581
+ };
582
+
583
+ // http://paulirish.com/2008/bookmarklet-inject-new-css-rules/
584
+ addCSS = function(css) {
585
+ var tag, iefail;
586
+ if (document.createStyleSheet) {
587
+ try {
588
+ document.createStyleSheet().cssText = css;
589
+ return;
590
+ } catch (e) {
591
+ // IE <= 9 maxes out at 31 stylesheets; inject into page instead.
592
+ iefail = true;
593
+ }
594
+ }
595
+ tag = document.createElement('style');
596
+ tag.type = 'text/css';
597
+ document.getElementsByTagName('head')[0].appendChild(tag);
598
+ if (iefail) {
599
+ document.styleSheets[document.styleSheets.length - 1].cssText = css;
600
+ } else {
601
+ tag[(typeof document.body.style.WebkitAppearance == 'string') /* webkit only */ ? 'innerText' : 'innerHTML'] = css;
602
+ }
603
+ };
604
+
605
+
606
+ // Provide a cross-browser interface to a few simple drawing primitives
607
+ $.fn.simpledraw = function (width, height, useExisting, interact) {
608
+ var target, mhandler;
609
+ if (useExisting && (target = this.data('_jqs_vcanvas'))) {
610
+ return target;
611
+ }
612
+
613
+ if ($.fn.sparkline.canvas === false) {
614
+ // We've already determined that neither Canvas nor VML are available
615
+ return false;
616
+
617
+ } else if ($.fn.sparkline.canvas === undefined) {
618
+ // No function defined yet -- need to see if we support Canvas or VML
619
+ var el = document.createElement('canvas');
620
+ if (!!(el.getContext && el.getContext('2d'))) {
621
+ // Canvas is available
622
+ $.fn.sparkline.canvas = function(width, height, target, interact) {
623
+ return new VCanvas_canvas(width, height, target, interact);
624
+ };
625
+ } else if (document.namespaces && !document.namespaces.v) {
626
+ // VML is available
627
+ document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML');
628
+ $.fn.sparkline.canvas = function(width, height, target, interact) {
629
+ return new VCanvas_vml(width, height, target);
630
+ };
631
+ } else {
632
+ // Neither Canvas nor VML are available
633
+ $.fn.sparkline.canvas = false;
634
+ return false;
635
+ }
636
+ }
637
+
638
+ if (width === undefined) {
639
+ width = $(this).innerWidth();
640
+ }
641
+ if (height === undefined) {
642
+ height = $(this).innerHeight();
643
+ }
644
+
645
+ target = $.fn.sparkline.canvas(width, height, this, interact);
646
+
647
+ mhandler = $(this).data('_jqs_mhandler');
648
+ if (mhandler) {
649
+ mhandler.registerCanvas(target);
650
+ }
651
+ return target;
652
+ };
653
+
654
+ $.fn.cleardraw = function () {
655
+ var target = this.data('_jqs_vcanvas');
656
+ if (target) {
657
+ target.reset();
658
+ }
659
+ };
660
+
661
+
662
+ $.RangeMapClass = RangeMap = createClass({
663
+ init: function (map) {
664
+ var key, range, rangelist = [];
665
+ for (key in map) {
666
+ if (map.hasOwnProperty(key) && typeof key === 'string' && key.indexOf(':') > -1) {
667
+ range = key.split(':');
668
+ range[0] = range[0].length === 0 ? -Infinity : parseFloat(range[0]);
669
+ range[1] = range[1].length === 0 ? Infinity : parseFloat(range[1]);
670
+ range[2] = map[key];
671
+ rangelist.push(range);
672
+ }
673
+ }
674
+ this.map = map;
675
+ this.rangelist = rangelist || false;
676
+ },
677
+
678
+ get: function (value) {
679
+ var rangelist = this.rangelist,
680
+ i, range, result;
681
+ if ((result = this.map[value]) !== undefined) {
682
+ return result;
683
+ }
684
+ if (rangelist) {
685
+ for (i = rangelist.length; i--;) {
686
+ range = rangelist[i];
687
+ if (range[0] <= value && range[1] >= value) {
688
+ return range[2];
689
+ }
690
+ }
691
+ }
692
+ return undefined;
693
+ }
694
+ });
695
+
696
+ // Convenience function
697
+ $.range_map = function(map) {
698
+ return new RangeMap(map);
699
+ };
700
+
701
+
702
+ MouseHandler = createClass({
703
+ init: function (el, options) {
704
+ var $el = $(el);
705
+ this.$el = $el;
706
+ this.options = options;
707
+ this.currentPageX = 0;
708
+ this.currentPageY = 0;
709
+ this.el = el;
710
+ this.splist = [];
711
+ this.tooltip = null;
712
+ this.over = false;
713
+ this.displayTooltips = !options.get('disableTooltips');
714
+ this.highlightEnabled = !options.get('disableHighlight');
715
+ },
716
+
717
+ registerSparkline: function (sp) {
718
+ this.splist.push(sp);
719
+ if (this.over) {
720
+ this.updateDisplay();
721
+ }
722
+ },
723
+
724
+ registerCanvas: function (canvas) {
725
+ var $canvas = $(canvas.canvas);
726
+ this.canvas = canvas;
727
+ this.$canvas = $canvas;
728
+ $canvas.mouseenter($.proxy(this.mouseenter, this));
729
+ $canvas.mouseleave($.proxy(this.mouseleave, this));
730
+ $canvas.click($.proxy(this.mouseclick, this));
731
+ },
732
+
733
+ reset: function (removeTooltip) {
734
+ this.splist = [];
735
+ if (this.tooltip && removeTooltip) {
736
+ this.tooltip.remove();
737
+ this.tooltip = undefined;
738
+ }
739
+ },
740
+
741
+ mouseclick: function (e) {
742
+ var clickEvent = $.Event('sparklineClick');
743
+ clickEvent.originalEvent = e;
744
+ clickEvent.sparklines = this.splist;
745
+ this.$el.trigger(clickEvent);
746
+ },
747
+
748
+ mouseenter: function (e) {
749
+ $(document.body).unbind('mousemove.jqs');
750
+ $(document.body).bind('mousemove.jqs', $.proxy(this.mousemove, this));
751
+ this.over = true;
752
+ this.currentPageX = e.pageX;
753
+ this.currentPageY = e.pageY;
754
+ this.currentEl = e.target;
755
+ if (!this.tooltip && this.displayTooltips) {
756
+ this.tooltip = new Tooltip(this.options);
757
+ this.tooltip.updatePosition(e.pageX, e.pageY);
758
+ }
759
+ this.updateDisplay();
760
+ },
761
+
762
+ mouseleave: function () {
763
+ $(document.body).unbind('mousemove.jqs');
764
+ var splist = this.splist,
765
+ spcount = splist.length,
766
+ needsRefresh = false,
767
+ sp, i;
768
+ this.over = false;
769
+ this.currentEl = null;
770
+
771
+ if (this.tooltip) {
772
+ this.tooltip.remove();
773
+ this.tooltip = null;
774
+ }
775
+
776
+ for (i = 0; i < spcount; i++) {
777
+ sp = splist[i];
778
+ if (sp.clearRegionHighlight()) {
779
+ needsRefresh = true;
780
+ }
781
+ }
782
+
783
+ if (needsRefresh) {
784
+ this.canvas.render();
785
+ }
786
+ },
787
+
788
+ mousemove: function (e) {
789
+ this.currentPageX = e.pageX;
790
+ this.currentPageY = e.pageY;
791
+ this.currentEl = e.target;
792
+ if (this.tooltip) {
793
+ this.tooltip.updatePosition(e.pageX, e.pageY);
794
+ }
795
+ this.updateDisplay();
796
+ },
797
+
798
+ updateDisplay: function () {
799
+ var splist = this.splist,
800
+ spcount = splist.length,
801
+ needsRefresh = false,
802
+ offset = this.$canvas.offset(),
803
+ localX = this.currentPageX - offset.left,
804
+ localY = this.currentPageY - offset.top,
805
+ tooltiphtml, sp, i, result, changeEvent;
806
+ if (!this.over) {
807
+ return;
808
+ }
809
+ for (i = 0; i < spcount; i++) {
810
+ sp = splist[i];
811
+ result = sp.setRegionHighlight(this.currentEl, localX, localY);
812
+ if (result) {
813
+ needsRefresh = true;
814
+ }
815
+ }
816
+ if (needsRefresh) {
817
+ changeEvent = $.Event('sparklineRegionChange');
818
+ changeEvent.sparklines = this.splist;
819
+ this.$el.trigger(changeEvent);
820
+ if (this.tooltip) {
821
+ tooltiphtml = '';
822
+ for (i = 0; i < spcount; i++) {
823
+ sp = splist[i];
824
+ tooltiphtml += sp.getCurrentRegionTooltip();
825
+ }
826
+ this.tooltip.setContent(tooltiphtml);
827
+ }
828
+ if (!this.disableHighlight) {
829
+ this.canvas.render();
830
+ }
831
+ }
832
+ if (result === null) {
833
+ this.mouseleave();
834
+ }
835
+ }
836
+ });
837
+
838
+
839
+ Tooltip = createClass({
840
+ sizeStyle: 'position: static !important;' +
841
+ 'display: block !important;' +
842
+ 'visibility: hidden !important;' +
843
+ 'float: left !important;',
844
+
845
+ init: function (options) {
846
+ var tooltipClassname = options.get('tooltipClassname', 'jqstooltip'),
847
+ sizetipStyle = this.sizeStyle,
848
+ offset;
849
+ this.container = options.get('tooltipContainer') || document.body;
850
+ this.tooltipOffsetX = options.get('tooltipOffsetX', 10);
851
+ this.tooltipOffsetY = options.get('tooltipOffsetY', 12);
852
+ // remove any previous lingering tooltip
853
+ $('#jqssizetip').remove();
854
+ $('#jqstooltip').remove();
855
+ this.sizetip = $('<div/>', {
856
+ id: 'jqssizetip',
857
+ style: sizetipStyle,
858
+ 'class': tooltipClassname
859
+ });
860
+ this.tooltip = $('<div/>', {
861
+ id: 'jqstooltip',
862
+ 'class': tooltipClassname
863
+ }).appendTo(this.container);
864
+ // account for the container's location
865
+ offset = this.tooltip.offset();
866
+ this.offsetLeft = offset.left;
867
+ this.offsetTop = offset.top;
868
+ this.hidden = true;
869
+ $(window).unbind('resize.jqs scroll.jqs');
870
+ $(window).bind('resize.jqs scroll.jqs', $.proxy(this.updateWindowDims, this));
871
+ this.updateWindowDims();
872
+ },
873
+
874
+ updateWindowDims: function () {
875
+ this.scrollTop = $(window).scrollTop();
876
+ this.scrollLeft = $(window).scrollLeft();
877
+ this.scrollRight = this.scrollLeft + $(window).width();
878
+ this.updatePosition();
879
+ },
880
+
881
+ getSize: function (content) {
882
+ this.sizetip.html(content).appendTo(this.container);
883
+ this.width = this.sizetip.width() + 1;
884
+ this.height = this.sizetip.height();
885
+ this.sizetip.remove();
886
+ },
887
+
888
+ setContent: function (content) {
889
+ if (!content) {
890
+ this.tooltip.css('visibility', 'hidden');
891
+ this.hidden = true;
892
+ return;
893
+ }
894
+ this.getSize(content);
895
+ this.tooltip.html(content)
896
+ .css({
897
+ 'width': this.width,
898
+ 'height': this.height,
899
+ 'visibility': 'visible'
900
+ });
901
+ if (this.hidden) {
902
+ this.hidden = false;
903
+ this.updatePosition();
904
+ }
905
+ },
906
+
907
+ updatePosition: function (x, y) {
908
+ if (x === undefined) {
909
+ if (this.mousex === undefined) {
910
+ return;
911
+ }
912
+ x = this.mousex - this.offsetLeft;
913
+ y = this.mousey - this.offsetTop;
914
+
915
+ } else {
916
+ this.mousex = x = x - this.offsetLeft;
917
+ this.mousey = y = y - this.offsetTop;
918
+ }
919
+ if (!this.height || !this.width || this.hidden) {
920
+ return;
921
+ }
922
+
923
+ y -= this.height + this.tooltipOffsetY;
924
+ x += this.tooltipOffsetX;
925
+
926
+ if (y < this.scrollTop) {
927
+ y = this.scrollTop;
928
+ }
929
+ if (x < this.scrollLeft) {
930
+ x = this.scrollLeft;
931
+ } else if (x + this.width > this.scrollRight) {
932
+ x = this.scrollRight - this.width;
933
+ }
934
+
935
+ this.tooltip.css({
936
+ 'left': x,
937
+ 'top': y
938
+ });
939
+ },
940
+
941
+ remove: function () {
942
+ this.tooltip.remove();
943
+ this.sizetip.remove();
944
+ this.sizetip = this.tooltip = undefined;
945
+ $(window).unbind('resize.jqs scroll.jqs');
946
+ }
947
+ });
948
+
949
+
950
+ initStyles = function() {
951
+ addCSS(defaultStyles);
952
+ };
953
+
954
+ $(initStyles);
955
+
956
+ pending = [];
957
+ $.fn.sparkline = function (userValues, userOptions) {
958
+ return this.each(function () {
959
+ var options = new $.fn.sparkline.options(this, userOptions),
960
+ $this = $(this),
961
+ render, i;
962
+ render = function () {
963
+ var values, width, height, tmp, mhandler, sp, vals;
964
+ if (userValues === 'html' || userValues === undefined) {
965
+ vals = this.getAttribute(options.get('tagValuesAttribute'));
966
+ if (vals === undefined || vals === null) {
967
+ vals = $this.html();
968
+ }
969
+ values = vals.replace(/(^\s*<!--)|(-->\s*$)|\s+/g, '').split(',');
970
+ } else {
971
+ values = userValues;
972
+ }
973
+
974
+ width = options.get('width') === 'auto' ? values.length * options.get('defaultPixelsPerValue') : options.get('width');
975
+ if (options.get('height') === 'auto') {
976
+ if (!options.get('composite') || !$.data(this, '_jqs_vcanvas')) {
977
+ // must be a better way to get the line height
978
+ tmp = document.createElement('span');
979
+ tmp.innerHTML = 'a';
980
+ $this.html(tmp);
981
+ height = $(tmp).innerHeight() || $(tmp).height();
982
+ $(tmp).remove();
983
+ tmp = null;
984
+ }
985
+ } else {
986
+ height = options.get('height');
987
+ }
988
+
989
+ if (!options.get('disableInteraction')) {
990
+ mhandler = $.data(this, '_jqs_mhandler');
991
+ if (!mhandler) {
992
+ mhandler = new MouseHandler(this, options);
993
+ $.data(this, '_jqs_mhandler', mhandler);
994
+ } else if (!options.get('composite')) {
995
+ mhandler.reset();
996
+ }
997
+ } else {
998
+ mhandler = false;
999
+ }
1000
+
1001
+ if (options.get('composite') && !$.data(this, '_jqs_vcanvas')) {
1002
+ if (!$.data(this, '_jqs_errnotify')) {
1003
+ window.alert('Attempted to attach a composite sparkline to an element with no existing sparkline');
1004
+ $.data(this, '_jqs_errnotify', true);
1005
+ }
1006
+ return;
1007
+ }
1008
+
1009
+ sp = new $.fn.sparkline[options.get('type')](this, values, options, width, height);
1010
+
1011
+ sp.render();
1012
+
1013
+ if (mhandler) {
1014
+ mhandler.registerSparkline(sp);
1015
+ }
1016
+ };
1017
+ if (($(this).html() && !options.get('disableHiddenCheck') && $(this).is(':hidden')) || !$(this).parents('body').length) {
1018
+ if (!options.get('composite') && $.data(this, '_jqs_pending')) {
1019
+ // remove any existing references to the element
1020
+ for (i = pending.length; i; i--) {
1021
+ if (pending[i - 1][0] == this) {
1022
+ pending.splice(i - 1, 1);
1023
+ }
1024
+ }
1025
+ }
1026
+ pending.push([this, render]);
1027
+ $.data(this, '_jqs_pending', true);
1028
+ } else {
1029
+ render.call(this);
1030
+ }
1031
+ });
1032
+ };
1033
+
1034
+ $.fn.sparkline.defaults = getDefaults();
1035
+
1036
+
1037
+ $.sparkline_display_visible = function () {
1038
+ var el, i, pl;
1039
+ var done = [];
1040
+ for (i = 0, pl = pending.length; i < pl; i++) {
1041
+ el = pending[i][0];
1042
+ if ($(el).is(':visible') && !$(el).parents().is(':hidden')) {
1043
+ pending[i][1].call(el);
1044
+ $.data(pending[i][0], '_jqs_pending', false);
1045
+ done.push(i);
1046
+ } else if (!$(el).closest('html').length && !$.data(el, '_jqs_pending')) {
1047
+ // element has been inserted and removed from the DOM
1048
+ // If it was not yet inserted into the dom then the .data request
1049
+ // will return true.
1050
+ // removing from the dom causes the data to be removed.
1051
+ $.data(pending[i][0], '_jqs_pending', false);
1052
+ done.push(i);
1053
+ }
1054
+ }
1055
+ for (i = done.length; i; i--) {
1056
+ pending.splice(done[i - 1], 1);
1057
+ }
1058
+ };
1059
+
1060
+
1061
+ /**
1062
+ * User option handler
1063
+ */
1064
+ $.fn.sparkline.options = createClass({
1065
+ init: function (tag, userOptions) {
1066
+ var extendedOptions, defaults, base, tagOptionType;
1067
+ this.userOptions = userOptions = userOptions || {};
1068
+ this.tag = tag;
1069
+ this.tagValCache = {};
1070
+ defaults = $.fn.sparkline.defaults;
1071
+ base = defaults.common;
1072
+ this.tagOptionsPrefix = userOptions.enableTagOptions && (userOptions.tagOptionsPrefix || base.tagOptionsPrefix);
1073
+
1074
+ tagOptionType = this.getTagSetting('type');
1075
+ if (tagOptionType === UNSET_OPTION) {
1076
+ extendedOptions = defaults[userOptions.type || base.type];
1077
+ } else {
1078
+ extendedOptions = defaults[tagOptionType];
1079
+ }
1080
+ this.mergedOptions = $.extend({}, base, extendedOptions, userOptions);
1081
+ },
1082
+
1083
+
1084
+ getTagSetting: function (key) {
1085
+ var prefix = this.tagOptionsPrefix,
1086
+ val, i, pairs, keyval;
1087
+ if (prefix === false || prefix === undefined) {
1088
+ return UNSET_OPTION;
1089
+ }
1090
+ if (this.tagValCache.hasOwnProperty(key)) {
1091
+ val = this.tagValCache.key;
1092
+ } else {
1093
+ val = this.tag.getAttribute(prefix + key);
1094
+ if (val === undefined || val === null) {
1095
+ val = UNSET_OPTION;
1096
+ } else if (val.substr(0, 1) === '[') {
1097
+ val = val.substr(1, val.length - 2).split(',');
1098
+ for (i = val.length; i--;) {
1099
+ val[i] = normalizeValue(val[i].replace(/(^\s*)|(\s*$)/g, ''));
1100
+ }
1101
+ } else if (val.substr(0, 1) === '{') {
1102
+ pairs = val.substr(1, val.length - 2).split(',');
1103
+ val = {};
1104
+ for (i = pairs.length; i--;) {
1105
+ keyval = pairs[i].split(':', 2);
1106
+ val[keyval[0].replace(/(^\s*)|(\s*$)/g, '')] = normalizeValue(keyval[1].replace(/(^\s*)|(\s*$)/g, ''));
1107
+ }
1108
+ } else {
1109
+ val = normalizeValue(val);
1110
+ }
1111
+ this.tagValCache.key = val;
1112
+ }
1113
+ return val;
1114
+ },
1115
+
1116
+ get: function (key, defaultval) {
1117
+ var tagOption = this.getTagSetting(key),
1118
+ result;
1119
+ if (tagOption !== UNSET_OPTION) {
1120
+ return tagOption;
1121
+ }
1122
+ return (result = this.mergedOptions[key]) === undefined ? defaultval : result;
1123
+ }
1124
+ });
1125
+
1126
+
1127
+ $.fn.sparkline._base = createClass({
1128
+ disabled: false,
1129
+
1130
+ init: function (el, values, options, width, height) {
1131
+ this.el = el;
1132
+ this.$el = $(el);
1133
+ this.values = values;
1134
+ this.options = options;
1135
+ this.width = width;
1136
+ this.height = height;
1137
+ this.currentRegion = undefined;
1138
+ },
1139
+
1140
+ /**
1141
+ * Setup the canvas
1142
+ */
1143
+ initTarget: function () {
1144
+ var interactive = !this.options.get('disableInteraction');
1145
+ if (!(this.target = this.$el.simpledraw(this.width, this.height, this.options.get('composite'), interactive))) {
1146
+ this.disabled = true;
1147
+ } else {
1148
+ this.canvasWidth = this.target.pixelWidth;
1149
+ this.canvasHeight = this.target.pixelHeight;
1150
+ }
1151
+ },
1152
+
1153
+ /**
1154
+ * Actually render the chart to the canvas
1155
+ */
1156
+ render: function () {
1157
+ if (this.disabled) {
1158
+ this.el.innerHTML = '';
1159
+ return false;
1160
+ }
1161
+ return true;
1162
+ },
1163
+
1164
+ /**
1165
+ * Return a region id for a given x/y co-ordinate
1166
+ */
1167
+ getRegion: function (x, y) {
1168
+ },
1169
+
1170
+ /**
1171
+ * Highlight an item based on the moused-over x,y co-ordinate
1172
+ */
1173
+ setRegionHighlight: function (el, x, y) {
1174
+ var currentRegion = this.currentRegion,
1175
+ highlightEnabled = !this.options.get('disableHighlight'),
1176
+ newRegion;
1177
+ if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) {
1178
+ return null;
1179
+ }
1180
+ newRegion = this.getRegion(el, x, y);
1181
+ if (currentRegion !== newRegion) {
1182
+ if (currentRegion !== undefined && highlightEnabled) {
1183
+ this.removeHighlight();
1184
+ }
1185
+ this.currentRegion = newRegion;
1186
+ if (newRegion !== undefined && highlightEnabled) {
1187
+ this.renderHighlight();
1188
+ }
1189
+ return true;
1190
+ }
1191
+ return false;
1192
+ },
1193
+
1194
+ /**
1195
+ * Reset any currently highlighted item
1196
+ */
1197
+ clearRegionHighlight: function () {
1198
+ if (this.currentRegion !== undefined) {
1199
+ this.removeHighlight();
1200
+ this.currentRegion = undefined;
1201
+ return true;
1202
+ }
1203
+ return false;
1204
+ },
1205
+
1206
+ renderHighlight: function () {
1207
+ this.changeHighlight(true);
1208
+ },
1209
+
1210
+ removeHighlight: function () {
1211
+ this.changeHighlight(false);
1212
+ },
1213
+
1214
+ changeHighlight: function (highlight) {},
1215
+
1216
+ /**
1217
+ * Fetch the HTML to display as a tooltip
1218
+ */
1219
+ getCurrentRegionTooltip: function () {
1220
+ var options = this.options,
1221
+ header = '',
1222
+ entries = [],
1223
+ fields, formats, formatlen, fclass, text, i,
1224
+ showFields, showFieldsKey, newFields, fv,
1225
+ formatter, format, fieldlen, j;
1226
+ if (this.currentRegion === undefined) {
1227
+ return '';
1228
+ }
1229
+ fields = this.getCurrentRegionFields();
1230
+ formatter = options.get('tooltipFormatter');
1231
+ if (formatter) {
1232
+ return formatter(this, options, fields);
1233
+ }
1234
+ if (options.get('tooltipChartTitle')) {
1235
+ header += '<div class="jqs jqstitle">' + options.get('tooltipChartTitle') + '</div>\n';
1236
+ }
1237
+ formats = this.options.get('tooltipFormat');
1238
+ if (!formats) {
1239
+ return '';
1240
+ }
1241
+ if (!$.isArray(formats)) {
1242
+ formats = [formats];
1243
+ }
1244
+ if (!$.isArray(fields)) {
1245
+ fields = [fields];
1246
+ }
1247
+ showFields = this.options.get('tooltipFormatFieldlist');
1248
+ showFieldsKey = this.options.get('tooltipFormatFieldlistKey');
1249
+ if (showFields && showFieldsKey) {
1250
+ // user-selected ordering of fields
1251
+ newFields = [];
1252
+ for (i = fields.length; i--;) {
1253
+ fv = fields[i][showFieldsKey];
1254
+ if ((j = $.inArray(fv, showFields)) != -1) {
1255
+ newFields[j] = fields[i];
1256
+ }
1257
+ }
1258
+ fields = newFields;
1259
+ }
1260
+ formatlen = formats.length;
1261
+ fieldlen = fields.length;
1262
+ for (i = 0; i < formatlen; i++) {
1263
+ format = formats[i];
1264
+ if (typeof format === 'string') {
1265
+ format = new SPFormat(format);
1266
+ }
1267
+ fclass = format.fclass || 'jqsfield';
1268
+ for (j = 0; j < fieldlen; j++) {
1269
+ if (!fields[j].isNull || !options.get('tooltipSkipNull')) {
1270
+ $.extend(fields[j], {
1271
+ prefix: options.get('tooltipPrefix'),
1272
+ suffix: options.get('tooltipSuffix')
1273
+ });
1274
+ text = format.render(fields[j], options.get('tooltipValueLookups'), options);
1275
+ entries.push('<div class="' + fclass + '">' + text + '</div>');
1276
+ }
1277
+ }
1278
+ }
1279
+ if (entries.length) {
1280
+ return header + entries.join('\n');
1281
+ }
1282
+ return '';
1283
+ },
1284
+
1285
+ getCurrentRegionFields: function () {},
1286
+
1287
+ calcHighlightColor: function (color, options) {
1288
+ var highlightColor = options.get('highlightColor'),
1289
+ lighten = options.get('highlightLighten'),
1290
+ parse, mult, rgbnew, i;
1291
+ if (highlightColor) {
1292
+ return highlightColor;
1293
+ }
1294
+ if (lighten) {
1295
+ // extract RGB values
1296
+ parse = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(color) || /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
1297
+ if (parse) {
1298
+ rgbnew = [];
1299
+ mult = color.length === 4 ? 16 : 1;
1300
+ for (i = 0; i < 3; i++) {
1301
+ rgbnew[i] = clipval(Math.round(parseInt(parse[i + 1], 16) * mult * lighten), 0, 255);
1302
+ }
1303
+ return 'rgb(' + rgbnew.join(',') + ')';
1304
+ }
1305
+
1306
+ }
1307
+ return color;
1308
+ }
1309
+
1310
+ });
1311
+
1312
+ barHighlightMixin = {
1313
+ changeHighlight: function (highlight) {
1314
+ var currentRegion = this.currentRegion,
1315
+ target = this.target,
1316
+ shapeids = this.regionShapes[currentRegion],
1317
+ newShapes;
1318
+ // will be null if the region value was null
1319
+ if (shapeids) {
1320
+ newShapes = this.renderRegion(currentRegion, highlight);
1321
+ if ($.isArray(newShapes) || $.isArray(shapeids)) {
1322
+ target.replaceWithShapes(shapeids, newShapes);
1323
+ this.regionShapes[currentRegion] = $.map(newShapes, function (newShape) {
1324
+ return newShape.id;
1325
+ });
1326
+ } else {
1327
+ target.replaceWithShape(shapeids, newShapes);
1328
+ this.regionShapes[currentRegion] = newShapes.id;
1329
+ }
1330
+ }
1331
+ },
1332
+
1333
+ render: function () {
1334
+ var values = this.values,
1335
+ target = this.target,
1336
+ regionShapes = this.regionShapes,
1337
+ shapes, ids, i, j;
1338
+
1339
+ if (!this.cls._super.render.call(this)) {
1340
+ return;
1341
+ }
1342
+ for (i = values.length; i--;) {
1343
+ shapes = this.renderRegion(i);
1344
+ if (shapes) {
1345
+ if ($.isArray(shapes)) {
1346
+ ids = [];
1347
+ for (j = shapes.length; j--;) {
1348
+ shapes[j].append();
1349
+ ids.push(shapes[j].id);
1350
+ }
1351
+ regionShapes[i] = ids;
1352
+ } else {
1353
+ shapes.append();
1354
+ regionShapes[i] = shapes.id; // store just the shapeid
1355
+ }
1356
+ } else {
1357
+ // null value
1358
+ regionShapes[i] = null;
1359
+ }
1360
+ }
1361
+ target.render();
1362
+ }
1363
+ };
1364
+
1365
+
1366
+ /**
1367
+ * Line charts
1368
+ */
1369
+ $.fn.sparkline.line = line = createClass($.fn.sparkline._base, {
1370
+ type: 'line',
1371
+
1372
+ init: function (el, values, options, width, height) {
1373
+ line._super.init.call(this, el, values, options, width, height);
1374
+ this.vertices = [];
1375
+ this.regionMap = [];
1376
+ this.xvalues = [];
1377
+ this.yvalues = [];
1378
+ this.yminmax = [];
1379
+ this.hightlightSpotId = null;
1380
+ this.lastShapeId = null;
1381
+ this.initTarget();
1382
+ },
1383
+
1384
+ getRegion: function (el, x, y) {
1385
+ var i,
1386
+ regionMap = this.regionMap; // maps regions to value positions
1387
+ for (i = regionMap.length; i--;) {
1388
+ if (regionMap[i] !== null && x >= regionMap[i][0] && x <= regionMap[i][1]) {
1389
+ return regionMap[i][2];
1390
+ }
1391
+ }
1392
+ return undefined;
1393
+ },
1394
+
1395
+ getCurrentRegionFields: function () {
1396
+ var currentRegion = this.currentRegion;
1397
+ return {
1398
+ isNull: this.yvalues[currentRegion] === null,
1399
+ x: this.xvalues[currentRegion],
1400
+ y: this.yvalues[currentRegion],
1401
+ color: this.options.get('lineColor'),
1402
+ fillColor: this.options.get('fillColor'),
1403
+ offset: currentRegion
1404
+ };
1405
+ },
1406
+
1407
+ renderHighlight: function () {
1408
+ var currentRegion = this.currentRegion,
1409
+ target = this.target,
1410
+ vertex = this.vertices[currentRegion],
1411
+ options = this.options,
1412
+ spotRadius = options.get('spotRadius'),
1413
+ highlightSpotColor = options.get('highlightSpotColor'),
1414
+ highlightLineColor = options.get('highlightLineColor'),
1415
+ highlightSpot, highlightLine;
1416
+
1417
+ if (!vertex) {
1418
+ return;
1419
+ }
1420
+ if (spotRadius && highlightSpotColor) {
1421
+ highlightSpot = target.drawCircle(vertex[0], vertex[1],
1422
+ spotRadius, undefined, highlightSpotColor);
1423
+ this.highlightSpotId = highlightSpot.id;
1424
+ target.insertAfterShape(this.lastShapeId, highlightSpot);
1425
+ }
1426
+ if (highlightLineColor) {
1427
+ highlightLine = target.drawLine(vertex[0], this.canvasTop, vertex[0],
1428
+ this.canvasTop + this.canvasHeight, highlightLineColor);
1429
+ this.highlightLineId = highlightLine.id;
1430
+ target.insertAfterShape(this.lastShapeId, highlightLine);
1431
+ }
1432
+ },
1433
+
1434
+ removeHighlight: function () {
1435
+ var target = this.target;
1436
+ if (this.highlightSpotId) {
1437
+ target.removeShapeId(this.highlightSpotId);
1438
+ this.highlightSpotId = null;
1439
+ }
1440
+ if (this.highlightLineId) {
1441
+ target.removeShapeId(this.highlightLineId);
1442
+ this.highlightLineId = null;
1443
+ }
1444
+ },
1445
+
1446
+ scanValues: function () {
1447
+ var values = this.values,
1448
+ valcount = values.length,
1449
+ xvalues = this.xvalues,
1450
+ yvalues = this.yvalues,
1451
+ yminmax = this.yminmax,
1452
+ i, val, isStr, isArray, sp;
1453
+ for (i = 0; i < valcount; i++) {
1454
+ val = values[i];
1455
+ isStr = typeof(values[i]) === 'string';
1456
+ isArray = typeof(values[i]) === 'object' && values[i] instanceof Array;
1457
+ sp = isStr && values[i].split(':');
1458
+ if (isStr && sp.length === 2) { // x:y
1459
+ xvalues.push(Number(sp[0]));
1460
+ yvalues.push(Number(sp[1]));
1461
+ yminmax.push(Number(sp[1]));
1462
+ } else if (isArray) {
1463
+ xvalues.push(val[0]);
1464
+ yvalues.push(val[1]);
1465
+ yminmax.push(val[1]);
1466
+ } else {
1467
+ xvalues.push(i);
1468
+ if (values[i] === null || values[i] === 'null') {
1469
+ yvalues.push(null);
1470
+ } else {
1471
+ yvalues.push(Number(val));
1472
+ yminmax.push(Number(val));
1473
+ }
1474
+ }
1475
+ }
1476
+ if (this.options.get('xvalues')) {
1477
+ xvalues = this.options.get('xvalues');
1478
+ }
1479
+
1480
+ this.maxy = this.maxyorg = Math.max.apply(Math, yminmax);
1481
+ this.miny = this.minyorg = Math.min.apply(Math, yminmax);
1482
+
1483
+ this.maxx = Math.max.apply(Math, xvalues);
1484
+ this.minx = Math.min.apply(Math, xvalues);
1485
+
1486
+ this.xvalues = xvalues;
1487
+ this.yvalues = yvalues;
1488
+ this.yminmax = yminmax;
1489
+
1490
+ },
1491
+
1492
+ processRangeOptions: function () {
1493
+ var options = this.options,
1494
+ normalRangeMin = options.get('normalRangeMin'),
1495
+ normalRangeMax = options.get('normalRangeMax');
1496
+
1497
+ if (normalRangeMin !== undefined) {
1498
+ if (normalRangeMin < this.miny) {
1499
+ this.miny = normalRangeMin;
1500
+ }
1501
+ if (normalRangeMax > this.maxy) {
1502
+ this.maxy = normalRangeMax;
1503
+ }
1504
+ }
1505
+ if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < this.miny)) {
1506
+ this.miny = options.get('chartRangeMin');
1507
+ }
1508
+ if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > this.maxy)) {
1509
+ this.maxy = options.get('chartRangeMax');
1510
+ }
1511
+ if (options.get('chartRangeMinX') !== undefined && (options.get('chartRangeClipX') || options.get('chartRangeMinX') < this.minx)) {
1512
+ this.minx = options.get('chartRangeMinX');
1513
+ }
1514
+ if (options.get('chartRangeMaxX') !== undefined && (options.get('chartRangeClipX') || options.get('chartRangeMaxX') > this.maxx)) {
1515
+ this.maxx = options.get('chartRangeMaxX');
1516
+ }
1517
+
1518
+ },
1519
+
1520
+ drawNormalRange: function (canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey) {
1521
+ var normalRangeMin = this.options.get('normalRangeMin'),
1522
+ normalRangeMax = this.options.get('normalRangeMax'),
1523
+ ytop = canvasTop + Math.round(canvasHeight - (canvasHeight * ((normalRangeMax - this.miny) / rangey))),
1524
+ height = Math.round((canvasHeight * (normalRangeMax - normalRangeMin)) / rangey);
1525
+ this.target.drawRect(canvasLeft, ytop, canvasWidth, height, undefined, this.options.get('normalRangeColor')).append();
1526
+ },
1527
+
1528
+ render: function () {
1529
+ var options = this.options,
1530
+ target = this.target,
1531
+ canvasWidth = this.canvasWidth,
1532
+ canvasHeight = this.canvasHeight,
1533
+ vertices = this.vertices,
1534
+ spotRadius = options.get('spotRadius'),
1535
+ regionMap = this.regionMap,
1536
+ rangex, rangey, yvallast,
1537
+ canvasTop, canvasLeft,
1538
+ vertex, path, paths, x, y, xnext, xpos, xposnext,
1539
+ last, next, yvalcount, lineShapes, fillShapes, plen,
1540
+ valueSpots, hlSpotsEnabled, color, xvalues, yvalues, i;
1541
+
1542
+ if (!line._super.render.call(this)) {
1543
+ return;
1544
+ }
1545
+
1546
+ this.scanValues();
1547
+ this.processRangeOptions();
1548
+
1549
+ xvalues = this.xvalues;
1550
+ yvalues = this.yvalues;
1551
+
1552
+ if (!this.yminmax.length || this.yvalues.length < 2) {
1553
+ // empty or all null valuess
1554
+ return;
1555
+ }
1556
+
1557
+ canvasTop = canvasLeft = 0;
1558
+
1559
+ rangex = this.maxx - this.minx === 0 ? 1 : this.maxx - this.minx;
1560
+ rangey = this.maxy - this.miny === 0 ? 1 : this.maxy - this.miny;
1561
+ yvallast = this.yvalues.length - 1;
1562
+
1563
+ if (spotRadius && (canvasWidth < (spotRadius * 4) || canvasHeight < (spotRadius * 4))) {
1564
+ spotRadius = 0;
1565
+ }
1566
+ if (spotRadius) {
1567
+ // adjust the canvas size as required so that spots will fit
1568
+ hlSpotsEnabled = options.get('highlightSpotColor') && !options.get('disableInteraction');
1569
+ if (hlSpotsEnabled || options.get('minSpotColor') || (options.get('spotColor') && yvalues[yvallast] === this.miny)) {
1570
+ canvasHeight -= Math.ceil(spotRadius);
1571
+ }
1572
+ if (hlSpotsEnabled || options.get('maxSpotColor') || (options.get('spotColor') && yvalues[yvallast] === this.maxy)) {
1573
+ canvasHeight -= Math.ceil(spotRadius);
1574
+ canvasTop += Math.ceil(spotRadius);
1575
+ }
1576
+ if (hlSpotsEnabled ||
1577
+ ((options.get('minSpotColor') || options.get('maxSpotColor')) && (yvalues[0] === this.miny || yvalues[0] === this.maxy))) {
1578
+ canvasLeft += Math.ceil(spotRadius);
1579
+ canvasWidth -= Math.ceil(spotRadius);
1580
+ }
1581
+ if (hlSpotsEnabled || options.get('spotColor') ||
1582
+ (options.get('minSpotColor') || options.get('maxSpotColor') &&
1583
+ (yvalues[yvallast] === this.miny || yvalues[yvallast] === this.maxy))) {
1584
+ canvasWidth -= Math.ceil(spotRadius);
1585
+ }
1586
+ }
1587
+
1588
+
1589
+ canvasHeight--;
1590
+
1591
+ if (options.get('normalRangeMin') !== undefined && !options.get('drawNormalOnTop')) {
1592
+ this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
1593
+ }
1594
+
1595
+ path = [];
1596
+ paths = [path];
1597
+ last = next = null;
1598
+ yvalcount = yvalues.length;
1599
+ for (i = 0; i < yvalcount; i++) {
1600
+ x = xvalues[i];
1601
+ xnext = xvalues[i + 1];
1602
+ y = yvalues[i];
1603
+ xpos = canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex));
1604
+ xposnext = i < yvalcount - 1 ? canvasLeft + Math.round((xnext - this.minx) * (canvasWidth / rangex)) : canvasWidth;
1605
+ next = xpos + ((xposnext - xpos) / 2);
1606
+ regionMap[i] = [last || 0, next, i];
1607
+ last = next;
1608
+ if (y === null) {
1609
+ if (i) {
1610
+ if (yvalues[i - 1] !== null) {
1611
+ path = [];
1612
+ paths.push(path);
1613
+ }
1614
+ vertices.push(null);
1615
+ }
1616
+ } else {
1617
+ if (y < this.miny) {
1618
+ y = this.miny;
1619
+ }
1620
+ if (y > this.maxy) {
1621
+ y = this.maxy;
1622
+ }
1623
+ if (!path.length) {
1624
+ // previous value was null
1625
+ path.push([xpos, canvasTop + canvasHeight]);
1626
+ }
1627
+ vertex = [xpos, canvasTop + Math.round(canvasHeight - (canvasHeight * ((y - this.miny) / rangey)))];
1628
+ path.push(vertex);
1629
+ vertices.push(vertex);
1630
+ }
1631
+ }
1632
+
1633
+ lineShapes = [];
1634
+ fillShapes = [];
1635
+ plen = paths.length;
1636
+ for (i = 0; i < plen; i++) {
1637
+ path = paths[i];
1638
+ if (path.length) {
1639
+ if (options.get('fillColor')) {
1640
+ path.push([path[path.length - 1][0], (canvasTop + canvasHeight)]);
1641
+ fillShapes.push(path.slice(0));
1642
+ path.pop();
1643
+ }
1644
+ // if there's only a single point in this path, then we want to display it
1645
+ // as a vertical line which means we keep path[0] as is
1646
+ if (path.length > 2) {
1647
+ // else we want the first value
1648
+ path[0] = [path[0][0], path[1][1]];
1649
+ }
1650
+ lineShapes.push(path);
1651
+ }
1652
+ }
1653
+
1654
+ // draw the fill first, then optionally the normal range, then the line on top of that
1655
+ plen = fillShapes.length;
1656
+ for (i = 0; i < plen; i++) {
1657
+ target.drawShape(fillShapes[i],
1658
+ options.get('fillColor'), options.get('fillColor')).append();
1659
+ }
1660
+
1661
+ if (options.get('normalRangeMin') !== undefined && options.get('drawNormalOnTop')) {
1662
+ this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
1663
+ }
1664
+
1665
+ plen = lineShapes.length;
1666
+ for (i = 0; i < plen; i++) {
1667
+ target.drawShape(lineShapes[i], options.get('lineColor'), undefined,
1668
+ options.get('lineWidth')).append();
1669
+ }
1670
+
1671
+ if (spotRadius && options.get('valueSpots')) {
1672
+ valueSpots = options.get('valueSpots');
1673
+ if (valueSpots.get === undefined) {
1674
+ valueSpots = new RangeMap(valueSpots);
1675
+ }
1676
+ for (i = 0; i < yvalcount; i++) {
1677
+ color = valueSpots.get(yvalues[i]);
1678
+ if (color) {
1679
+ target.drawCircle(canvasLeft + Math.round((xvalues[i] - this.minx) * (canvasWidth / rangex)),
1680
+ canvasTop + Math.round(canvasHeight - (canvasHeight * ((yvalues[i] - this.miny) / rangey))),
1681
+ spotRadius, undefined,
1682
+ color).append();
1683
+ }
1684
+ }
1685
+
1686
+ }
1687
+ if (spotRadius && options.get('spotColor') && yvalues[yvallast] !== null) {
1688
+ target.drawCircle(canvasLeft + Math.round((xvalues[xvalues.length - 1] - this.minx) * (canvasWidth / rangex)),
1689
+ canvasTop + Math.round(canvasHeight - (canvasHeight * ((yvalues[yvallast] - this.miny) / rangey))),
1690
+ spotRadius, undefined,
1691
+ options.get('spotColor')).append();
1692
+ }
1693
+ if (this.maxy !== this.minyorg) {
1694
+ if (spotRadius && options.get('minSpotColor')) {
1695
+ x = xvalues[$.inArray(this.minyorg, yvalues)];
1696
+ target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)),
1697
+ canvasTop + Math.round(canvasHeight - (canvasHeight * ((this.minyorg - this.miny) / rangey))),
1698
+ spotRadius, undefined,
1699
+ options.get('minSpotColor')).append();
1700
+ }
1701
+ if (spotRadius && options.get('maxSpotColor')) {
1702
+ x = xvalues[$.inArray(this.maxyorg, yvalues)];
1703
+ target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)),
1704
+ canvasTop + Math.round(canvasHeight - (canvasHeight * ((this.maxyorg - this.miny) / rangey))),
1705
+ spotRadius, undefined,
1706
+ options.get('maxSpotColor')).append();
1707
+ }
1708
+ }
1709
+
1710
+ this.lastShapeId = target.getLastShapeId();
1711
+ this.canvasTop = canvasTop;
1712
+ target.render();
1713
+ }
1714
+ });
1715
+
1716
+
1717
+ /**
1718
+ * Bar charts
1719
+ */
1720
+ $.fn.sparkline.bar = bar = createClass($.fn.sparkline._base, barHighlightMixin, {
1721
+ type: 'bar',
1722
+
1723
+ init: function (el, values, options, width, height) {
1724
+ var barWidth = parseInt(options.get('barWidth'), 10),
1725
+ barSpacing = parseInt(options.get('barSpacing'), 10),
1726
+ chartRangeMin = options.get('chartRangeMin'),
1727
+ chartRangeMax = options.get('chartRangeMax'),
1728
+ chartRangeClip = options.get('chartRangeClip'),
1729
+ stackMin = Infinity,
1730
+ stackMax = -Infinity,
1731
+ isStackString, groupMin, groupMax, stackRanges,
1732
+ numValues, i, vlen, range, zeroAxis, xaxisOffset, min, max, clipMin, clipMax,
1733
+ stacked, vlist, j, slen, svals, val, yoffset, yMaxCalc, canvasHeightEf;
1734
+ bar._super.init.call(this, el, values, options, width, height);
1735
+
1736
+ // scan values to determine whether to stack bars
1737
+ for (i = 0, vlen = values.length; i < vlen; i++) {
1738
+ val = values[i];
1739
+ isStackString = typeof(val) === 'string' && val.indexOf(':') > -1;
1740
+ if (isStackString || $.isArray(val)) {
1741
+ stacked = true;
1742
+ if (isStackString) {
1743
+ val = values[i] = normalizeValues(val.split(':'));
1744
+ }
1745
+ val = remove(val, null); // min/max will treat null as zero
1746
+ groupMin = Math.min.apply(Math, val);
1747
+ groupMax = Math.max.apply(Math, val);
1748
+ if (groupMin < stackMin) {
1749
+ stackMin = groupMin;
1750
+ }
1751
+ if (groupMax > stackMax) {
1752
+ stackMax = groupMax;
1753
+ }
1754
+ }
1755
+ }
1756
+
1757
+ this.stacked = stacked;
1758
+ this.regionShapes = {};
1759
+ this.barWidth = barWidth;
1760
+ this.barSpacing = barSpacing;
1761
+ this.totalBarWidth = barWidth + barSpacing;
1762
+ this.width = width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
1763
+
1764
+ this.initTarget();
1765
+
1766
+ if (chartRangeClip) {
1767
+ clipMin = chartRangeMin === undefined ? -Infinity : chartRangeMin;
1768
+ clipMax = chartRangeMax === undefined ? Infinity : chartRangeMax;
1769
+ }
1770
+
1771
+ numValues = [];
1772
+ stackRanges = stacked ? [] : numValues;
1773
+ var stackTotals = [];
1774
+ var stackRangesNeg = [];
1775
+ for (i = 0, vlen = values.length; i < vlen; i++) {
1776
+ if (stacked) {
1777
+ vlist = values[i];
1778
+ values[i] = svals = [];
1779
+ stackTotals[i] = 0;
1780
+ stackRanges[i] = stackRangesNeg[i] = 0;
1781
+ for (j = 0, slen = vlist.length; j < slen; j++) {
1782
+ val = svals[j] = chartRangeClip ? clipval(vlist[j], clipMin, clipMax) : vlist[j];
1783
+ if (val !== null) {
1784
+ if (val > 0) {
1785
+ stackTotals[i] += val;
1786
+ }
1787
+ if (stackMin < 0 && stackMax > 0) {
1788
+ if (val < 0) {
1789
+ stackRangesNeg[i] += Math.abs(val);
1790
+ } else {
1791
+ stackRanges[i] += val;
1792
+ }
1793
+ } else {
1794
+ stackRanges[i] += Math.abs(val - (val < 0 ? stackMax : stackMin));
1795
+ }
1796
+ numValues.push(val);
1797
+ }
1798
+ }
1799
+ } else {
1800
+ val = chartRangeClip ? clipval(values[i], clipMin, clipMax) : values[i];
1801
+ val = values[i] = normalizeValue(val);
1802
+ if (val !== null) {
1803
+ numValues.push(val);
1804
+ }
1805
+ }
1806
+ }
1807
+ this.max = max = Math.max.apply(Math, numValues);
1808
+ this.min = min = Math.min.apply(Math, numValues);
1809
+ this.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
1810
+ this.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
1811
+
1812
+ if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < min)) {
1813
+ min = options.get('chartRangeMin');
1814
+ }
1815
+ if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > max)) {
1816
+ max = options.get('chartRangeMax');
1817
+ }
1818
+
1819
+ this.zeroAxis = zeroAxis = options.get('zeroAxis', true);
1820
+ if (min <= 0 && max >= 0 && zeroAxis) {
1821
+ xaxisOffset = 0;
1822
+ } else if (zeroAxis == false) {
1823
+ xaxisOffset = min;
1824
+ } else if (min > 0) {
1825
+ xaxisOffset = min;
1826
+ } else {
1827
+ xaxisOffset = max;
1828
+ }
1829
+ this.xaxisOffset = xaxisOffset;
1830
+
1831
+ range = stacked ? (Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg)) : max - min;
1832
+
1833
+ // as we plot zero/min values a single pixel line, we add a pixel to all other
1834
+ // values - Reduce the effective canvas size to suit
1835
+ this.canvasHeightEf = (zeroAxis && min < 0) ? this.canvasHeight - 2 : this.canvasHeight - 1;
1836
+
1837
+ if (min < xaxisOffset) {
1838
+ yMaxCalc = (stacked && max >= 0) ? stackMax : max;
1839
+ yoffset = (yMaxCalc - xaxisOffset) / range * this.canvasHeight;
1840
+ if (yoffset !== Math.ceil(yoffset)) {
1841
+ this.canvasHeightEf -= 2;
1842
+ yoffset = Math.ceil(yoffset);
1843
+ }
1844
+ } else {
1845
+ yoffset = this.canvasHeight;
1846
+ }
1847
+ this.yoffset = yoffset;
1848
+
1849
+ if ($.isArray(options.get('colorMap'))) {
1850
+ this.colorMapByIndex = options.get('colorMap');
1851
+ this.colorMapByValue = null;
1852
+ } else {
1853
+ this.colorMapByIndex = null;
1854
+ this.colorMapByValue = options.get('colorMap');
1855
+ if (this.colorMapByValue && this.colorMapByValue.get === undefined) {
1856
+ this.colorMapByValue = new RangeMap(this.colorMapByValue);
1857
+ }
1858
+ }
1859
+
1860
+ this.range = range;
1861
+ },
1862
+
1863
+ getRegion: function (el, x, y) {
1864
+ var result = Math.floor(x / this.totalBarWidth);
1865
+ return (result < 0 || result >= this.values.length) ? undefined : result;
1866
+ },
1867
+
1868
+ getCurrentRegionFields: function () {
1869
+ var currentRegion = this.currentRegion,
1870
+ values = ensureArray(this.values[currentRegion]),
1871
+ result = [],
1872
+ value, i;
1873
+ for (i = values.length; i--;) {
1874
+ value = values[i];
1875
+ result.push({
1876
+ isNull: value === null,
1877
+ value: value,
1878
+ color: this.calcColor(i, value, currentRegion),
1879
+ offset: currentRegion
1880
+ });
1881
+ }
1882
+ return result;
1883
+ },
1884
+
1885
+ calcColor: function (stacknum, value, valuenum) {
1886
+ var colorMapByIndex = this.colorMapByIndex,
1887
+ colorMapByValue = this.colorMapByValue,
1888
+ options = this.options,
1889
+ color, newColor;
1890
+ if (this.stacked) {
1891
+ color = options.get('stackedBarColor');
1892
+ } else {
1893
+ color = (value < 0) ? options.get('negBarColor') : options.get('barColor');
1894
+ }
1895
+ if (value === 0 && options.get('zeroColor') !== undefined) {
1896
+ color = options.get('zeroColor');
1897
+ }
1898
+ if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
1899
+ color = newColor;
1900
+ } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
1901
+ color = colorMapByIndex[valuenum];
1902
+ }
1903
+ return $.isArray(color) ? color[stacknum % color.length] : color;
1904
+ },
1905
+
1906
+ /**
1907
+ * Render bar(s) for a region
1908
+ */
1909
+ renderRegion: function (valuenum, highlight) {
1910
+ var vals = this.values[valuenum],
1911
+ options = this.options,
1912
+ xaxisOffset = this.xaxisOffset,
1913
+ result = [],
1914
+ range = this.range,
1915
+ stacked = this.stacked,
1916
+ target = this.target,
1917
+ x = valuenum * this.totalBarWidth,
1918
+ canvasHeightEf = this.canvasHeightEf,
1919
+ yoffset = this.yoffset,
1920
+ y, height, color, isNull, yoffsetNeg, i, valcount, val, minPlotted, allMin;
1921
+
1922
+ vals = $.isArray(vals) ? vals : [vals];
1923
+ valcount = vals.length;
1924
+ val = vals[0];
1925
+ isNull = all(null, vals);
1926
+ allMin = all(xaxisOffset, vals, true);
1927
+
1928
+ if (isNull) {
1929
+ if (options.get('nullColor')) {
1930
+ color = highlight ? options.get('nullColor') : this.calcHighlightColor(options.get('nullColor'), options);
1931
+ y = (yoffset > 0) ? yoffset - 1 : yoffset;
1932
+ return target.drawRect(x, y, this.barWidth - 1, 0, color, color);
1933
+ } else {
1934
+ return undefined;
1935
+ }
1936
+ }
1937
+ yoffsetNeg = yoffset;
1938
+ for (i = 0; i < valcount; i++) {
1939
+ val = vals[i];
1940
+
1941
+ if (stacked && val === xaxisOffset) {
1942
+ if (!allMin || minPlotted) {
1943
+ continue;
1944
+ }
1945
+ minPlotted = true;
1946
+ }
1947
+
1948
+ if (range > 0) {
1949
+ height = Math.floor(canvasHeightEf * ((Math.abs(val - xaxisOffset) / range))) + 1;
1950
+ } else {
1951
+ height = 1;
1952
+ }
1953
+ if (val < xaxisOffset || (val === xaxisOffset && yoffset === 0)) {
1954
+ y = yoffsetNeg;
1955
+ yoffsetNeg += height;
1956
+ } else {
1957
+ y = yoffset - height;
1958
+ yoffset -= height;
1959
+ }
1960
+ color = this.calcColor(i, val, valuenum);
1961
+ if (highlight) {
1962
+ color = this.calcHighlightColor(color, options);
1963
+ }
1964
+ result.push(target.drawRect(x, y, this.barWidth - 1, height - 1, color, color));
1965
+ }
1966
+ if (result.length === 1) {
1967
+ return result[0];
1968
+ }
1969
+ return result;
1970
+ }
1971
+ });
1972
+
1973
+
1974
+ /**
1975
+ * Tristate charts
1976
+ */
1977
+ $.fn.sparkline.tristate = tristate = createClass($.fn.sparkline._base, barHighlightMixin, {
1978
+ type: 'tristate',
1979
+
1980
+ init: function (el, values, options, width, height) {
1981
+ var barWidth = parseInt(options.get('barWidth'), 10),
1982
+ barSpacing = parseInt(options.get('barSpacing'), 10);
1983
+ tristate._super.init.call(this, el, values, options, width, height);
1984
+
1985
+ this.regionShapes = {};
1986
+ this.barWidth = barWidth;
1987
+ this.barSpacing = barSpacing;
1988
+ this.totalBarWidth = barWidth + barSpacing;
1989
+ this.values = $.map(values, Number);
1990
+ this.width = width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
1991
+
1992
+ if ($.isArray(options.get('colorMap'))) {
1993
+ this.colorMapByIndex = options.get('colorMap');
1994
+ this.colorMapByValue = null;
1995
+ } else {
1996
+ this.colorMapByIndex = null;
1997
+ this.colorMapByValue = options.get('colorMap');
1998
+ if (this.colorMapByValue && this.colorMapByValue.get === undefined) {
1999
+ this.colorMapByValue = new RangeMap(this.colorMapByValue);
2000
+ }
2001
+ }
2002
+ this.initTarget();
2003
+ },
2004
+
2005
+ getRegion: function (el, x, y) {
2006
+ return Math.floor(x / this.totalBarWidth);
2007
+ },
2008
+
2009
+ getCurrentRegionFields: function () {
2010
+ var currentRegion = this.currentRegion;
2011
+ return {
2012
+ isNull: this.values[currentRegion] === undefined,
2013
+ value: this.values[currentRegion],
2014
+ color: this.calcColor(this.values[currentRegion], currentRegion),
2015
+ offset: currentRegion
2016
+ };
2017
+ },
2018
+
2019
+ calcColor: function (value, valuenum) {
2020
+ var values = this.values,
2021
+ options = this.options,
2022
+ colorMapByIndex = this.colorMapByIndex,
2023
+ colorMapByValue = this.colorMapByValue,
2024
+ color, newColor;
2025
+
2026
+ if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
2027
+ color = newColor;
2028
+ } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
2029
+ color = colorMapByIndex[valuenum];
2030
+ } else if (values[valuenum] < 0) {
2031
+ color = options.get('negBarColor');
2032
+ } else if (values[valuenum] > 0) {
2033
+ color = options.get('posBarColor');
2034
+ } else {
2035
+ color = options.get('zeroBarColor');
2036
+ }
2037
+ return color;
2038
+ },
2039
+
2040
+ renderRegion: function (valuenum, highlight) {
2041
+ var values = this.values,
2042
+ options = this.options,
2043
+ target = this.target,
2044
+ canvasHeight, height, halfHeight,
2045
+ x, y, color;
2046
+
2047
+ canvasHeight = target.pixelHeight;
2048
+ halfHeight = Math.round(canvasHeight / 2);
2049
+
2050
+ x = valuenum * this.totalBarWidth;
2051
+ if (values[valuenum] < 0) {
2052
+ y = halfHeight;
2053
+ height = halfHeight - 1;
2054
+ } else if (values[valuenum] > 0) {
2055
+ y = 0;
2056
+ height = halfHeight - 1;
2057
+ } else {
2058
+ y = halfHeight - 1;
2059
+ height = 2;
2060
+ }
2061
+ color = this.calcColor(values[valuenum], valuenum);
2062
+ if (color === null) {
2063
+ return;
2064
+ }
2065
+ if (highlight) {
2066
+ color = this.calcHighlightColor(color, options);
2067
+ }
2068
+ return target.drawRect(x, y, this.barWidth - 1, height - 1, color, color);
2069
+ }
2070
+ });
2071
+
2072
+
2073
+ /**
2074
+ * Discrete charts
2075
+ */
2076
+ $.fn.sparkline.discrete = discrete = createClass($.fn.sparkline._base, barHighlightMixin, {
2077
+ type: 'discrete',
2078
+
2079
+ init: function (el, values, options, width, height) {
2080
+ discrete._super.init.call(this, el, values, options, width, height);
2081
+
2082
+ this.regionShapes = {};
2083
+ this.values = values = $.map(values, Number);
2084
+ this.min = Math.min.apply(Math, values);
2085
+ this.max = Math.max.apply(Math, values);
2086
+ this.range = this.max - this.min;
2087
+ this.width = width = options.get('width') === 'auto' ? values.length * 2 : this.width;
2088
+ this.interval = Math.floor(width / values.length);
2089
+ this.itemWidth = width / values.length;
2090
+ if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < this.min)) {
2091
+ this.min = options.get('chartRangeMin');
2092
+ }
2093
+ if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > this.max)) {
2094
+ this.max = options.get('chartRangeMax');
2095
+ }
2096
+ this.initTarget();
2097
+ if (this.target) {
2098
+ this.lineHeight = options.get('lineHeight') === 'auto' ? Math.round(this.canvasHeight * 0.3) : options.get('lineHeight');
2099
+ }
2100
+ },
2101
+
2102
+ getRegion: function (el, x, y) {
2103
+ return Math.floor(x / this.itemWidth);
2104
+ },
2105
+
2106
+ getCurrentRegionFields: function () {
2107
+ var currentRegion = this.currentRegion;
2108
+ return {
2109
+ isNull: this.values[currentRegion] === undefined,
2110
+ value: this.values[currentRegion],
2111
+ offset: currentRegion
2112
+ };
2113
+ },
2114
+
2115
+ renderRegion: function (valuenum, highlight) {
2116
+ var values = this.values,
2117
+ options = this.options,
2118
+ min = this.min,
2119
+ max = this.max,
2120
+ range = this.range,
2121
+ interval = this.interval,
2122
+ target = this.target,
2123
+ canvasHeight = this.canvasHeight,
2124
+ lineHeight = this.lineHeight,
2125
+ pheight = canvasHeight - lineHeight,
2126
+ ytop, val, color, x;
2127
+
2128
+ val = clipval(values[valuenum], min, max);
2129
+ x = valuenum * interval;
2130
+ ytop = Math.round(pheight - pheight * ((val - min) / range));
2131
+ color = (options.get('thresholdColor') && val < options.get('thresholdValue')) ? options.get('thresholdColor') : options.get('lineColor');
2132
+ if (highlight) {
2133
+ color = this.calcHighlightColor(color, options);
2134
+ }
2135
+ return target.drawLine(x, ytop, x, ytop + lineHeight, color);
2136
+ }
2137
+ });
2138
+
2139
+
2140
+ /**
2141
+ * Bullet charts
2142
+ */
2143
+ $.fn.sparkline.bullet = bullet = createClass($.fn.sparkline._base, {
2144
+ type: 'bullet',
2145
+
2146
+ init: function (el, values, options, width, height) {
2147
+ var min, max, vals;
2148
+ bullet._super.init.call(this, el, values, options, width, height);
2149
+
2150
+ // values: target, performance, range1, range2, range3
2151
+ this.values = values = normalizeValues(values);
2152
+ // target or performance could be null
2153
+ vals = values.slice();
2154
+ vals[0] = vals[0] === null ? vals[2] : vals[0];
2155
+ vals[1] = values[1] === null ? vals[2] : vals[1];
2156
+ min = Math.min.apply(Math, values);
2157
+ max = Math.max.apply(Math, values);
2158
+ if (options.get('base') === undefined) {
2159
+ min = min < 0 ? min : 0;
2160
+ } else {
2161
+ min = options.get('base');
2162
+ }
2163
+ this.min = min;
2164
+ this.max = max;
2165
+ this.range = max - min;
2166
+ this.shapes = {};
2167
+ this.valueShapes = {};
2168
+ this.regiondata = {};
2169
+ this.width = width = options.get('width') === 'auto' ? '4.0em' : width;
2170
+ this.target = this.$el.simpledraw(width, height, options.get('composite'));
2171
+ if (!values.length) {
2172
+ this.disabled = true;
2173
+ }
2174
+ this.initTarget();
2175
+ },
2176
+
2177
+ getRegion: function (el, x, y) {
2178
+ var shapeid = this.target.getShapeAt(el, x, y);
2179
+ return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
2180
+ },
2181
+
2182
+ getCurrentRegionFields: function () {
2183
+ var currentRegion = this.currentRegion;
2184
+ return {
2185
+ fieldkey: currentRegion.substr(0, 1),
2186
+ value: this.values[currentRegion.substr(1)],
2187
+ region: currentRegion
2188
+ };
2189
+ },
2190
+
2191
+ changeHighlight: function (highlight) {
2192
+ var currentRegion = this.currentRegion,
2193
+ shapeid = this.valueShapes[currentRegion],
2194
+ shape;
2195
+ delete this.shapes[shapeid];
2196
+ switch (currentRegion.substr(0, 1)) {
2197
+ case 'r':
2198
+ shape = this.renderRange(currentRegion.substr(1), highlight);
2199
+ break;
2200
+ case 'p':
2201
+ shape = this.renderPerformance(highlight);
2202
+ break;
2203
+ case 't':
2204
+ shape = this.renderTarget(highlight);
2205
+ break;
2206
+ }
2207
+ this.valueShapes[currentRegion] = shape.id;
2208
+ this.shapes[shape.id] = currentRegion;
2209
+ this.target.replaceWithShape(shapeid, shape);
2210
+ },
2211
+
2212
+ renderRange: function (rn, highlight) {
2213
+ var rangeval = this.values[rn],
2214
+ rangewidth = Math.round(this.canvasWidth * ((rangeval - this.min) / this.range)),
2215
+ color = this.options.get('rangeColors')[rn - 2];
2216
+ if (highlight) {
2217
+ color = this.calcHighlightColor(color, this.options);
2218
+ }
2219
+ return this.target.drawRect(0, 0, rangewidth - 1, this.canvasHeight - 1, color, color);
2220
+ },
2221
+
2222
+ renderPerformance: function (highlight) {
2223
+ var perfval = this.values[1],
2224
+ perfwidth = Math.round(this.canvasWidth * ((perfval - this.min) / this.range)),
2225
+ color = this.options.get('performanceColor');
2226
+ if (highlight) {
2227
+ color = this.calcHighlightColor(color, this.options);
2228
+ }
2229
+ return this.target.drawRect(0, Math.round(this.canvasHeight * 0.3), perfwidth - 1,
2230
+ Math.round(this.canvasHeight * 0.4) - 1, color, color);
2231
+ },
2232
+
2233
+ renderTarget: function (highlight) {
2234
+ var targetval = this.values[0],
2235
+ x = Math.round(this.canvasWidth * ((targetval - this.min) / this.range) - (this.options.get('targetWidth') / 2)),
2236
+ targettop = Math.round(this.canvasHeight * 0.10),
2237
+ targetheight = this.canvasHeight - (targettop * 2),
2238
+ color = this.options.get('targetColor');
2239
+ if (highlight) {
2240
+ color = this.calcHighlightColor(color, this.options);
2241
+ }
2242
+ return this.target.drawRect(x, targettop, this.options.get('targetWidth') - 1, targetheight - 1, color, color);
2243
+ },
2244
+
2245
+ render: function () {
2246
+ var vlen = this.values.length,
2247
+ target = this.target,
2248
+ i, shape;
2249
+ if (!bullet._super.render.call(this)) {
2250
+ return;
2251
+ }
2252
+ for (i = 2; i < vlen; i++) {
2253
+ shape = this.renderRange(i).append();
2254
+ this.shapes[shape.id] = 'r' + i;
2255
+ this.valueShapes['r' + i] = shape.id;
2256
+ }
2257
+ if (this.values[1] !== null) {
2258
+ shape = this.renderPerformance().append();
2259
+ this.shapes[shape.id] = 'p1';
2260
+ this.valueShapes.p1 = shape.id;
2261
+ }
2262
+ if (this.values[0] !== null) {
2263
+ shape = this.renderTarget().append();
2264
+ this.shapes[shape.id] = 't0';
2265
+ this.valueShapes.t0 = shape.id;
2266
+ }
2267
+ target.render();
2268
+ }
2269
+ });
2270
+
2271
+
2272
+ /**
2273
+ * Pie charts
2274
+ */
2275
+ $.fn.sparkline.pie = pie = createClass($.fn.sparkline._base, {
2276
+ type: 'pie',
2277
+
2278
+ init: function (el, values, options, width, height) {
2279
+ var total = 0, i;
2280
+
2281
+ pie._super.init.call(this, el, values, options, width, height);
2282
+
2283
+ this.shapes = {}; // map shape ids to value offsets
2284
+ this.valueShapes = {}; // maps value offsets to shape ids
2285
+ this.values = values = $.map(values, Number);
2286
+
2287
+ if (options.get('width') === 'auto') {
2288
+ this.width = this.height;
2289
+ }
2290
+
2291
+ if (values.length > 0) {
2292
+ for (i = values.length; i--;) {
2293
+ total += values[i];
2294
+ }
2295
+ }
2296
+ this.total = total;
2297
+ this.initTarget();
2298
+ this.radius = Math.floor(Math.min(this.canvasWidth, this.canvasHeight) / 2);
2299
+ },
2300
+
2301
+ getRegion: function (el, x, y) {
2302
+ var shapeid = this.target.getShapeAt(el, x, y);
2303
+ return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
2304
+ },
2305
+
2306
+ getCurrentRegionFields: function () {
2307
+ var currentRegion = this.currentRegion;
2308
+ return {
2309
+ isNull: this.values[currentRegion] === undefined,
2310
+ value: this.values[currentRegion],
2311
+ percent: this.values[currentRegion] / this.total * 100,
2312
+ color: this.options.get('sliceColors')[currentRegion % this.options.get('sliceColors').length],
2313
+ offset: currentRegion
2314
+ };
2315
+ },
2316
+
2317
+ changeHighlight: function (highlight) {
2318
+ var currentRegion = this.currentRegion,
2319
+ newslice = this.renderSlice(currentRegion, highlight),
2320
+ shapeid = this.valueShapes[currentRegion];
2321
+ delete this.shapes[shapeid];
2322
+ this.target.replaceWithShape(shapeid, newslice);
2323
+ this.valueShapes[currentRegion] = newslice.id;
2324
+ this.shapes[newslice.id] = currentRegion;
2325
+ },
2326
+
2327
+ renderSlice: function (valuenum, highlight) {
2328
+ var target = this.target,
2329
+ options = this.options,
2330
+ radius = this.radius,
2331
+ borderWidth = options.get('borderWidth'),
2332
+ offset = options.get('offset'),
2333
+ circle = 2 * Math.PI,
2334
+ values = this.values,
2335
+ total = this.total,
2336
+ next = offset ? (2*Math.PI)*(offset/360) : 0,
2337
+ start, end, i, vlen, color;
2338
+
2339
+ vlen = values.length;
2340
+ for (i = 0; i < vlen; i++) {
2341
+ start = next;
2342
+ end = next;
2343
+ if (total > 0) { // avoid divide by zero
2344
+ end = next + (circle * (values[i] / total));
2345
+ }
2346
+ if (valuenum === i) {
2347
+ color = options.get('sliceColors')[i % options.get('sliceColors').length];
2348
+ if (highlight) {
2349
+ color = this.calcHighlightColor(color, options);
2350
+ }
2351
+
2352
+ return target.drawPieSlice(radius, radius, radius - borderWidth, start, end, undefined, color);
2353
+ }
2354
+ next = end;
2355
+ }
2356
+ },
2357
+
2358
+ render: function () {
2359
+ var target = this.target,
2360
+ values = this.values,
2361
+ options = this.options,
2362
+ radius = this.radius,
2363
+ borderWidth = options.get('borderWidth'),
2364
+ shape, i;
2365
+
2366
+ if (!pie._super.render.call(this)) {
2367
+ return;
2368
+ }
2369
+ if (borderWidth) {
2370
+ target.drawCircle(radius, radius, Math.floor(radius - (borderWidth / 2)),
2371
+ options.get('borderColor'), undefined, borderWidth).append();
2372
+ }
2373
+ for (i = values.length; i--;) {
2374
+ if (values[i]) { // don't render zero values
2375
+ shape = this.renderSlice(i).append();
2376
+ this.valueShapes[i] = shape.id; // store just the shapeid
2377
+ this.shapes[shape.id] = i;
2378
+ }
2379
+ }
2380
+ target.render();
2381
+ }
2382
+ });
2383
+
2384
+
2385
+ /**
2386
+ * Box plots
2387
+ */
2388
+ $.fn.sparkline.box = box = createClass($.fn.sparkline._base, {
2389
+ type: 'box',
2390
+
2391
+ init: function (el, values, options, width, height) {
2392
+ box._super.init.call(this, el, values, options, width, height);
2393
+ this.values = $.map(values, Number);
2394
+ this.width = options.get('width') === 'auto' ? '4.0em' : width;
2395
+ this.initTarget();
2396
+ if (!this.values.length) {
2397
+ this.disabled = 1;
2398
+ }
2399
+ },
2400
+
2401
+ /**
2402
+ * Simulate a single region
2403
+ */
2404
+ getRegion: function () {
2405
+ return 1;
2406
+ },
2407
+
2408
+ getCurrentRegionFields: function () {
2409
+ var result = [
2410
+ { field: 'lq', value: this.quartiles[0] },
2411
+ { field: 'med', value: this.quartiles[1] },
2412
+ { field: 'uq', value: this.quartiles[2] }
2413
+ ];
2414
+ if (this.loutlier !== undefined) {
2415
+ result.push({ field: 'lo', value: this.loutlier});
2416
+ }
2417
+ if (this.routlier !== undefined) {
2418
+ result.push({ field: 'ro', value: this.routlier});
2419
+ }
2420
+ if (this.lwhisker !== undefined) {
2421
+ result.push({ field: 'lw', value: this.lwhisker});
2422
+ }
2423
+ if (this.rwhisker !== undefined) {
2424
+ result.push({ field: 'rw', value: this.rwhisker});
2425
+ }
2426
+ return result;
2427
+ },
2428
+
2429
+ render: function () {
2430
+ var target = this.target,
2431
+ values = this.values,
2432
+ vlen = values.length,
2433
+ options = this.options,
2434
+ canvasWidth = this.canvasWidth,
2435
+ canvasHeight = this.canvasHeight,
2436
+ minValue = options.get('chartRangeMin') === undefined ? Math.min.apply(Math, values) : options.get('chartRangeMin'),
2437
+ maxValue = options.get('chartRangeMax') === undefined ? Math.max.apply(Math, values) : options.get('chartRangeMax'),
2438
+ canvasLeft = 0,
2439
+ lwhisker, loutlier, iqr, q1, q2, q3, rwhisker, routlier, i,
2440
+ size, unitSize;
2441
+
2442
+ if (!box._super.render.call(this)) {
2443
+ return;
2444
+ }
2445
+
2446
+ if (options.get('raw')) {
2447
+ if (options.get('showOutliers') && values.length > 5) {
2448
+ loutlier = values[0];
2449
+ lwhisker = values[1];
2450
+ q1 = values[2];
2451
+ q2 = values[3];
2452
+ q3 = values[4];
2453
+ rwhisker = values[5];
2454
+ routlier = values[6];
2455
+ } else {
2456
+ lwhisker = values[0];
2457
+ q1 = values[1];
2458
+ q2 = values[2];
2459
+ q3 = values[3];
2460
+ rwhisker = values[4];
2461
+ }
2462
+ } else {
2463
+ values.sort(function (a, b) { return a - b; });
2464
+ q1 = quartile(values, 1);
2465
+ q2 = quartile(values, 2);
2466
+ q3 = quartile(values, 3);
2467
+ iqr = q3 - q1;
2468
+ if (options.get('showOutliers')) {
2469
+ lwhisker = rwhisker = undefined;
2470
+ for (i = 0; i < vlen; i++) {
2471
+ if (lwhisker === undefined && values[i] > q1 - (iqr * options.get('outlierIQR'))) {
2472
+ lwhisker = values[i];
2473
+ }
2474
+ if (values[i] < q3 + (iqr * options.get('outlierIQR'))) {
2475
+ rwhisker = values[i];
2476
+ }
2477
+ }
2478
+ loutlier = values[0];
2479
+ routlier = values[vlen - 1];
2480
+ } else {
2481
+ lwhisker = values[0];
2482
+ rwhisker = values[vlen - 1];
2483
+ }
2484
+ }
2485
+ this.quartiles = [q1, q2, q3];
2486
+ this.lwhisker = lwhisker;
2487
+ this.rwhisker = rwhisker;
2488
+ this.loutlier = loutlier;
2489
+ this.routlier = routlier;
2490
+
2491
+ unitSize = canvasWidth / (maxValue - minValue + 1);
2492
+ if (options.get('showOutliers')) {
2493
+ canvasLeft = Math.ceil(options.get('spotRadius'));
2494
+ canvasWidth -= 2 * Math.ceil(options.get('spotRadius'));
2495
+ unitSize = canvasWidth / (maxValue - minValue + 1);
2496
+ if (loutlier < lwhisker) {
2497
+ target.drawCircle((loutlier - minValue) * unitSize + canvasLeft,
2498
+ canvasHeight / 2,
2499
+ options.get('spotRadius'),
2500
+ options.get('outlierLineColor'),
2501
+ options.get('outlierFillColor')).append();
2502
+ }
2503
+ if (routlier > rwhisker) {
2504
+ target.drawCircle((routlier - minValue) * unitSize + canvasLeft,
2505
+ canvasHeight / 2,
2506
+ options.get('spotRadius'),
2507
+ options.get('outlierLineColor'),
2508
+ options.get('outlierFillColor')).append();
2509
+ }
2510
+ }
2511
+
2512
+ // box
2513
+ target.drawRect(
2514
+ Math.round((q1 - minValue) * unitSize + canvasLeft),
2515
+ Math.round(canvasHeight * 0.1),
2516
+ Math.round((q3 - q1) * unitSize),
2517
+ Math.round(canvasHeight * 0.8),
2518
+ options.get('boxLineColor'),
2519
+ options.get('boxFillColor')).append();
2520
+ // left whisker
2521
+ target.drawLine(
2522
+ Math.round((lwhisker - minValue) * unitSize + canvasLeft),
2523
+ Math.round(canvasHeight / 2),
2524
+ Math.round((q1 - minValue) * unitSize + canvasLeft),
2525
+ Math.round(canvasHeight / 2),
2526
+ options.get('lineColor')).append();
2527
+ target.drawLine(
2528
+ Math.round((lwhisker - minValue) * unitSize + canvasLeft),
2529
+ Math.round(canvasHeight / 4),
2530
+ Math.round((lwhisker - minValue) * unitSize + canvasLeft),
2531
+ Math.round(canvasHeight - canvasHeight / 4),
2532
+ options.get('whiskerColor')).append();
2533
+ // right whisker
2534
+ target.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft),
2535
+ Math.round(canvasHeight / 2),
2536
+ Math.round((q3 - minValue) * unitSize + canvasLeft),
2537
+ Math.round(canvasHeight / 2),
2538
+ options.get('lineColor')).append();
2539
+ target.drawLine(
2540
+ Math.round((rwhisker - minValue) * unitSize + canvasLeft),
2541
+ Math.round(canvasHeight / 4),
2542
+ Math.round((rwhisker - minValue) * unitSize + canvasLeft),
2543
+ Math.round(canvasHeight - canvasHeight / 4),
2544
+ options.get('whiskerColor')).append();
2545
+ // median line
2546
+ target.drawLine(
2547
+ Math.round((q2 - minValue) * unitSize + canvasLeft),
2548
+ Math.round(canvasHeight * 0.1),
2549
+ Math.round((q2 - minValue) * unitSize + canvasLeft),
2550
+ Math.round(canvasHeight * 0.9),
2551
+ options.get('medianColor')).append();
2552
+ if (options.get('target')) {
2553
+ size = Math.ceil(options.get('spotRadius'));
2554
+ target.drawLine(
2555
+ Math.round((options.get('target') - minValue) * unitSize + canvasLeft),
2556
+ Math.round((canvasHeight / 2) - size),
2557
+ Math.round((options.get('target') - minValue) * unitSize + canvasLeft),
2558
+ Math.round((canvasHeight / 2) + size),
2559
+ options.get('targetColor')).append();
2560
+ target.drawLine(
2561
+ Math.round((options.get('target') - minValue) * unitSize + canvasLeft - size),
2562
+ Math.round(canvasHeight / 2),
2563
+ Math.round((options.get('target') - minValue) * unitSize + canvasLeft + size),
2564
+ Math.round(canvasHeight / 2),
2565
+ options.get('targetColor')).append();
2566
+ }
2567
+ target.render();
2568
+ }
2569
+ });
2570
+
2571
+
2572
+ // Setup a very simple "virtual canvas" to make drawing the few shapes we need easier
2573
+ // This is accessible as $(foo).simpledraw()
2574
+
2575
+ VShape = createClass({
2576
+ init: function (target, id, type, args) {
2577
+ this.target = target;
2578
+ this.id = id;
2579
+ this.type = type;
2580
+ this.args = args;
2581
+ },
2582
+ append: function () {
2583
+ this.target.appendShape(this);
2584
+ return this;
2585
+ }
2586
+ });
2587
+
2588
+ VCanvas_base = createClass({
2589
+ _pxregex: /(\d+)(px)?\s*$/i,
2590
+
2591
+ init: function (width, height, target) {
2592
+ if (!width) {
2593
+ return;
2594
+ }
2595
+ this.width = width;
2596
+ this.height = height;
2597
+ this.target = target;
2598
+ this.lastShapeId = null;
2599
+ if (target[0]) {
2600
+ target = target[0];
2601
+ }
2602
+ $.data(target, '_jqs_vcanvas', this);
2603
+ },
2604
+
2605
+ drawLine: function (x1, y1, x2, y2, lineColor, lineWidth) {
2606
+ return this.drawShape([[x1, y1], [x2, y2]], lineColor, lineWidth);
2607
+ },
2608
+
2609
+ drawShape: function (path, lineColor, fillColor, lineWidth) {
2610
+ return this._genShape('Shape', [path, lineColor, fillColor, lineWidth]);
2611
+ },
2612
+
2613
+ drawCircle: function (x, y, radius, lineColor, fillColor, lineWidth) {
2614
+ return this._genShape('Circle', [x, y, radius, lineColor, fillColor, lineWidth]);
2615
+ },
2616
+
2617
+ drawPieSlice: function (x, y, radius, startAngle, endAngle, lineColor, fillColor) {
2618
+ return this._genShape('PieSlice', [x, y, radius, startAngle, endAngle, lineColor, fillColor]);
2619
+ },
2620
+
2621
+ drawRect: function (x, y, width, height, lineColor, fillColor) {
2622
+ return this._genShape('Rect', [x, y, width, height, lineColor, fillColor]);
2623
+ },
2624
+
2625
+ getElement: function () {
2626
+ return this.canvas;
2627
+ },
2628
+
2629
+ /**
2630
+ * Return the most recently inserted shape id
2631
+ */
2632
+ getLastShapeId: function () {
2633
+ return this.lastShapeId;
2634
+ },
2635
+
2636
+ /**
2637
+ * Clear and reset the canvas
2638
+ */
2639
+ reset: function () {
2640
+ window.alert('reset not implemented');
2641
+ },
2642
+
2643
+ _insert: function (el, target) {
2644
+ $(target).html(el);
2645
+ },
2646
+
2647
+ /**
2648
+ * Calculate the pixel dimensions of the canvas
2649
+ */
2650
+ _calculatePixelDims: function (width, height, canvas) {
2651
+ // XXX This should probably be a configurable option
2652
+ var match;
2653
+ match = this._pxregex.exec(height);
2654
+ if (match) {
2655
+ this.pixelHeight = match[1];
2656
+ } else {
2657
+ this.pixelHeight = $(canvas).height();
2658
+ }
2659
+ match = this._pxregex.exec(width);
2660
+ if (match) {
2661
+ this.pixelWidth = match[1];
2662
+ } else {
2663
+ this.pixelWidth = $(canvas).width();
2664
+ }
2665
+ },
2666
+
2667
+ /**
2668
+ * Generate a shape object and id for later rendering
2669
+ */
2670
+ _genShape: function (shapetype, shapeargs) {
2671
+ var id = shapeCount++;
2672
+ shapeargs.unshift(id);
2673
+ return new VShape(this, id, shapetype, shapeargs);
2674
+ },
2675
+
2676
+ /**
2677
+ * Add a shape to the end of the render queue
2678
+ */
2679
+ appendShape: function (shape) {
2680
+ window.alert('appendShape not implemented');
2681
+ },
2682
+
2683
+ /**
2684
+ * Replace one shape with another
2685
+ */
2686
+ replaceWithShape: function (shapeid, shape) {
2687
+ window.alert('replaceWithShape not implemented');
2688
+ },
2689
+
2690
+ /**
2691
+ * Insert one shape after another in the render queue
2692
+ */
2693
+ insertAfterShape: function (shapeid, shape) {
2694
+ window.alert('insertAfterShape not implemented');
2695
+ },
2696
+
2697
+ /**
2698
+ * Remove a shape from the queue
2699
+ */
2700
+ removeShapeId: function (shapeid) {
2701
+ window.alert('removeShapeId not implemented');
2702
+ },
2703
+
2704
+ /**
2705
+ * Find a shape at the specified x/y co-ordinates
2706
+ */
2707
+ getShapeAt: function (el, x, y) {
2708
+ window.alert('getShapeAt not implemented');
2709
+ },
2710
+
2711
+ /**
2712
+ * Render all queued shapes onto the canvas
2713
+ */
2714
+ render: function () {
2715
+ window.alert('render not implemented');
2716
+ }
2717
+ });
2718
+
2719
+
2720
+ VCanvas_canvas = createClass(VCanvas_base, {
2721
+ init: function (width, height, target, interact) {
2722
+ VCanvas_canvas._super.init.call(this, width, height, target);
2723
+ this.canvas = document.createElement('canvas');
2724
+ if (target[0]) {
2725
+ target = target[0];
2726
+ }
2727
+ this.context = this.canvas.getContext('2d');
2728
+ var devicePixelRatio = window.devicePixelRatio || 1,
2729
+ backingStoreRatio = this.context.webkitBackingStorePixelRatio || this.context.mozBackingStorePixelRatio || this.context.msBackingStorePixelRatio || this.context.oBackingStorePixelRatio || this.context.backingStorePixelRatio || 1,
2730
+ ratio = devicePixelRatio / backingStoreRatio;
2731
+ $.data(target, '_jqs_vcanvas', this);
2732
+ $(this.canvas).css({ display: 'inline-block', width: width, height: height, verticalAlign: 'top' });
2733
+ this._insert(this.canvas, target);
2734
+ this._calculatePixelDims(width, height, this.canvas);
2735
+ this.canvas.width = this.pixelWidth * ratio;
2736
+ this.canvas.height = this.pixelHeight * ratio;
2737
+ this.context.scale(ratio, ratio);
2738
+ this.interact = interact;
2739
+ this.shapes = {};
2740
+ this.shapeseq = [];
2741
+ this.currentTargetShapeId = undefined;
2742
+ $(this.canvas).css({width: this.pixelWidth, height: this.pixelHeight});
2743
+ },
2744
+
2745
+ _getContext: function (lineColor, fillColor, lineWidth) {
2746
+ var context = this.canvas.getContext('2d');
2747
+ if (lineColor !== undefined) {
2748
+ context.strokeStyle = lineColor;
2749
+ }
2750
+ context.lineWidth = lineWidth === undefined ? 1 : lineWidth;
2751
+ if (fillColor !== undefined) {
2752
+ context.fillStyle = fillColor;
2753
+ }
2754
+ return context;
2755
+ },
2756
+
2757
+ reset: function () {
2758
+ var context = this._getContext();
2759
+ context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
2760
+ this.shapes = {};
2761
+ this.shapeseq = [];
2762
+ this.currentTargetShapeId = undefined;
2763
+ },
2764
+
2765
+ _drawShape: function (shapeid, path, lineColor, fillColor, lineWidth) {
2766
+ var context = this._getContext(lineColor, fillColor, lineWidth),
2767
+ i, plen;
2768
+ context.beginPath();
2769
+ context.moveTo(path[0][0] + 0.5, path[0][1] + 0.5);
2770
+ for (i = 1, plen = path.length; i < plen; i++) {
2771
+ context.lineTo(path[i][0] + 0.5, path[i][1] + 0.5); // the 0.5 offset gives us crisp pixel-width lines
2772
+ }
2773
+ if (lineColor !== undefined) {
2774
+ context.stroke();
2775
+ }
2776
+ if (fillColor !== undefined) {
2777
+ context.fill();
2778
+ }
2779
+ if (this.targetX !== undefined && this.targetY !== undefined &&
2780
+ context.isPointInPath(this.targetX, this.targetY)) {
2781
+ this.currentTargetShapeId = shapeid;
2782
+ }
2783
+ },
2784
+
2785
+ _drawCircle: function (shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
2786
+ var context = this._getContext(lineColor, fillColor, lineWidth);
2787
+ context.beginPath();
2788
+ context.arc(x, y, radius, 0, 2 * Math.PI, false);
2789
+ if (this.targetX !== undefined && this.targetY !== undefined &&
2790
+ context.isPointInPath(this.targetX, this.targetY)) {
2791
+ this.currentTargetShapeId = shapeid;
2792
+ }
2793
+ if (lineColor !== undefined) {
2794
+ context.stroke();
2795
+ }
2796
+ if (fillColor !== undefined) {
2797
+ context.fill();
2798
+ }
2799
+ },
2800
+
2801
+ _drawPieSlice: function (shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
2802
+ var context = this._getContext(lineColor, fillColor);
2803
+ context.beginPath();
2804
+ context.moveTo(x, y);
2805
+ context.arc(x, y, radius, startAngle, endAngle, false);
2806
+ context.lineTo(x, y);
2807
+ context.closePath();
2808
+ if (lineColor !== undefined) {
2809
+ context.stroke();
2810
+ }
2811
+ if (fillColor) {
2812
+ context.fill();
2813
+ }
2814
+ if (this.targetX !== undefined && this.targetY !== undefined &&
2815
+ context.isPointInPath(this.targetX, this.targetY)) {
2816
+ this.currentTargetShapeId = shapeid;
2817
+ }
2818
+ },
2819
+
2820
+ _drawRect: function (shapeid, x, y, width, height, lineColor, fillColor) {
2821
+ return this._drawShape(shapeid, [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]], lineColor, fillColor);
2822
+ },
2823
+
2824
+ appendShape: function (shape) {
2825
+ this.shapes[shape.id] = shape;
2826
+ this.shapeseq.push(shape.id);
2827
+ this.lastShapeId = shape.id;
2828
+ return shape.id;
2829
+ },
2830
+
2831
+ replaceWithShape: function (shapeid, shape) {
2832
+ var shapeseq = this.shapeseq,
2833
+ i;
2834
+ this.shapes[shape.id] = shape;
2835
+ for (i = shapeseq.length; i--;) {
2836
+ if (shapeseq[i] == shapeid) {
2837
+ shapeseq[i] = shape.id;
2838
+ }
2839
+ }
2840
+ delete this.shapes[shapeid];
2841
+ },
2842
+
2843
+ replaceWithShapes: function (shapeids, shapes) {
2844
+ var shapeseq = this.shapeseq,
2845
+ shapemap = {},
2846
+ sid, i, first;
2847
+
2848
+ for (i = shapeids.length; i--;) {
2849
+ shapemap[shapeids[i]] = true;
2850
+ }
2851
+ for (i = shapeseq.length; i--;) {
2852
+ sid = shapeseq[i];
2853
+ if (shapemap[sid]) {
2854
+ shapeseq.splice(i, 1);
2855
+ delete this.shapes[sid];
2856
+ first = i;
2857
+ }
2858
+ }
2859
+ for (i = shapes.length; i--;) {
2860
+ shapeseq.splice(first, 0, shapes[i].id);
2861
+ this.shapes[shapes[i].id] = shapes[i];
2862
+ }
2863
+
2864
+ },
2865
+
2866
+ insertAfterShape: function (shapeid, shape) {
2867
+ var shapeseq = this.shapeseq,
2868
+ i;
2869
+ for (i = shapeseq.length; i--;) {
2870
+ if (shapeseq[i] === shapeid) {
2871
+ shapeseq.splice(i + 1, 0, shape.id);
2872
+ this.shapes[shape.id] = shape;
2873
+ return;
2874
+ }
2875
+ }
2876
+ },
2877
+
2878
+ removeShapeId: function (shapeid) {
2879
+ var shapeseq = this.shapeseq,
2880
+ i;
2881
+ for (i = shapeseq.length; i--;) {
2882
+ if (shapeseq[i] === shapeid) {
2883
+ shapeseq.splice(i, 1);
2884
+ break;
2885
+ }
2886
+ }
2887
+ delete this.shapes[shapeid];
2888
+ },
2889
+
2890
+ getShapeAt: function (el, x, y) {
2891
+ this.targetX = x;
2892
+ this.targetY = y;
2893
+ this.render();
2894
+ return this.currentTargetShapeId;
2895
+ },
2896
+
2897
+ render: function () {
2898
+ var shapeseq = this.shapeseq,
2899
+ shapes = this.shapes,
2900
+ shapeCount = shapeseq.length,
2901
+ context = this._getContext(),
2902
+ shapeid, shape, i;
2903
+ context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
2904
+ for (i = 0; i < shapeCount; i++) {
2905
+ shapeid = shapeseq[i];
2906
+ shape = shapes[shapeid];
2907
+ this['_draw' + shape.type].apply(this, shape.args);
2908
+ }
2909
+ if (!this.interact) {
2910
+ // not interactive so no need to keep the shapes array
2911
+ this.shapes = {};
2912
+ this.shapeseq = [];
2913
+ }
2914
+ }
2915
+
2916
+ });
2917
+
2918
+
2919
+ VCanvas_vml = createClass(VCanvas_base, {
2920
+ init: function (width, height, target) {
2921
+ var groupel;
2922
+ VCanvas_vml._super.init.call(this, width, height, target);
2923
+ if (target[0]) {
2924
+ target = target[0];
2925
+ }
2926
+ $.data(target, '_jqs_vcanvas', this);
2927
+ this.canvas = document.createElement('span');
2928
+ $(this.canvas).css({ display: 'inline-block', position: 'relative', overflow: 'hidden', width: width, height: height, margin: '0', padding: '0', verticalAlign: 'top'});
2929
+ this._insert(this.canvas, target);
2930
+ this._calculatePixelDims(width, height, this.canvas);
2931
+ this.canvas.width = this.pixelWidth;
2932
+ this.canvas.height = this.pixelHeight;
2933
+ groupel = '<v:group coordorigin="0 0" coordsize="' + this.pixelWidth + ' ' + this.pixelHeight + '"' +
2934
+ ' style="position:absolute;top:0;left:0;width:' + this.pixelWidth + 'px;height=' + this.pixelHeight + 'px;"></v:group>';
2935
+ this.canvas.insertAdjacentHTML('beforeEnd', groupel);
2936
+ this.group = $(this.canvas).children()[0];
2937
+ this.rendered = false;
2938
+ this.prerender = '';
2939
+ },
2940
+
2941
+ _drawShape: function (shapeid, path, lineColor, fillColor, lineWidth) {
2942
+ var vpath = [],
2943
+ initial, stroke, fill, closed, vel, plen, i;
2944
+ for (i = 0, plen = path.length; i < plen; i++) {
2945
+ vpath[i] = '' + (path[i][0]) + ',' + (path[i][1]);
2946
+ }
2947
+ initial = vpath.splice(0, 1);
2948
+ lineWidth = lineWidth === undefined ? 1 : lineWidth;
2949
+ stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
2950
+ fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
2951
+ closed = vpath[0] === vpath[vpath.length - 1] ? 'x ' : '';
2952
+ vel = '<v:shape coordorigin="0 0" coordsize="' + this.pixelWidth + ' ' + this.pixelHeight + '" ' +
2953
+ ' id="jqsshape' + shapeid + '" ' +
2954
+ stroke +
2955
+ fill +
2956
+ ' style="position:absolute;left:0;top:0;height:' + this.pixelHeight + 'px;width:' + this.pixelWidth + 'px;padding:0;margin:0;" ' +
2957
+ ' path="m ' + initial + ' l ' + vpath.join(', ') + ' ' + closed + 'e">' +
2958
+ ' </v:shape>';
2959
+ return vel;
2960
+ },
2961
+
2962
+ _drawCircle: function (shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
2963
+ var stroke, fill, vel;
2964
+ x -= radius;
2965
+ y -= radius;
2966
+ stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
2967
+ fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
2968
+ vel = '<v:oval ' +
2969
+ ' id="jqsshape' + shapeid + '" ' +
2970
+ stroke +
2971
+ fill +
2972
+ ' style="position:absolute;top:' + y + 'px; left:' + x + 'px; width:' + (radius * 2) + 'px; height:' + (radius * 2) + 'px"></v:oval>';
2973
+ return vel;
2974
+
2975
+ },
2976
+
2977
+ _drawPieSlice: function (shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
2978
+ var vpath, startx, starty, endx, endy, stroke, fill, vel;
2979
+ if (startAngle === endAngle) {
2980
+ return ''; // VML seems to have problem when start angle equals end angle.
2981
+ }
2982
+ if ((endAngle - startAngle) === (2 * Math.PI)) {
2983
+ startAngle = 0.0; // VML seems to have a problem when drawing a full circle that doesn't start 0
2984
+ endAngle = (2 * Math.PI);
2985
+ }
2986
+
2987
+ startx = x + Math.round(Math.cos(startAngle) * radius);
2988
+ starty = y + Math.round(Math.sin(startAngle) * radius);
2989
+ endx = x + Math.round(Math.cos(endAngle) * radius);
2990
+ endy = y + Math.round(Math.sin(endAngle) * radius);
2991
+
2992
+ if (startx === endx && starty === endy) {
2993
+ if ((endAngle - startAngle) < Math.PI) {
2994
+ // Prevent very small slices from being mistaken as a whole pie
2995
+ return '';
2996
+ }
2997
+ // essentially going to be the entire circle, so ignore startAngle
2998
+ startx = endx = x + radius;
2999
+ starty = endy = y;
3000
+ }
3001
+
3002
+ if (startx === endx && starty === endy && (endAngle - startAngle) < Math.PI) {
3003
+ return '';
3004
+ }
3005
+
3006
+ vpath = [x - radius, y - radius, x + radius, y + radius, startx, starty, endx, endy];
3007
+ stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="1px" strokeColor="' + lineColor + '" ';
3008
+ fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
3009
+ vel = '<v:shape coordorigin="0 0" coordsize="' + this.pixelWidth + ' ' + this.pixelHeight + '" ' +
3010
+ ' id="jqsshape' + shapeid + '" ' +
3011
+ stroke +
3012
+ fill +
3013
+ ' style="position:absolute;left:0;top:0;height:' + this.pixelHeight + 'px;width:' + this.pixelWidth + 'px;padding:0;margin:0;" ' +
3014
+ ' path="m ' + x + ',' + y + ' wa ' + vpath.join(', ') + ' x e">' +
3015
+ ' </v:shape>';
3016
+ return vel;
3017
+ },
3018
+
3019
+ _drawRect: function (shapeid, x, y, width, height, lineColor, fillColor) {
3020
+ return this._drawShape(shapeid, [[x, y], [x, y + height], [x + width, y + height], [x + width, y], [x, y]], lineColor, fillColor);
3021
+ },
3022
+
3023
+ reset: function () {
3024
+ this.group.innerHTML = '';
3025
+ },
3026
+
3027
+ appendShape: function (shape) {
3028
+ var vel = this['_draw' + shape.type].apply(this, shape.args);
3029
+ if (this.rendered) {
3030
+ this.group.insertAdjacentHTML('beforeEnd', vel);
3031
+ } else {
3032
+ this.prerender += vel;
3033
+ }
3034
+ this.lastShapeId = shape.id;
3035
+ return shape.id;
3036
+ },
3037
+
3038
+ replaceWithShape: function (shapeid, shape) {
3039
+ var existing = $('#jqsshape' + shapeid),
3040
+ vel = this['_draw' + shape.type].apply(this, shape.args);
3041
+ existing[0].outerHTML = vel;
3042
+ },
3043
+
3044
+ replaceWithShapes: function (shapeids, shapes) {
3045
+ // replace the first shapeid with all the new shapes then toast the remaining old shapes
3046
+ var existing = $('#jqsshape' + shapeids[0]),
3047
+ replace = '',
3048
+ slen = shapes.length,
3049
+ i;
3050
+ for (i = 0; i < slen; i++) {
3051
+ replace += this['_draw' + shapes[i].type].apply(this, shapes[i].args);
3052
+ }
3053
+ existing[0].outerHTML = replace;
3054
+ for (i = 1; i < shapeids.length; i++) {
3055
+ $('#jqsshape' + shapeids[i]).remove();
3056
+ }
3057
+ },
3058
+
3059
+ insertAfterShape: function (shapeid, shape) {
3060
+ var existing = $('#jqsshape' + shapeid),
3061
+ vel = this['_draw' + shape.type].apply(this, shape.args);
3062
+ existing[0].insertAdjacentHTML('afterEnd', vel);
3063
+ },
3064
+
3065
+ removeShapeId: function (shapeid) {
3066
+ var existing = $('#jqsshape' + shapeid);
3067
+ this.group.removeChild(existing[0]);
3068
+ },
3069
+
3070
+ getShapeAt: function (el, x, y) {
3071
+ var shapeid = el.id.substr(8);
3072
+ return shapeid;
3073
+ },
3074
+
3075
+ render: function () {
3076
+ if (!this.rendered) {
3077
+ // batch the intial render into a single repaint
3078
+ this.group.innerHTML = this.prerender;
3079
+ this.rendered = true;
3080
+ }
3081
+ }
3082
+ });
3083
+
3084
+
3085
+ }))}(document, Math));