billboard.js 4.1.5 → 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 (347) hide show
  1. package/dist/billboard.css +87 -1
  2. package/dist/billboard.js +11000 -6970
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +19 -19
  5. package/dist/billboard.pkgd.js +22584 -14102
  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 +2 -3
  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 +3 -4
  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 +9 -7
  63. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +39 -11
  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 +3 -4
  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 +8 -8
  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 +20 -20
  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 +5 -6
  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 +7 -7
  126. package/dist-esm/ChartInternal/shape/treemap.js +8 -5
  127. package/dist-esm/canvas/CanvasAxisRenderer.js +12 -315
  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 +2 -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 +3 -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 +112 -911
  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/focus.ts +3 -0
  257. package/src/Chart/api/subchart.ts +1 -1
  258. package/src/Chart/api/tooltip.ts +54 -15
  259. package/src/ChartInternal/Axis/AxisRenderer.ts +9 -2
  260. package/src/ChartInternal/Axis/AxisRendererHelper.ts +42 -8
  261. package/src/ChartInternal/ChartInternal.ts +46 -19
  262. package/src/ChartInternal/data/IData.ts +13 -0
  263. package/src/ChartInternal/data/data.ts +26 -5
  264. package/src/ChartInternal/data/load.ts +2 -2
  265. package/src/ChartInternal/interactions/interaction.ts +15 -11
  266. package/src/ChartInternal/internals/class.ts +3 -2
  267. package/src/ChartInternal/internals/domain.ts +4 -2
  268. package/src/ChartInternal/internals/format.ts +3 -1
  269. package/src/ChartInternal/internals/legend.ts +2 -1
  270. package/src/ChartInternal/internals/redraw.ts +3 -3
  271. package/src/ChartInternal/internals/size.ts +5 -3
  272. package/src/ChartInternal/internals/text.ts +24 -28
  273. package/src/ChartInternal/internals/tooltip.ts +35 -14
  274. package/src/ChartInternal/internals/transform.ts +2 -2
  275. package/src/ChartInternal/internals/type.ts +101 -9
  276. package/src/ChartInternal/shape/boxplot.ts +172 -0
  277. package/src/ChartInternal/shape/bullet.ts +323 -0
  278. package/src/ChartInternal/shape/core/boxplot.ts +241 -0
  279. package/src/ChartInternal/shape/core/bullet.ts +734 -0
  280. package/src/ChartInternal/shape/core/heatmap.ts +665 -0
  281. package/src/ChartInternal/shape/core/sankey.ts +782 -0
  282. package/src/ChartInternal/shape/funnel.ts +73 -2
  283. package/src/ChartInternal/shape/heatmap.ts +236 -0
  284. package/src/ChartInternal/shape/radar.ts +30 -1
  285. package/src/ChartInternal/shape/sankey.ts +242 -0
  286. package/src/ChartInternal/shape/shape.ts +1 -1
  287. package/src/ChartInternal/shape/treemap.ts +10 -0
  288. package/src/Plugin/stanford/index.ts +1 -28
  289. package/src/canvas/CanvasAxisRenderer.ts +35 -574
  290. package/src/canvas/CanvasRenderer.ts +68 -640
  291. package/src/canvas/CanvasTheme.ts +92 -6
  292. package/src/canvas/HitDetector.ts +30 -28
  293. package/src/canvas/boxplot.ts +230 -0
  294. package/src/canvas/bullet.ts +269 -0
  295. package/src/canvas/flow.ts +237 -0
  296. package/src/canvas/grid.ts +359 -0
  297. package/src/canvas/heatmap.ts +147 -0
  298. package/src/canvas/labels.ts +3 -1
  299. package/src/canvas/sankey.ts +151 -0
  300. package/src/canvas/selection.ts +626 -0
  301. package/src/canvas/subchart.ts +1292 -0
  302. package/src/canvas/treemap.ts +142 -0
  303. package/src/config/Options/axis/y2.ts +13 -0
  304. package/src/config/Options/data/data.ts +47 -1
  305. package/src/config/Options/shape/boxplot.ts +95 -0
  306. package/src/config/Options/shape/bullet.ts +170 -0
  307. package/src/config/Options/shape/heatmap.ts +125 -0
  308. package/src/config/Options/shape/sankey.ts +108 -0
  309. package/src/config/Store/State.ts +1 -1
  310. package/src/config/classes.ts +0 -1
  311. package/src/config/const.ts +30 -21
  312. package/src/config/resolver/canvas.ts +126 -1290
  313. package/src/config/resolver/canvasBoxplot.ts +42 -0
  314. package/src/config/resolver/canvasBullet.ts +20 -0
  315. package/src/config/resolver/canvasFlow.ts +18 -0
  316. package/src/config/resolver/canvasGrid.ts +17 -0
  317. package/src/config/resolver/canvasHeatmap.ts +23 -0
  318. package/src/config/resolver/canvasSankey.ts +23 -0
  319. package/src/config/resolver/canvasSelection.ts +20 -0
  320. package/src/config/resolver/canvasShape.ts +6 -1
  321. package/src/config/resolver/canvasSubchart.ts +20 -0
  322. package/src/config/resolver/canvasType.ts +51 -0
  323. package/src/config/resolver/customType.ts +69 -0
  324. package/src/config/resolver/shape/boxplot.ts +31 -0
  325. package/src/config/resolver/shape/bullet.ts +18 -0
  326. package/src/config/resolver/shape/funnel.ts +8 -2
  327. package/src/config/resolver/shape/heatmap.ts +18 -0
  328. package/src/config/resolver/shape/index.ts +4 -0
  329. package/src/config/resolver/shape/sankey.ts +18 -0
  330. package/src/index.canvas.ts +9 -3
  331. package/src/index.esm.ts +4 -0
  332. package/src/index.ts +34 -0
  333. package/src/module/error.ts +32 -18
  334. package/src/module/util/object.ts +26 -1
  335. package/src/scss/billboard.scss +106 -0
  336. package/src/scss/theme/dark.scss +110 -0
  337. package/src/scss/theme/datalab.scss +106 -0
  338. package/src/scss/theme/graph.scss +106 -0
  339. package/src/scss/theme/insight.scss +106 -0
  340. package/src/scss/theme/modern.scss +106 -0
  341. package/types/bb.d.ts +4 -0
  342. package/types/canvas.d.ts +3 -0
  343. package/types/chart.d.ts +5 -0
  344. package/types/index.d.ts +4 -0
  345. package/types/options.d.ts +10 -1
  346. package/types/options.shape.d.ts +431 -0
  347. package/types/types.d.ts +4 -0
