billboard.js 4.1.4 → 4.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/dist/billboard.css +87 -1
  2. package/dist/billboard.js +11129 -7032
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +20 -20
  5. package/dist/billboard.pkgd.js +22703 -14154
  6. package/dist/billboard.pkgd.min.js +37 -37
  7. package/dist/billboard.react.js +5 -5
  8. package/dist/billboard.react.min.js +2 -2
  9. package/dist/billboard.worker.js +1 -1
  10. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-sparkline.js +21 -4
  13. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  14. package/dist/plugin/billboardjs-plugin-stanford.js +22 -13
  15. package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
  16. package/dist/plugin/billboardjs-plugin-tableview.js +20 -3
  17. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  18. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  19. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1689 -1252
  21. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
  22. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2288 -1012
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6350 -2390
  25. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -18
  26. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1310 -1006
  27. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -10
  28. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1293 -1006
  29. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
  30. package/dist/theme/dark.css +90 -1
  31. package/dist/theme/dark.min.css +2 -2
  32. package/dist/theme/datalab.css +87 -1
  33. package/dist/theme/datalab.min.css +2 -2
  34. package/dist/theme/graph.css +87 -1
  35. package/dist/theme/graph.min.css +2 -2
  36. package/dist/theme/insight.css +87 -1
  37. package/dist/theme/insight.min.css +2 -2
  38. package/dist/theme/modern.css +87 -1
  39. package/dist/theme/modern.min.css +2 -2
  40. package/dist-esm/Chart/Chart.js +5 -5
  41. package/dist-esm/Chart/api/axis.js +2 -3
  42. package/dist-esm/Chart/api/category.js +2 -3
  43. package/dist-esm/Chart/api/chart.js +3 -4
  44. package/dist-esm/Chart/api/color.js +2 -3
  45. package/dist-esm/Chart/api/data.js +3 -4
  46. package/dist-esm/Chart/api/export.js +3 -4
  47. package/dist-esm/Chart/api/flow.js +15 -9
  48. package/dist-esm/Chart/api/focus.js +5 -3
  49. package/dist-esm/Chart/api/grid.js +2 -3
  50. package/dist-esm/Chart/api/group.js +2 -3
  51. package/dist-esm/Chart/api/legend.js +1 -2
  52. package/dist-esm/Chart/api/load.js +3 -4
  53. package/dist-esm/Chart/api/regions.js +3 -4
  54. package/dist-esm/Chart/api/selection.js +3 -4
  55. package/dist-esm/Chart/api/show.js +2 -3
  56. package/dist-esm/Chart/api/stubs.js +3 -4
  57. package/dist-esm/Chart/api/subchart.js +4 -5
  58. package/dist-esm/Chart/api/tooltip.js +28 -9
  59. package/dist-esm/Chart/api/x.js +2 -3
  60. package/dist-esm/Chart/api/zoom.js +6 -7
  61. package/dist-esm/ChartInternal/Axis/Axis.js +5 -6
  62. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +26 -17
  63. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +40 -12
  64. package/dist-esm/ChartInternal/ChartInternal.js +39 -24
  65. package/dist-esm/ChartInternal/data/convert.helper.js +2 -3
  66. package/dist-esm/ChartInternal/data/convert.js +3 -4
  67. package/dist-esm/ChartInternal/data/data.js +18 -11
  68. package/dist-esm/ChartInternal/data/load.js +4 -5
  69. package/dist-esm/ChartInternal/interactions/drag.js +3 -4
  70. package/dist-esm/ChartInternal/interactions/eventrect.js +4 -5
  71. package/dist-esm/ChartInternal/interactions/flow.js +25 -19
  72. package/dist-esm/ChartInternal/interactions/interaction.js +14 -13
  73. package/dist-esm/ChartInternal/interactions/subchart.js +5 -6
  74. package/dist-esm/ChartInternal/interactions/zoom.js +4 -5
  75. package/dist-esm/ChartInternal/internals/category.js +2 -3
  76. package/dist-esm/ChartInternal/internals/class.js +5 -5
  77. package/dist-esm/ChartInternal/internals/clip.js +2 -3
  78. package/dist-esm/ChartInternal/internals/color.js +4 -5
  79. package/dist-esm/ChartInternal/internals/domain.js +7 -7
  80. package/dist-esm/ChartInternal/internals/format.js +3 -4
  81. package/dist-esm/ChartInternal/internals/grid.js +4 -5
  82. package/dist-esm/ChartInternal/internals/legend.js +7 -7
  83. package/dist-esm/ChartInternal/internals/redraw.js +13 -13
  84. package/dist-esm/ChartInternal/internals/region.js +4 -5
  85. package/dist-esm/ChartInternal/internals/scale.js +2 -3
  86. package/dist-esm/ChartInternal/internals/selection.js +3 -4
  87. package/dist-esm/ChartInternal/internals/size.axis.js +2 -3
  88. package/dist-esm/ChartInternal/internals/size.js +8 -9
  89. package/dist-esm/ChartInternal/internals/style.js +4 -5
  90. package/dist-esm/ChartInternal/internals/subchart.util.js +2 -3
  91. package/dist-esm/ChartInternal/internals/text.arc.js +3 -4
  92. package/dist-esm/ChartInternal/internals/text.js +22 -23
  93. package/dist-esm/ChartInternal/internals/text.util.js +4 -5
  94. package/dist-esm/ChartInternal/internals/title.js +4 -5
  95. package/dist-esm/ChartInternal/internals/tooltip.js +42 -23
  96. package/dist-esm/ChartInternal/internals/transform.js +5 -6
  97. package/dist-esm/ChartInternal/internals/type.js +78 -11
  98. package/dist-esm/ChartInternal/shape/arc.js +5 -6
  99. package/dist-esm/ChartInternal/shape/area.js +4 -5
  100. package/dist-esm/ChartInternal/shape/bar.js +5 -6
  101. package/dist-esm/ChartInternal/shape/boxplot.js +111 -0
  102. package/dist-esm/ChartInternal/shape/bubble.js +2 -3
  103. package/dist-esm/ChartInternal/shape/bullet.js +213 -0
  104. package/dist-esm/ChartInternal/shape/candlestick.js +5 -6
  105. package/dist-esm/ChartInternal/shape/core/barRadius.js +2 -3
  106. package/dist-esm/ChartInternal/shape/core/boxplot.js +192 -0
  107. package/dist-esm/ChartInternal/shape/core/bubble.js +4 -5
  108. package/dist-esm/ChartInternal/shape/core/bullet.js +528 -0
  109. package/dist-esm/ChartInternal/shape/core/candlestick.js +2 -3
  110. package/dist-esm/ChartInternal/shape/core/dataRegion.js +2 -3
  111. package/dist-esm/ChartInternal/shape/core/geometry.js +2 -3
  112. package/dist-esm/ChartInternal/shape/core/heatmap.js +453 -0
  113. package/dist-esm/ChartInternal/shape/core/path.js +2 -3
  114. package/dist-esm/ChartInternal/shape/core/point.js +2 -3
  115. package/dist-esm/ChartInternal/shape/core/sankey.js +576 -0
  116. package/dist-esm/ChartInternal/shape/core/treemap.js +2 -3
  117. package/dist-esm/ChartInternal/shape/funnel.js +45 -6
  118. package/dist-esm/ChartInternal/shape/gauge.js +3 -4
  119. package/dist-esm/ChartInternal/shape/heatmap.js +144 -0
  120. package/dist-esm/ChartInternal/shape/line.js +7 -8
  121. package/dist-esm/ChartInternal/shape/point.js +9 -9
  122. package/dist-esm/ChartInternal/shape/polar.js +3 -4
  123. package/dist-esm/ChartInternal/shape/radar.js +19 -7
  124. package/dist-esm/ChartInternal/shape/sankey.js +154 -0
  125. package/dist-esm/ChartInternal/shape/shape.js +15 -11
  126. package/dist-esm/ChartInternal/shape/treemap.js +8 -5
  127. package/dist-esm/canvas/CanvasAxisRenderer.js +28 -328
  128. package/dist-esm/canvas/CanvasEngine.js +2 -3
  129. package/dist-esm/canvas/CanvasPainter.js +2 -3
  130. package/dist-esm/canvas/CanvasRenderer.js +38 -408
  131. package/dist-esm/canvas/CanvasTheme.js +28 -8
  132. package/dist-esm/canvas/HitDetector.js +20 -24
  133. package/dist-esm/canvas/axisTicks.js +5 -6
  134. package/dist-esm/canvas/boxplot.js +201 -0
  135. package/dist-esm/canvas/bullet.js +212 -0
  136. package/dist-esm/canvas/classes.js +2 -3
  137. package/dist-esm/canvas/color.js +2 -3
  138. package/dist-esm/canvas/flow.js +190 -0
  139. package/dist-esm/canvas/geometry.js +2 -3
  140. package/dist-esm/canvas/grid.js +206 -0
  141. package/dist-esm/canvas/heatmap.js +141 -0
  142. package/dist-esm/canvas/labels.js +3 -4
  143. package/dist-esm/canvas/pointPattern.js +2 -3
  144. package/dist-esm/canvas/sankey.js +137 -0
  145. package/dist-esm/canvas/selection.js +473 -0
  146. package/dist-esm/canvas/subchart.js +814 -0
  147. package/dist-esm/canvas/treemap.js +100 -0
  148. package/dist-esm/canvas/util.js +2 -3
  149. package/dist-esm/config/Options/Options.js +3 -4
  150. package/dist-esm/config/Options/axis/axis.js +2 -3
  151. package/dist-esm/config/Options/axis/x.js +2 -3
  152. package/dist-esm/config/Options/axis/y.js +2 -3
  153. package/dist-esm/config/Options/axis/y2.js +14 -3
  154. package/dist-esm/config/Options/common/boost.js +2 -3
  155. package/dist-esm/config/Options/common/color.js +2 -3
  156. package/dist-esm/config/Options/common/grid.js +2 -3
  157. package/dist-esm/config/Options/common/legend.js +2 -3
  158. package/dist-esm/config/Options/common/main.js +2 -3
  159. package/dist-esm/config/Options/common/point.js +2 -3
  160. package/dist-esm/config/Options/common/title.js +2 -3
  161. package/dist-esm/config/Options/common/tooltip.js +2 -3
  162. package/dist-esm/config/Options/data/axis.js +2 -3
  163. package/dist-esm/config/Options/data/data.js +49 -4
  164. package/dist-esm/config/Options/data/selection.js +2 -3
  165. package/dist-esm/config/Options/interaction/interaction.js +2 -3
  166. package/dist-esm/config/Options/interaction/subchart.js +6 -3
  167. package/dist-esm/config/Options/interaction/zoom.js +2 -3
  168. package/dist-esm/config/Options/shape/arc.js +2 -3
  169. package/dist-esm/config/Options/shape/area.js +2 -3
  170. package/dist-esm/config/Options/shape/bar.js +2 -3
  171. package/dist-esm/config/Options/shape/boxplot.js +106 -0
  172. package/dist-esm/config/Options/shape/bubble.js +2 -3
  173. package/dist-esm/config/Options/shape/bullet.js +177 -0
  174. package/dist-esm/config/Options/shape/candlestick.js +2 -3
  175. package/dist-esm/config/Options/shape/donut.js +2 -3
  176. package/dist-esm/config/Options/shape/funnel.js +2 -3
  177. package/dist-esm/config/Options/shape/gauge.js +2 -3
  178. package/dist-esm/config/Options/shape/heatmap.js +137 -0
  179. package/dist-esm/config/Options/shape/line.js +2 -3
  180. package/dist-esm/config/Options/shape/pie.js +2 -3
  181. package/dist-esm/config/Options/shape/polar.js +2 -3
  182. package/dist-esm/config/Options/shape/radar.js +2 -3
  183. package/dist-esm/config/Options/shape/sankey.js +116 -0
  184. package/dist-esm/config/Options/shape/scatter.js +2 -3
  185. package/dist-esm/config/Options/shape/spline.js +2 -3
  186. package/dist-esm/config/Options/shape/treemap.js +2 -3
  187. package/dist-esm/config/Store/Element.js +2 -3
  188. package/dist-esm/config/Store/State.js +4 -4
  189. package/dist-esm/config/Store/Store.js +2 -3
  190. package/dist-esm/config/classes.js +2 -4
  191. package/dist-esm/config/config.js +2 -3
  192. package/dist-esm/config/const.js +31 -23
  193. package/dist-esm/config/resolver/axis.core.js +4 -5
  194. package/dist-esm/config/resolver/axis.js +2 -3
  195. package/dist-esm/config/resolver/canvas.js +113 -900
  196. package/dist-esm/config/resolver/canvasBoxplot.js +49 -0
  197. package/dist-esm/config/resolver/canvasBullet.js +29 -0
  198. package/dist-esm/config/resolver/canvasFlow.js +28 -0
  199. package/dist-esm/config/resolver/canvasGrid.js +27 -0
  200. package/dist-esm/config/resolver/canvasHeatmap.js +31 -0
  201. package/dist-esm/config/resolver/canvasSankey.js +31 -0
  202. package/dist-esm/config/resolver/canvasSelection.js +30 -0
  203. package/dist-esm/config/resolver/canvasShape.js +13 -12
  204. package/dist-esm/config/resolver/canvasSubchart.js +30 -0
  205. package/dist-esm/config/resolver/canvasType.js +48 -0
  206. package/dist-esm/config/resolver/category.js +3 -4
  207. package/dist-esm/config/resolver/customType.js +58 -0
  208. package/dist-esm/config/resolver/export.js +3 -4
  209. package/dist-esm/config/resolver/flow.js +5 -6
  210. package/dist-esm/config/resolver/grid.js +6 -7
  211. package/dist-esm/config/resolver/interaction/selection.js +6 -7
  212. package/dist-esm/config/resolver/interaction/subchart.js +6 -7
  213. package/dist-esm/config/resolver/interaction/zoom.js +6 -7
  214. package/dist-esm/config/resolver/regions.js +5 -6
  215. package/dist-esm/config/resolver/shape/arc.helpers.js +5 -6
  216. package/dist-esm/config/resolver/shape/area.js +3 -4
  217. package/dist-esm/config/resolver/shape/axis.helpers.js +2 -3
  218. package/dist-esm/config/resolver/shape/bar.js +5 -6
  219. package/dist-esm/config/resolver/shape/boxplot.js +30 -0
  220. package/dist-esm/config/resolver/shape/bubble.js +5 -6
  221. package/dist-esm/config/resolver/shape/bullet.js +23 -0
  222. package/dist-esm/config/resolver/shape/candlestick.js +5 -6
  223. package/dist-esm/config/resolver/shape/donut.js +2 -3
  224. package/dist-esm/config/resolver/shape/funnel.js +7 -6
  225. package/dist-esm/config/resolver/shape/gauge.js +4 -5
  226. package/dist-esm/config/resolver/shape/heatmap.js +23 -0
  227. package/dist-esm/config/resolver/shape/line.js +2 -3
  228. package/dist-esm/config/resolver/shape/pie.js +3 -4
  229. package/dist-esm/config/resolver/shape/polar.js +4 -5
  230. package/dist-esm/config/resolver/shape/radar.js +5 -6
  231. package/dist-esm/config/resolver/shape/sankey.js +23 -0
  232. package/dist-esm/config/resolver/shape/scatter.js +4 -5
  233. package/dist-esm/config/resolver/shape/treemap.js +4 -5
  234. package/dist-esm/core.js +5 -6
  235. package/dist-esm/index.canvas.js +13 -9
  236. package/dist-esm/index.esm.js +6 -2
  237. package/dist-esm/module/Cache.js +2 -3
  238. package/dist-esm/module/browser.js +2 -3
  239. package/dist-esm/module/dsv.js +2 -3
  240. package/dist-esm/module/error.js +23 -16
  241. package/dist-esm/module/generator.js +3 -4
  242. package/dist-esm/module/sanitize.js +2 -3
  243. package/dist-esm/module/util/brush.js +2 -3
  244. package/dist-esm/module/util/dom.js +3 -4
  245. package/dist-esm/module/util/object.js +13 -6
  246. package/dist-esm/module/util/type-checks.js +2 -3
  247. package/dist-esm/module/worker.js +2 -3
  248. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +6 -10
  249. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -18
  250. package/dist-esm/plugin/billboardjs-plugin-stanford.js +17 -45
  251. package/dist-esm/plugin/billboardjs-plugin-tableview.js +10 -18
  252. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +9 -16
  253. package/dist-esm/react/index.js +2 -3
  254. package/package.json +44 -44
  255. package/src/Chart/Chart.ts +1 -0
  256. package/src/Chart/api/chart.ts +2 -1
  257. package/src/Chart/api/flow.ts +20 -7
  258. package/src/Chart/api/focus.ts +3 -0
  259. package/src/Chart/api/subchart.ts +1 -1
  260. package/src/Chart/api/tooltip.ts +54 -15
  261. package/src/ChartInternal/Axis/AxisRenderer.ts +29 -20
  262. package/src/ChartInternal/Axis/AxisRendererHelper.ts +45 -9
  263. package/src/ChartInternal/ChartInternal.ts +46 -19
  264. package/src/ChartInternal/data/IData.ts +13 -0
  265. package/src/ChartInternal/data/data.ts +26 -5
  266. package/src/ChartInternal/data/load.ts +2 -2
  267. package/src/ChartInternal/interactions/flow.ts +50 -19
  268. package/src/ChartInternal/interactions/interaction.ts +15 -11
  269. package/src/ChartInternal/internals/class.ts +3 -2
  270. package/src/ChartInternal/internals/domain.ts +4 -2
  271. package/src/ChartInternal/internals/format.ts +3 -1
  272. package/src/ChartInternal/internals/legend.ts +2 -1
  273. package/src/ChartInternal/internals/redraw.ts +18 -12
  274. package/src/ChartInternal/internals/size.ts +5 -3
  275. package/src/ChartInternal/internals/text.ts +24 -28
  276. package/src/ChartInternal/internals/tooltip.ts +59 -20
  277. package/src/ChartInternal/internals/transform.ts +2 -2
  278. package/src/ChartInternal/internals/type.ts +101 -9
  279. package/src/ChartInternal/shape/boxplot.ts +172 -0
  280. package/src/ChartInternal/shape/bullet.ts +323 -0
  281. package/src/ChartInternal/shape/core/boxplot.ts +241 -0
  282. package/src/ChartInternal/shape/core/bullet.ts +734 -0
  283. package/src/ChartInternal/shape/core/heatmap.ts +665 -0
  284. package/src/ChartInternal/shape/core/sankey.ts +782 -0
  285. package/src/ChartInternal/shape/funnel.ts +73 -2
  286. package/src/ChartInternal/shape/heatmap.ts +236 -0
  287. package/src/ChartInternal/shape/point.ts +6 -3
  288. package/src/ChartInternal/shape/radar.ts +30 -1
  289. package/src/ChartInternal/shape/sankey.ts +242 -0
  290. package/src/ChartInternal/shape/shape.ts +16 -4
  291. package/src/ChartInternal/shape/treemap.ts +10 -0
  292. package/src/Plugin/stanford/index.ts +1 -28
  293. package/src/canvas/CanvasAxisRenderer.ts +54 -596
  294. package/src/canvas/CanvasRenderer.ts +68 -640
  295. package/src/canvas/CanvasTheme.ts +92 -6
  296. package/src/canvas/HitDetector.ts +30 -28
  297. package/src/canvas/boxplot.ts +230 -0
  298. package/src/canvas/bullet.ts +269 -0
  299. package/src/canvas/flow.ts +237 -0
  300. package/src/canvas/grid.ts +359 -0
  301. package/src/canvas/heatmap.ts +147 -0
  302. package/src/canvas/labels.ts +3 -1
  303. package/src/canvas/sankey.ts +151 -0
  304. package/src/canvas/selection.ts +626 -0
  305. package/src/canvas/subchart.ts +1292 -0
  306. package/src/canvas/treemap.ts +142 -0
  307. package/src/config/Options/axis/y2.ts +13 -0
  308. package/src/config/Options/data/data.ts +47 -1
  309. package/src/config/Options/interaction/subchart.ts +4 -0
  310. package/src/config/Options/shape/boxplot.ts +95 -0
  311. package/src/config/Options/shape/bullet.ts +170 -0
  312. package/src/config/Options/shape/heatmap.ts +125 -0
  313. package/src/config/Options/shape/sankey.ts +108 -0
  314. package/src/config/Store/State.ts +2 -1
  315. package/src/config/classes.ts +0 -1
  316. package/src/config/const.ts +30 -21
  317. package/src/config/resolver/canvas.ts +147 -1293
  318. package/src/config/resolver/canvasBoxplot.ts +42 -0
  319. package/src/config/resolver/canvasBullet.ts +20 -0
  320. package/src/config/resolver/canvasFlow.ts +18 -0
  321. package/src/config/resolver/canvasGrid.ts +17 -0
  322. package/src/config/resolver/canvasHeatmap.ts +23 -0
  323. package/src/config/resolver/canvasSankey.ts +23 -0
  324. package/src/config/resolver/canvasSelection.ts +20 -0
  325. package/src/config/resolver/canvasShape.ts +6 -1
  326. package/src/config/resolver/canvasSubchart.ts +20 -0
  327. package/src/config/resolver/canvasType.ts +51 -0
  328. package/src/config/resolver/customType.ts +69 -0
  329. package/src/config/resolver/shape/boxplot.ts +31 -0
  330. package/src/config/resolver/shape/bullet.ts +18 -0
  331. package/src/config/resolver/shape/funnel.ts +8 -2
  332. package/src/config/resolver/shape/heatmap.ts +18 -0
  333. package/src/config/resolver/shape/index.ts +4 -0
  334. package/src/config/resolver/shape/sankey.ts +18 -0
  335. package/src/index.canvas.ts +9 -3
  336. package/src/index.esm.ts +4 -0
  337. package/src/index.ts +34 -0
  338. package/src/module/error.ts +32 -18
  339. package/src/module/util/object.ts +26 -1
  340. package/src/scss/billboard.scss +106 -0
  341. package/src/scss/theme/dark.scss +110 -0
  342. package/src/scss/theme/datalab.scss +106 -0
  343. package/src/scss/theme/graph.scss +106 -0
  344. package/src/scss/theme/insight.scss +106 -0
  345. package/src/scss/theme/modern.scss +106 -0
  346. package/types/bb.d.ts +4 -0
  347. package/types/canvas.d.ts +3 -0
  348. package/types/chart.d.ts +5 -0
  349. package/types/index.d.ts +4 -0
  350. package/types/options.d.ts +13 -1
  351. package/types/options.shape.d.ts +431 -0
  352. package/types/types.d.ts +4 -0
@@ -0,0 +1,453 @@
1
+ /*!
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ *
5
+ * billboard.js, JavaScript chart library
6
+ * https://naver.github.io/billboard.js/
7
+ *
8
+ * @version 4.2.0-next.1
9
+ */
10
+ import { isFunction } from "../../../module/util/type-checks.js";
11
+ import { scaleLinear } from "d3-scale";
12
+ import { interpolateRgb } from "d3-interpolate";
13
+ // src/ChartInternal/shape/core/heatmap.ts
14
+ /**
15
+ * Copyright (c) 2017 ~ present NAVER Corp.
16
+ * billboard.js project is licensed under the MIT license
17
+ */
18
+ const $HEATMAP = {
19
+ chartHeatmap: "bb-chart-heatmap",
20
+ heatmapRows: "bb-heatmap-rows",
21
+ heatmapRow: "bb-heatmap-row",
22
+ heatmapCell: "bb-heatmap-cell",
23
+ heatmapLabel: "bb-heatmap-label",
24
+ heatmapNames: "bb-heatmap-names",
25
+ heatmapAxis: "bb-heatmap-axis",
26
+ heatmapColorbar: "bb-heatmap-colorbar"
27
+ };
28
+ const AXIS_X_SIZE = 18;
29
+ const AXIS_GAP = 6;
30
+ const BAR_WIDTH = 12;
31
+ const BAR_GAP = 10;
32
+ const BAR_LABEL = 16;
33
+ const LINE_HEIGHT = 11;
34
+ const own = (obj, key) => obj && Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : void 0;
35
+ const isValue = (value) => value !== null && value !== void 0 && value !== "" && Number.isFinite(Number(value));
36
+ /**
37
+ * Get the area the heatmap is drawn in, in chart coordinates.
38
+ * @returns {object} Area
39
+ * @private
40
+ */
41
+ function _getArea() {
42
+ const $$ = this;
43
+ const { config, state: { current: { width, height }, isCanvasMode, isLegendRight } } = $$;
44
+ const padding = $$.getCurrentPadding();
45
+ const legendHeight = config.legend_show && config.legend_position === "bottom" ? (isCanvasMode ? 0 : $$.getLegendHeight()) + 10 : 0;
46
+ const legendRight = config.legend_show && isLegendRight ? $$.getLegendWidth() + (config.padding?.mode === "fit" ? 6 : 20) : 0;
47
+ const surfaceHeight = isCanvasMode ? $$.getCanvasSurfaceHeight() : height;
48
+ const areaHeight = Math.max(0, surfaceHeight - padding.top - padding.bottom - legendHeight);
49
+ const domLegend = isCanvasMode && legendHeight ? $$.getCanvasBottomLegendHeight?.() || 0 : 0;
50
+ return {
51
+ left: padding.left,
52
+ top: padding.top,
53
+ width: Math.max(0, width - padding.left - padding.right - legendRight),
54
+ height: areaHeight,
55
+ chrome: padding.top + padding.bottom + legendHeight + domLegend
56
+ };
57
+ }
58
+ /**
59
+ * Get the width of the widest text, drawn with the style of the axis.
60
+ * @param {Array} texts Texts
61
+ * @returns {number} Width in px
62
+ * @private
63
+ */
64
+ function _getTextWidth(texts) {
65
+ const $$ = this;
66
+ const { cache, state: { isCanvasMode }, $el } = $$;
67
+ const key = `heatmap-text-${isCanvasMode}-${texts.join("\0")}`;
68
+ let width = cache.get(key) || 0;
69
+ if (!width && isCanvasMode && $$.canvasRenderer) {
70
+ const { ctx } = $$.canvasRenderer;
71
+ ctx.save();
72
+ ctx.font = $$.canvasTheme.style.heatmap.axisFont;
73
+ width = texts.reduce((w, v) => Math.max(w, ctx.measureText(v).width), 0);
74
+ ctx.restore();
75
+ } else if (!width && !isCanvasMode && $el.heatmap) {
76
+ const text = $el.heatmap.append("text").attr("class", $HEATMAP.heatmapAxis).style("visibility", "hidden");
77
+ texts.forEach((v) => {
78
+ width = Math.max(width, text.text(v).node().getComputedTextLength?.() || 0);
79
+ });
80
+ text.remove();
81
+ }
82
+ if (width) cache.add(key, width);
83
+ else width = texts.reduce((n, v) => Math.max(n, v.length), 0) * 6.5;
84
+ return Math.ceil(width);
85
+ }
86
+ /**
87
+ * Get the color function of the values: the colors of heatmap.color.range spread on the domain.
88
+ * @param {Array} domain Min and max value
89
+ * @returns {function} Color getter
90
+ * @private
91
+ */
92
+ function _getColorScale(domain) {
93
+ const ranges = this.config.heatmap_color_ranges;
94
+ if (ranges?.length) return (value) => ranges.find((r) => value >= (r.from ?? -1e400) && value <= (r.to ?? 1e400))?.color;
95
+ const range = this.config.heatmap_color_range;
96
+ const [min, max] = domain;
97
+ const last = range.length - 1;
98
+ if (last < 1) return () => range[0];
99
+ return scaleLinear().domain(range.map((_, i) => min + (max - min) * i / last)).range(range).interpolate(interpolateRgb).clamp(true);
100
+ }
101
+ /**
102
+ * Get the text color to read on the color: black on a light one, white on a dark one.
103
+ * @param {string} color Color in the rgb() or the hex form
104
+ * @returns {string} Text color
105
+ * @private
106
+ */
107
+ function _getContrastColor(color) {
108
+ const m = /^rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(color);
109
+ let rgb = [
110
+ 0,
111
+ 0,
112
+ 0
113
+ ];
114
+ if (m) rgb = [
115
+ +m[1],
116
+ +m[2],
117
+ +m[3]
118
+ ];
119
+ else if (/^#[0-9a-f]{6}$/i.test(color)) rgb = [
120
+ 1,
121
+ 3,
122
+ 5
123
+ ].map((i) => parseInt(color.slice(i, i + 2), 16));
124
+ else if (/^#[0-9a-f]{3}$/i.test(color)) rgb = [
125
+ 1,
126
+ 2,
127
+ 3
128
+ ].map((i) => parseInt(color[i] + color[i], 16));
129
+ return (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1e3 > 140 ? "#000" : "#fff";
130
+ }
131
+ /**
132
+ * Get the names to draw along an axis: every name that fits, or every n-th name when they don't.
133
+ * @param {Array} names Names
134
+ * @param {number} step Size of a cell along the axis
135
+ * @param {number} size Size of the widest name along the axis
136
+ * @param {number} [gap=4] The space kept between two names
137
+ * @returns {Array} The names with their index
138
+ * @private
139
+ */
140
+ function _getNames(names, step, size, gap = 4) {
141
+ const skip = Math.max(1, Math.ceil((size + gap) / (step || 1)));
142
+ return names.map((v, i) => [v, i]).filter(([, i]) => i % skip === 0);
143
+ }
144
+ /**
145
+ * How the heatmap differs from the other types for the shared code.
146
+ * It asks these through `getCustomTypeHooks()` (they are registered with the type name).
147
+ * @private
148
+ */
149
+ const customTypeHooks = {
150
+ ownLegendLayout: true,
151
+ currentHeight($$) {
152
+ if (!($$.config.heatmap_cell_ratio > 0) || !$$.data?.targets?.length) return;
153
+ const { height } = $$.getHeatmapLayout(true);
154
+ return Number.isFinite(height) ? Math.ceil(height) : void 0;
155
+ },
156
+ namedData: true,
157
+ labelData() {
158
+ return [];
159
+ },
160
+ legendColor($$, data) {
161
+ const values = data.values.filter((v) => isValue(v.value));
162
+ return values.length ? $$.getHeatmapScale().scale(values.reduce((sum, v) => sum + Number(v.value), 0) / values.length) ?? $$.config.heatmap_color_none ?? void 0 : void 0;
163
+ },
164
+ tooltipColor($$, row) {
165
+ return isValue(row.value) ? $$.getHeatmapScale().scale(Number(row.value)) ?? $$.config.heatmap_color_none ?? void 0 : void 0;
166
+ },
167
+ tooltipTarget($$, args) {
168
+ const { cells } = $$.getHeatmapLayout();
169
+ const id = args.data?.id;
170
+ const index = args.index ?? args.data?.index;
171
+ const x = args.x ?? args.data?.x;
172
+ const cell = cells.find((d) => (id === void 0 || d.id === id) && (index !== void 0 ? d.index === index : x !== void 0 ? d.x === String(x) : true) && d.value !== null);
173
+ return {
174
+ data: cell ? [$$.getHeatmapCellData(cell)] : [],
175
+ point: cell && [(cell.x0 + cell.x1) / 2, (cell.y0 + cell.y1) / 2]
176
+ };
177
+ }
178
+ };
179
+ const invalid = /* @__PURE__ */ new WeakSet();
180
+ const fitting = /* @__PURE__ */ new WeakMap();
181
+ var heatmap_default = {
182
+ /**
183
+ * Fit the height of the chart (heatmap.cell.ratio) after a draw.
184
+ * The first height is made before the legend and the other parts are there to measure: it is fit
185
+ * again once they are, as the resize of the window does. At most 3 times for a width.
186
+ * @private
187
+ */
188
+ fitHeatmapHeight() {
189
+ const $$ = this;
190
+ const { width, height } = $$.state.current;
191
+ const fit = customTypeHooks.currentHeight($$);
192
+ let state = fitting.get($$);
193
+ if (!state || state.width !== width) fitting.set($$, state = {
194
+ width,
195
+ count: 0
196
+ });
197
+ if (fit && Math.abs(fit - height) > 1 && state.count++ < 3) $$.resizeFunction();
198
+ },
199
+ /**
200
+ * Whether the data belongs to the heatmap type.
201
+ * @param {object} d Data object
202
+ * @returns {boolean}
203
+ * @private
204
+ */
205
+ isHeatmapType(d) {
206
+ return this.isTypeOf(d, "heatmap");
207
+ },
208
+ /**
209
+ * Get the layout of the cells, the names and the color bar, in chart coordinates.
210
+ * Shared by the SVG and the canvas renderer.
211
+ * @param {boolean} [fit=false] Set true to lay out the cells without the height limit, to get the height they need
212
+ * @returns {object} Heatmap layout
213
+ * @private
214
+ */
215
+ getHeatmapLayout(fit = false) {
216
+ const $$ = this;
217
+ const { config } = $$;
218
+ const targets = $$.data.targets.filter($$.isHeatmapType.bind($$));
219
+ const area = _getArea.call($$);
220
+ fit && (area.height = 1e400);
221
+ const columns = targets.reduce((a, t) => t.values.length > a.length ? t.values : a, []).map((v) => String(v.x));
222
+ const { domain, scale } = $$.getHeatmapScale();
223
+ const shown = targets.filter((t) => $$.isTargetToShow(t.id));
224
+ const rows = shown.map((t) => t.id);
225
+ const names = shown.map((t) => String(own(config.data_names, t.id) ?? t.id));
226
+ const showX = config.heatmap_axis_x_show && columns.length > 0;
227
+ const showY = config.heatmap_axis_y_show && rows.length > 0;
228
+ const axisYWidth = showY ? _getTextWidth.call($$, names) + AXIS_GAP : 0;
229
+ const axisXHeight = showX ? AXIS_X_SIZE : 0;
230
+ const onTop = config.heatmap_axis_x_position === "top";
231
+ const format = config.heatmap_colorbar_format;
232
+ const fmt = (v) => v === void 0 ? "" : String(isFunction(format) ? format.call($$.api, v) : v);
233
+ const ranges = config.heatmap_color_ranges || [];
234
+ let barLabels = [];
235
+ if (config.heatmap_colorbar_show) barLabels = ranges.length ? ranges.map((r, i) => ({
236
+ text: r.name ?? (r.from === void 0 ? `≤ ${fmt(r.to)}` : r.to === void 0 ? `≥ ${fmt(r.from)}` : `${fmt(r.from)} - ${fmt(r.to)}`),
237
+ pos: (i + .5) / ranges.length,
238
+ edge: false
239
+ })) : domain.map((v, i) => ({
240
+ text: fmt(v),
241
+ pos: i,
242
+ edge: true
243
+ }));
244
+ const barPosition = config.heatmap_colorbar_position;
245
+ const isBarSide = barPosition !== "top" && barPosition !== "bottom";
246
+ const hasBar = barLabels.length > 0;
247
+ const barSpace = hasBar && isBarSide ? 26 + _getTextWidth.call($$, barLabels.map((d) => d.text)) : 0;
248
+ const barLine = hasBar && !isBarSide ? 38 : 0;
249
+ const barOnTop = barPosition === "top";
250
+ const plot = {
251
+ left: area.left + axisYWidth,
252
+ top: area.top + (onTop ? axisXHeight : 0) + (barOnTop ? barLine : 0),
253
+ width: Math.max(0, area.width - axisYWidth - barSpace),
254
+ height: Math.max(0, area.height - axisXHeight - barLine)
255
+ };
256
+ let cw = columns.length ? plot.width / columns.length : 0;
257
+ let ch = rows.length ? plot.height / rows.length : 0;
258
+ const ratio = config.heatmap_cell_ratio;
259
+ if (ratio > 0 && cw && ch) {
260
+ cw = Math.min(cw, ch * ratio);
261
+ ch = cw / ratio;
262
+ plot.width = cw * columns.length;
263
+ plot.height = ch * rows.length;
264
+ }
265
+ const pad = config.heatmap_cell_padding / 2;
266
+ const none = config.heatmap_color_none;
267
+ const cells = [];
268
+ shown.forEach((t, row) => {
269
+ t.values.forEach((v, index) => {
270
+ const hasValue = isValue(v.value);
271
+ const color = hasValue ? scale(Number(v.value)) ?? none : none;
272
+ if (!color) return;
273
+ cells.push({
274
+ id: t.id,
275
+ name: names[row],
276
+ x: columns[index],
277
+ index,
278
+ row,
279
+ value: hasValue ? Number(v.value) : null,
280
+ color,
281
+ x0: plot.left + index * cw + pad,
282
+ y0: plot.top + row * ch + pad,
283
+ x1: plot.left + (index + 1) * cw - pad,
284
+ y1: plot.top + (row + 1) * ch - pad
285
+ });
286
+ });
287
+ });
288
+ const axisX = showX ? _getNames(columns, cw, _getTextWidth.call($$, columns)).map(([text, i]) => ({
289
+ text,
290
+ x: plot.left + (i + .5) * cw,
291
+ y: onTop ? plot.top - AXIS_GAP : plot.top + plot.height + AXIS_GAP,
292
+ align: "center",
293
+ baseline: onTop ? "bottom" : "top"
294
+ })) : [];
295
+ const axisY = showY ? _getNames(names, ch, LINE_HEIGHT, 0).map(([text, i]) => ({
296
+ text,
297
+ x: plot.left - AXIS_GAP,
298
+ y: plot.top + (i + .5) * ch,
299
+ align: "right",
300
+ baseline: "middle"
301
+ })) : [];
302
+ let colorbar = null;
303
+ if (hasBar) {
304
+ const colors = ranges.length ? ranges.map((r) => r.color) : config.heatmap_color_range;
305
+ const last = colors.length - 1;
306
+ const stops = [];
307
+ colors.forEach((c, i) => {
308
+ if (ranges.length) stops.push([i / colors.length, c], [(i + 1) / colors.length, c]);
309
+ else stops.push([last ? i / last : 0, c]);
310
+ });
311
+ if (isBarSide) {
312
+ const x = plot.left + plot.width + BAR_GAP;
313
+ colorbar = {
314
+ horizontal: false,
315
+ x,
316
+ y: plot.top,
317
+ width: BAR_WIDTH,
318
+ height: plot.height,
319
+ stops: stops.map(([o, c]) => [1 - o, c]).reverse(),
320
+ labels: barLabels.map((d) => ({
321
+ text: d.text,
322
+ x: x + BAR_WIDTH + 4,
323
+ y: plot.top + plot.height * (1 - d.pos),
324
+ align: "left",
325
+ baseline: d.edge ? d.pos ? "top" : "bottom" : "middle"
326
+ }))
327
+ };
328
+ } else {
329
+ const y = barOnTop ? area.top + BAR_LABEL : plot.top + plot.height + (onTop ? 0 : axisXHeight) + BAR_GAP;
330
+ const labelY = barOnTop ? y - 4 : y + BAR_WIDTH + 4;
331
+ const baseline = barOnTop ? "bottom" : "top";
332
+ colorbar = {
333
+ horizontal: true,
334
+ x: plot.left,
335
+ y,
336
+ width: plot.width,
337
+ height: BAR_WIDTH,
338
+ stops,
339
+ labels: barLabels.map((d) => ({
340
+ text: d.text,
341
+ x: plot.left + plot.width * d.pos,
342
+ y: labelY,
343
+ align: d.edge ? d.pos ? "right" : "left" : "center",
344
+ baseline
345
+ }))
346
+ };
347
+ }
348
+ }
349
+ return {
350
+ cells,
351
+ rows,
352
+ columns,
353
+ plot,
354
+ axisX,
355
+ axisY,
356
+ colorbar,
357
+ domain,
358
+ height: plot.height + axisXHeight + barLine + area.chrome
359
+ };
360
+ },
361
+ /**
362
+ * Get the domain of the values and the color function of them.
363
+ * The colors of the cells do not depend on what is hidden: all the series are counted.
364
+ * @returns {object} Domain and color getter
365
+ * @private
366
+ */
367
+ getHeatmapScale() {
368
+ const $$ = this;
369
+ const { config } = $$;
370
+ let min = 1e400;
371
+ let max = -1e400;
372
+ $$.data.targets.filter($$.isHeatmapType.bind($$)).forEach((t) => {
373
+ $$.color(t.id);
374
+ t.values.forEach((v) => {
375
+ if (isValue(v.value)) {
376
+ const value = Number(v.value);
377
+ min = Math.min(min, value);
378
+ max = Math.max(max, value);
379
+ }
380
+ });
381
+ });
382
+ let low = config.heatmap_color_min;
383
+ let high = config.heatmap_color_max;
384
+ if (low > high) {
385
+ if (!invalid.has($$)) {
386
+ invalid.add($$);
387
+ console.error(`[billboard.js] heatmap.color.min (${low}) is bigger than heatmap.color.max (${high}): both are ignored.`);
388
+ }
389
+ low = high = void 0;
390
+ }
391
+ const domain = [low ?? (min === 1e400 ? 0 : min), high ?? (max === -1e400 ? 1 : max)];
392
+ return {
393
+ domain,
394
+ scale: _getColorScale.call($$, domain)
395
+ };
396
+ },
397
+ /**
398
+ * Get the text color of a cell: heatmap.label.color, or the one to read on the cell.
399
+ * @param {object} cell Cell
400
+ * @returns {string} Color
401
+ * @private
402
+ */
403
+ getHeatmapLabelColor(cell) {
404
+ return this.config.heatmap_label_color || _getContrastColor(cell.color);
405
+ },
406
+ /**
407
+ * Get the label of a cell: its value, or the text of heatmap.label.format.
408
+ * @param {object} cell Cell
409
+ * @returns {string} Text, empty when it is not shown
410
+ * @private
411
+ */
412
+ getHeatmapLabel(cell) {
413
+ const $$ = this;
414
+ const { config } = $$;
415
+ if (!config.heatmap_label_show || cell.value === null) return "";
416
+ const format = config.heatmap_label_format;
417
+ return String((isFunction(format) ? format.call($$.api, cell.value, cell.x, cell.id) : cell.value) ?? "");
418
+ },
419
+ /**
420
+ * Check whether a row is defocused by focus(), defocus() or a legend hover.
421
+ * @param {string} id Row id
422
+ * @returns {boolean} Whether it is defocused
423
+ * @private
424
+ */
425
+ isHeatmapDefocused(id) {
426
+ return !!this.state.defocusedTargetIds?.has(id);
427
+ },
428
+ /**
429
+ * Get the data of a cell, for the tooltip and the events.
430
+ * @param {object} cell Cell
431
+ * @returns {object} Data
432
+ * @private
433
+ */
434
+ getHeatmapCellData(cell) {
435
+ return {
436
+ id: cell.id,
437
+ x: cell.x,
438
+ index: cell.index,
439
+ value: cell.value,
440
+ name: `${cell.name} / ${cell.x}`
441
+ };
442
+ },
443
+ /**
444
+ * The data labels of the values are not drawn for the heatmap (see customTypeHooks.labelData).
445
+ * The shared data label code asks the points of every type, so it is there.
446
+ * @returns {function} Point getter
447
+ * @private
448
+ */
449
+ generateGetHeatmapPoints() {
450
+ return () => void 0;
451
+ }
452
+ };
453
+ export { $HEATMAP, customTypeHooks, heatmap_default as default };
@@ -5,10 +5,10 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.1.4
8
+ * @version 4.2.0-next.1
9
9
  */
10
10
  import { area, line } from "d3-shape";
11
- //#region src/ChartInternal/shape/core/path.ts
11
+ // src/ChartInternal/shape/core/path.ts
12
12
  /**
13
13
  * Copyright (c) 2017 ~ present NAVER Corp.
14
14
  * billboard.js project is licensed under the MIT license
@@ -157,5 +157,4 @@ function generateDrawAreaPath($$, areaIndices, isSub, context) {
157
157
  return path || (context ? void 0 : "M 0 0");
158
158
  };
159
159
  }
160
- //#endregion
161
160
  export { generateDrawAreaPath, generateDrawLinePath };
@@ -5,14 +5,14 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.1.4
8
+ * @version 4.2.0-next.1
9
9
  */
10
10
  import { document as doc } from "../../../module/browser.js";
11
11
  import { isFunction, isObjectType, notEmpty } from "../../../module/util/type-checks.js";
12
12
  import { sanitize } from "../../../module/sanitize.js";
13
13
  import { toArray } from "../../../module/util/object.js";
14
14
  import { namespaces, select } from "d3-selection";
15
- //#region src/ChartInternal/shape/core/point.ts
15
+ // src/ChartInternal/shape/core/point.ts
16
16
  /**
17
17
  * Copyright (c) 2017 ~ present NAVER Corp.
18
18
  * billboard.js project is licensed under the MIT license
@@ -117,5 +117,4 @@ var point_default = {
117
117
  };
118
118
  }
119
119
  };
120
- //#endregion
121
120
  export { point_default as default };