@@ -0,0 +1,665 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {interpolateRgb as d3InterpolateRgb} from "d3-interpolate";
6
+ import {scaleLinear as d3ScaleLinear} from "d3-scale";
7
+ import {isFunction} from "../../../module/util";
8
+
9
+ // class names of the heatmap elements
10
+ export const $HEATMAP = {
11
+ chartHeatmap: "bb-chart-heatmap",
12
+ heatmapRows: "bb-heatmap-rows",
13
+ heatmapRow: "bb-heatmap-row",
14
+ heatmapCell: "bb-heatmap-cell",
15
+ heatmapLabel: "bb-heatmap-label",
16
+ heatmapNames: "bb-heatmap-names",
17
+ heatmapAxis: "bb-heatmap-axis",
18
+ heatmapColorbar: "bb-heatmap-colorbar"
19
+ };
20
+
21
+ export interface IHeatmapCell {
22
+ // the series (row) of the cell, its name, and the name of the column
23
+ id: string;
24
+ name: string;
25
+ x: string;
26
+ // the index of the column, and of the row among the shown rows
27
+ index: number;
28
+ row: number;
29
+ // null for a cell without a value
30
+ value: number | null;
31
+ color: string;
32
+ x0: number;
33
+ y0: number;
34
+ x1: number;
35
+ y1: number;
36
+ }
37
+
38
+ export interface IHeatmapRange {
39
+ from?: number;
40
+ to?: number;
41
+ color: string;
42
+ name?: string;
43
+ }
44
+
45
+ export interface IHeatmapText {
46
+ text: string;
47
+ x: number;
48
+ y: number;
49
+ align: "left" | "right" | "center";
50
+ baseline: "middle" | "top" | "bottom";
51
+ }
52
+
53
+ export interface IHeatmapColorbar {
54
+ // true: from the left (the min) to the right (the max), false: from the bottom to the top
55
+ horizontal: boolean;
56
+ x: number;
57
+ y: number;
58
+ width: number;
59
+ height: number;
60
+ // along the bar from its start (the left, or the top) to its end: offset 0 ~ 1 and color
61
+ stops: [number, string][];
62
+ labels: IHeatmapText[];
63
+ }
64
+
65
+ // a name along the color bar: 0 is the start (the min), 1 is the end, a name of a range is in its middle
66
+ interface IBarLabel {
67
+ text: string;
68
+ pos: number;
69
+ edge: boolean;
70
+ }
71
+
72
+ export interface IHeatmapLayout {
73
+ // the height of the chart the cells fit in, from the width: for the cell ratio
74
+ height: number;
75
+ cells: IHeatmapCell[];
76
+ rows: string[];
77
+ columns: string[];
78
+ plot: {left: number, top: number, width: number, height: number};
79
+ axisX: IHeatmapText[];
80
+ axisY: IHeatmapText[];
81
+ colorbar: IHeatmapColorbar | null;
82
+ domain: [number, number];
83
+ }
84
+
85
+ // the size of the column names (a line), the gap to the plot, and the color bar
86
+ const AXIS_X_SIZE = 18;
87
+ const AXIS_GAP = 6;
88
+ const BAR_WIDTH = 12;
89
+ const BAR_GAP = 10;
90
+ // the height of the names of the values of a horizontal bar
91
+ const BAR_LABEL = 16;
92
+ const LINE_HEIGHT = 11;
93
+
94
+ // the property of the object itself: "constructor" or "toString" as a data id is not a key
95
+ const own = (obj, key: string) =>
96
+ obj && Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
97
+
98
+ const isValue = (value): boolean =>
99
+ value !== null && value !== undefined && value !== "" &&
100
+ Number.isFinite(Number(value));
101
+
102
+ /**
103
+ * Get the area the heatmap is drawn in, in chart coordinates.
104
+ * @returns {object} Area
105
+ * @private
106
+ */
107
+ function _getArea(): {left: number, top: number, width: number, height: number, chrome: number} {
108
+ const $$ = this;
109
+ const {config, state: {current: {width, height}, isCanvasMode, isLegendRight}} = $$;
110
+ const padding = $$.getCurrentPadding();
111
+ // canvas mode draws the legend as HTML outside of its drawing surface: only the gap is needed
112
+ const legendHeight = config.legend_show && config.legend_position === "bottom" ?
113
+ (isCanvasMode ? 0 : $$.getLegendHeight()) + 10 :
114
+ 0;
115
+ const legendRight = config.legend_show && isLegendRight ?
116
+ $$.getLegendWidth() + (config.padding?.mode === "fit" ? 6 : 20) :
117
+ 0;
118
+ const surfaceHeight = isCanvasMode ? $$.getCanvasSurfaceHeight() : height;
119
+
120
+ const areaHeight = Math.max(0, surfaceHeight - padding.top - padding.bottom - legendHeight);
121
+ // canvas mode has the bottom legend as HTML under the surface
122
+ const domLegend = isCanvasMode && legendHeight ? $$.getCanvasBottomLegendHeight?.() || 0 : 0;
123
+
124
+ return {
125
+ left: padding.left,
126
+ top: padding.top,
127
+ width: Math.max(0, width - padding.left - padding.right - legendRight),
128
+ height: areaHeight,
129
+ // what the chart has besides the area: the paddings and the legend
130
+ chrome: padding.top + padding.bottom + legendHeight + domLegend
131
+ };
132
+ }
133
+
134
+ /**
135
+ * Get the width of the widest text, drawn with the style of the axis.
136
+ * @param {Array} texts Texts
137
+ * @returns {number} Width in px
138
+ * @private
139
+ */
140
+ function _getTextWidth(texts: string[]): number {
141
+ const $$ = this;
142
+ const {cache, state: {isCanvasMode}, $el} = $$;
143
+ const key = `heatmap-text-${isCanvasMode}-${texts.join("\u0000")}`;
144
+ let width: number = cache.get(key) || 0;
145
+
146
+ if (!width && isCanvasMode && $$.canvasRenderer) {
147
+ const {ctx} = $$.canvasRenderer;
148
+
149
+ ctx.save();
150
+ ctx.font = $$.canvasTheme.style.heatmap.axisFont;
151
+ width = texts.reduce((w, v) => Math.max(w, ctx.measureText(v).width), 0);
152
+ ctx.restore();
153
+ } else if (!width && !isCanvasMode && $el.heatmap) {
154
+ const text = $el.heatmap.append("text")
155
+ .attr("class", $HEATMAP.heatmapAxis)
156
+ .style("visibility", "hidden");
157
+
158
+ texts.forEach(v => {
159
+ width = Math.max(width, text.text(v).node().getComputedTextLength?.() || 0);
160
+ });
161
+ text.remove();
162
+ }
163
+
164
+ if (width) {
165
+ cache.add(key, width);
166
+ } else {
167
+ // it can not be measured yet (not drawn): estimate from the characters
168
+ width = texts.reduce((n, v) => Math.max(n, v.length), 0) * 6.5;
169
+ }
170
+
171
+ return Math.ceil(width);
172
+ }
173
+
174
+ /**
175
+ * Get the color function of the values: the colors of heatmap.color.range spread on the domain.
176
+ * @param {Array} domain Min and max value
177
+ * @returns {function} Color getter
178
+ * @private
179
+ */
180
+ function _getColorScale(domain: [number, number]): (value: number) => string | undefined {
181
+ const ranges: IHeatmapRange[] = this.config.heatmap_color_ranges;
182
+
183
+ // by the ranges: the first one that has the value, none when there is no such range
184
+ if (ranges?.length) {
185
+ return value =>
186
+ ranges.find(r => value >= (r.from ?? -Infinity) && value <= (r.to ?? Infinity))
187
+ ?.color;
188
+ }
189
+
190
+ const range: string[] = this.config.heatmap_color_range;
191
+ const [min, max] = domain;
192
+ const last = range.length - 1;
193
+
194
+ if (last < 1) {
195
+ return () => range[0];
196
+ }
197
+
198
+ return d3ScaleLinear<string>()
199
+ .domain(range.map((_, i) => min + (max - min) * i / last))
200
+ .range(range)
201
+ .interpolate(d3InterpolateRgb)
202
+ .clamp(true);
203
+ }
204
+
205
+ /**
206
+ * Get the text color to read on the color: black on a light one, white on a dark one.
207
+ * @param {string} color Color in the rgb() or the hex form
208
+ * @returns {string} Text color
209
+ * @private
210
+ */
211
+ function _getContrastColor(color: string): string {
212
+ const m = /^rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(color);
213
+ let rgb: number[] = [0, 0, 0];
214
+
215
+ if (m) {
216
+ rgb = [+m[1], +m[2], +m[3]];
217
+ } else if (/^#[0-9a-f]{6}$/i.test(color)) {
218
+ rgb = [1, 3, 5].map(i => parseInt(color.slice(i, i + 2), 16));
219
+ } else if (/^#[0-9a-f]{3}$/i.test(color)) {
220
+ rgb = [1, 2, 3].map(i => parseInt(color[i] + color[i], 16));
221
+ }
222
+
223
+ // perceived brightness
224
+ return (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 > 140 ? "#000" : "#fff";
225
+ }
226
+
227
+ /**
228
+ * Get the names to draw along an axis: every name that fits, or every n-th name when they don't.
229
+ * @param {Array} names Names
230
+ * @param {number} step Size of a cell along the axis
231
+ * @param {number} size Size of the widest name along the axis
232
+ * @param {number} [gap=4] The space kept between two names
233
+ * @returns {Array} The names with their index
234
+ * @private
235
+ */
236
+ function _getNames(names: string[], step: number, size: number, gap = 4): [string, number][] {
237
+ const skip = Math.max(1, Math.ceil((size + gap) / (step || 1)));
238
+
239
+ return names.map((v, i) => <[string, number]>[v, i]).filter(([, i]) => i % skip === 0);
240
+ }
241
+
242
+ /**
243
+ * How the heatmap differs from the other types for the shared code.
244
+ * It asks these through `getCustomTypeHooks()` (they are registered with the type name).
245
+ * @private
246
+ */
247
+ export const customTypeHooks = {
248
+ // the legend is placed beside its own plot, not by the size of an arc
249
+ ownLegendLayout: true,
250
+
251
+ // with a cell ratio, the chart is as high as its cells need, when the height is not set
252
+ currentHeight($$): number | undefined {
253
+ if (!($$.config.heatmap_cell_ratio > 0) || !$$.data?.targets?.length) {
254
+ return undefined;
255
+ }
256
+
257
+ const {height} = $$.getHeatmapLayout(true);
258
+
259
+ return Number.isFinite(height) ? Math.ceil(height) : undefined;
260
+ },
261
+
262
+ // the name of a cell tells its row and its column ("Noon / Wed"): the tooltip has no title of the x
263
+ namedData: true,
264
+
265
+ // the names and the values are drawn by the type: there are no data labels of the values
266
+ labelData(): [] {
267
+ return [];
268
+ },
269
+
270
+ // the swatch of the legend: the color of the mean value of the row, as the color of the cells
271
+ legendColor($$, data): string | undefined {
272
+ const values = data.values.filter(v => isValue(v.value));
273
+
274
+ return values.length ?
275
+ ($$.getHeatmapScale().scale(
276
+ values.reduce((sum, v) => sum + Number(v.value), 0) / values.length
277
+ ) ?? $$.config.heatmap_color_none ?? undefined) :
278
+ undefined;
279
+ },
280
+
281
+ // the swatch of the tooltip: the color of the cell
282
+ tooltipColor($$, row): string | undefined {
283
+ return isValue(row.value) ?
284
+ ($$.getHeatmapScale().scale(Number(row.value)) ?? $$.config.heatmap_color_none ??
285
+ undefined) :
286
+ undefined;
287
+ },
288
+
289
+ // the tooltip of a cell, addressed by its row (tooltip.show({data: {id}, index: column}))
290
+ tooltipTarget($$, args) {
291
+ const {cells} = $$.getHeatmapLayout();
292
+ const id = args.data?.id;
293
+ const index = args.index ?? args.data?.index;
294
+ const x = args.x ?? args.data?.x;
295
+ const cell = cells.find(d =>
296
+ (id === undefined || d.id === id) &&
297
+ (index !== undefined ?
298
+ d.index === index :
299
+ (x !== undefined ? d.x === String(x) : true)) &&
300
+ d.value !== null
301
+ );
302
+
303
+ return {
304
+ data: cell ? [$$.getHeatmapCellData(cell)] : [],
305
+ point: cell && [(cell.x0 + cell.x1) / 2, (cell.y0 + cell.y1) / 2]
306
+ };
307
+ }
308
+ };
309
+
310
+ // the charts that told about a min over the max
311
+ const invalid = new WeakSet<object>();
312
+
313
+ // how many times the height was fit again for a width, by chart
314
+ const fitting = new WeakMap<object, {width: number, count: number}>();
315
+
316
+ export default {
317
+ /**
318
+ * Fit the height of the chart (heatmap.cell.ratio) after a draw.
319
+ * The first height is made before the legend and the other parts are there to measure: it is fit
320
+ * again once they are, as the resize of the window does. At most 3 times for a width.
321
+ * @private
322
+ */
323
+ fitHeatmapHeight(): void {
324
+ const $$ = this;
325
+ const {width, height} = $$.state.current;
326
+ const fit = customTypeHooks.currentHeight($$);
327
+ let state = fitting.get($$);
328
+
329
+ if (!state || state.width !== width) {
330
+ fitting.set($$, state = {width, count: 0});
331
+ }
332
+
333
+ if (fit && Math.abs(fit - height) > 1 && state.count++ < 3) {
334
+ $$.resizeFunction();
335
+ }
336
+ },
337
+
338
+ /**
339
+ * Whether the data belongs to the heatmap type.
340
+ * @param {object} d Data object
341
+ * @returns {boolean}
342
+ * @private
343
+ */
344
+ isHeatmapType(d): boolean {
345
+ return this.isTypeOf(d, "heatmap");
346
+ },
347
+
348
+ /**
349
+ * Get the layout of the cells, the names and the color bar, in chart coordinates.
350
+ * Shared by the SVG and the canvas renderer.
351
+ * @param {boolean} [fit=false] Set true to lay out the cells without the height limit, to get the height they need
352
+ * @returns {object} Heatmap layout
353
+ * @private
354
+ */
355
+ getHeatmapLayout(fit = false): IHeatmapLayout {
356
+ const $$ = this;
357
+ const {config} = $$;
358
+ const targets = $$.data.targets.filter($$.isHeatmapType.bind($$));
359
+ const area = _getArea.call($$);
360
+
361
+ // the height is not a limit when the chart is made as high as the cells need
362
+ fit && (area.height = Infinity);
363
+
364
+ // the columns are of the longest series: a shorter one has no cells after its end
365
+ const longest = targets.reduce((a, t) => (t.values.length > a.length ? t.values : a), []);
366
+ const columns: string[] = longest.map(v => String(v.x));
367
+ const {domain, scale} = $$.getHeatmapScale();
368
+ const shown = targets.filter(t => $$.isTargetToShow(t.id));
369
+ const rows = shown.map(t => t.id);
370
+ const names = shown.map(t => String(own(config.data_names, t.id) ?? t.id));
371
+
372
+ // the space the names and the color bar take
373
+ const showX = config.heatmap_axis_x_show && columns.length > 0;
374
+ const showY = config.heatmap_axis_y_show && rows.length > 0;
375
+ const axisYWidth = showY ? _getTextWidth.call($$, names) + AXIS_GAP : 0;
376
+ const axisXHeight = showX ? AXIS_X_SIZE : 0;
377
+ const onTop = config.heatmap_axis_x_position === "top";
378
+ const format = config.heatmap_colorbar_format;
379
+ const fmt = (v: number | undefined) =>
380
+ v === undefined ? "" : String(isFunction(format) ? format.call($$.api, v) : v);
381
+ const ranges: IHeatmapRange[] = config.heatmap_color_ranges || [];
382
+ let barLabels: IBarLabel[] = [];
383
+
384
+ if (config.heatmap_colorbar_show) {
385
+ barLabels = ranges.length ?
386
+ ranges.map((r, i) => ({
387
+ text: r.name ??
388
+ (r.from === undefined ?
389
+ `≤ ${fmt(r.to)}` :
390
+ (r.to === undefined ?
391
+ `≥ ${fmt(r.from)}` :
392
+ `${fmt(r.from)} - ${fmt(r.to)}`)),
393
+ pos: (i + 0.5) / ranges.length,
394
+ edge: false
395
+ })) :
396
+ domain.map((v, i) => ({text: fmt(v), pos: i, edge: true}));
397
+ }
398
+ const barPosition = config.heatmap_colorbar_position;
399
+ const isBarSide = barPosition !== "top" && barPosition !== "bottom";
400
+ const hasBar = barLabels.length > 0;
401
+ const barSpace = hasBar && isBarSide ?
402
+ BAR_GAP + BAR_WIDTH + 4 + _getTextWidth.call($$, barLabels.map(d => d.text)) :
403
+ 0;
404
+ // a horizontal bar takes a line above or below the cells (and the names of the columns)
405
+ const barLine = hasBar && !isBarSide ? BAR_GAP + BAR_WIDTH + BAR_LABEL : 0;
406
+ const barOnTop = barPosition === "top";
407
+ const plot = {
408
+ left: area.left + axisYWidth,
409
+ top: area.top + (onTop ? axisXHeight : 0) + (barOnTop ? barLine : 0),
410
+ width: Math.max(0, area.width - axisYWidth - barSpace),
411
+ height: Math.max(0, area.height - axisXHeight - barLine)
412
+ };
413
+ let cw = columns.length ? plot.width / columns.length : 0;
414
+ let ch = rows.length ? plot.height / rows.length : 0;
415
+ const ratio = config.heatmap_cell_ratio;
416
+
417
+ // the biggest cells of the ratio that fit: the plot shrinks to them, from its left and top
418
+ if (ratio > 0 && cw && ch) {
419
+ cw = Math.min(cw, ch * ratio);
420
+ ch = cw / ratio;
421
+ plot.width = cw * columns.length;
422
+ plot.height = ch * rows.length;
423
+ }
424
+ const pad = config.heatmap_cell_padding / 2;
425
+ const none = config.heatmap_color_none;
426
+ const cells: IHeatmapCell[] = [];
427
+
428
+ shown.forEach((t, row) => {
429
+ t.values.forEach((v, index) => {
430
+ const hasValue = isValue(v.value);
431
+
432
+ const color = hasValue ? scale(Number(v.value)) ?? none : none;
433
+
434
+ // no color: the value is in no range and there is no color for it
435
+ if (!color) {
436
+ return;
437
+ }
438
+
439
+ cells.push({
440
+ id: t.id,
441
+ name: names[row],
442
+ x: columns[index],
443
+ index,
444
+ row,
445
+ value: hasValue ? Number(v.value) : null,
446
+ color,
447
+ x0: plot.left + index * cw + pad,
448
+ y0: plot.top + row * ch + pad,
449
+ x1: plot.left + (index + 1) * cw - pad,
450
+ y1: plot.top + (row + 1) * ch - pad
451
+ });
452
+ });
453
+ });
454
+
455
+ const axisX: IHeatmapText[] = showX ?
456
+ _getNames(columns, cw, _getTextWidth.call($$, columns)).map(([text, i]) => ({
457
+ text,
458
+ x: plot.left + (i + 0.5) * cw,
459
+ y: onTop ? plot.top - AXIS_GAP : plot.top + plot.height + AXIS_GAP,
460
+ align: "center",
461
+ baseline: onTop ? "bottom" : "top"
462
+ })) :
463
+ [];
464
+ const axisY: IHeatmapText[] = showY ?
465
+ _getNames(names, ch, LINE_HEIGHT, 0).map(([text, i]) => ({
466
+ text,
467
+ x: plot.left - AXIS_GAP,
468
+ y: plot.top + (i + 0.5) * ch,
469
+ align: "right",
470
+ baseline: "middle"
471
+ })) :
472
+ [];
473
+
474
+ let colorbar: IHeatmapColorbar | null = null;
475
+
476
+ if (hasBar) {
477
+ const colors: string[] = ranges.length ?
478
+ ranges.map(r => r.color) :
479
+ config.heatmap_color_range;
480
+ const last = colors.length - 1;
481
+ // the ranges are bands of the same size with hard edges: their colors are on both ends
482
+ const stops: [number, string][] = [];
483
+
484
+ colors.forEach((c, i) => {
485
+ if (ranges.length) {
486
+ stops.push([i / colors.length, c], [(i + 1) / colors.length, c]);
487
+ } else {
488
+ stops.push([last ? i / last : 0, c]);
489
+ }
490
+ });
491
+
492
+ if (isBarSide) {
493
+ const x = plot.left + plot.width + BAR_GAP;
494
+
495
+ colorbar = {
496
+ horizontal: false,
497
+ x,
498
+ y: plot.top,
499
+ width: BAR_WIDTH,
500
+ height: plot.height,
501
+ // the max is on the top
502
+ stops: stops.map(([o, c]) => <[number, string]>[1 - o, c]).reverse(),
503
+ labels: barLabels.map(d => ({
504
+ text: d.text,
505
+ x: x + BAR_WIDTH + 4,
506
+ y: plot.top + plot.height * (1 - d.pos),
507
+ align: "left",
508
+ baseline: d.edge ? (d.pos ? "top" : "bottom") : "middle"
509
+ }))
510
+ };
511
+ } else {
512
+ // above the names of the columns, or under them
513
+ const y = barOnTop ?
514
+ area.top + BAR_LABEL :
515
+ plot.top + plot.height + (onTop ? 0 : axisXHeight) + BAR_GAP;
516
+ const labelY = barOnTop ? y - 4 : y + BAR_WIDTH + 4;
517
+ const baseline = barOnTop ? "bottom" : "top";
518
+
519
+ colorbar = {
520
+ horizontal: true,
521
+ x: plot.left,
522
+ y,
523
+ width: plot.width,
524
+ height: BAR_WIDTH,
525
+ stops,
526
+ labels: barLabels.map(d => ({
527
+ text: d.text,
528
+ x: plot.left + plot.width * d.pos,
529
+ y: labelY,
530
+ align: d.edge ? (d.pos ? "right" : "left") : "center",
531
+ baseline
532
+ }))
533
+ };
534
+ }
535
+ }
536
+
537
+ return {
538
+ cells,
539
+ rows,
540
+ columns,
541
+ plot,
542
+ axisX,
543
+ axisY,
544
+ colorbar,
545
+ domain,
546
+ height: plot.height + axisXHeight + barLine + area.chrome
547
+ };
548
+ },
549
+
550
+ /**
551
+ * Get the domain of the values and the color function of them.
552
+ * The colors of the cells do not depend on what is hidden: all the series are counted.
553
+ * @returns {object} Domain and color getter
554
+ * @private
555
+ */
556
+ getHeatmapScale(): {domain: [number, number], scale: (value: number) => string | undefined} {
557
+ const $$ = this;
558
+ const {config} = $$;
559
+ let min = Infinity;
560
+ let max = -Infinity;
561
+
562
+ $$.data.targets.filter($$.isHeatmapType.bind($$)).forEach(t => {
563
+ // the series get their colors in the data order, shown or not
564
+ $$.color(t.id);
565
+ t.values.forEach(v => {
566
+ if (isValue(v.value)) {
567
+ const value = Number(v.value);
568
+
569
+ min = Math.min(min, value);
570
+ max = Math.max(max, value);
571
+ }
572
+ });
573
+ });
574
+
575
+ let low = config.heatmap_color_min;
576
+ let high = config.heatmap_color_max;
577
+
578
+ // a min over the max would turn the colors upside down: they are not used
579
+ if (low > high) {
580
+ if (!invalid.has($$)) {
581
+ invalid.add($$);
582
+ console.error(
583
+ `[billboard.js] heatmap.color.min (${low}) is bigger than heatmap.color.max (${high}): both are ignored.`
584
+ );
585
+ }
586
+
587
+ low = high = undefined;
588
+ }
589
+
590
+ const domain: [number, number] = [
591
+ low ?? (min === Infinity ? 0 : min),
592
+ high ?? (max === -Infinity ? 1 : max)
593
+ ];
594
+
595
+ return {domain, scale: _getColorScale.call($$, domain)};
596
+ },
597
+
598
+ /**
599
+ * Get the text color of a cell: heatmap.label.color, or the one to read on the cell.
600
+ * @param {object} cell Cell
601
+ * @returns {string} Color
602
+ * @private
603
+ */
604
+ getHeatmapLabelColor(cell: IHeatmapCell): string {
605
+ return this.config.heatmap_label_color || _getContrastColor(cell.color);
606
+ },
607
+
608
+ /**
609
+ * Get the label of a cell: its value, or the text of heatmap.label.format.
610
+ * @param {object} cell Cell
611
+ * @returns {string} Text, empty when it is not shown
612
+ * @private
613
+ */
614
+ getHeatmapLabel(cell: IHeatmapCell): string {
615
+ const $$ = this;
616
+ const {config} = $$;
617
+
618
+ if (!config.heatmap_label_show || cell.value === null) {
619
+ return "";
620
+ }
621
+
622
+ const format = config.heatmap_label_format;
623
+
624
+ return String(
625
+ (isFunction(format) ? format.call($$.api, cell.value, cell.x, cell.id) : cell.value) ??
626
+ ""
627
+ );
628
+ },
629
+
630
+ /**
631
+ * Check whether a row is defocused by focus(), defocus() or a legend hover.
632
+ * @param {string} id Row id
633
+ * @returns {boolean} Whether it is defocused
634
+ * @private
635
+ */
636
+ isHeatmapDefocused(id: string): boolean {
637
+ return !!this.state.defocusedTargetIds?.has(id);
638
+ },
639
+
640
+ /**
641
+ * Get the data of a cell, for the tooltip and the events.
642
+ * @param {object} cell Cell
643
+ * @returns {object} Data
644
+ * @private
645
+ */
646
+ getHeatmapCellData(cell: IHeatmapCell) {
647
+ return {
648
+ id: cell.id,
649
+ x: cell.x,
650
+ index: cell.index,
651
+ value: cell.value,
652
+ name: `${cell.name} / ${cell.x}`
653
+ };
654
+ },
655
+
656
+ /**
657
+ * The data labels of the values are not drawn for the heatmap (see customTypeHooks.labelData).
658
+ * The shared data label code asks the points of every type, so it is there.
659
+ * @returns {function} Point getter
660
+ * @private
661
+ */
662
+ generateGetHeatmapPoints(): () => undefined {
663
+ return () => undefined;
664
+ }
665
+ };