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
@@ -5,8 +5,9 @@
5
5
  import {select as d3Select} from "d3-selection";
6
6
  import {curveLinear as d3CurveLinear, line as d3Line} from "d3-shape";
7
7
  import {$COMMON, $FUNNEL} from "../../config/classes";
8
- import {isObject} from "../../module/util";
8
+ import {getElementPos, isNumber, isObject} from "../../module/util";
9
9
  import type {IData, IDataRow, IFunnelData} from "../data/IData";
10
+ import {getTextPos} from "../internals/text.util";
10
11
 
11
12
  type TSize = { [key in "width" | "height" | "top" | "left"]: number };
12
13
  type TSizeCurrent = Pick<TSize, "width" | "height">;
@@ -285,7 +286,67 @@ function _getSplineClipPath(): string {
285
286
  return isRotated ? `${path1}${path2}z` : `M0,0${path1.replace(/^M/, "L")}${path2}z`;
286
287
  }
287
288
 
289
+ /**
290
+ * How the funnel differs from the other types for the shared code.
291
+ * It asks these through `getCustomTypeHooks()` (they are registered with the type name).
292
+ * @private
293
+ */
294
+ export const customTypeHooks = {
295
+ // the label is not drawn with the color of the series
296
+ themeTextColor: true,
297
+
298
+ // funnel is drawn by svg only: canvas mode falls back to it, and warns with this
299
+ canvasUnsupported: "funnel chart",
300
+
301
+ // the data of the types that are left is transformed again after the unload
302
+ afterUnload($$): void {
303
+ $$.updateFunnel($$.data.targets);
304
+ },
305
+
306
+ // the data labels are of the values, as for the type of the axis
307
+ labelData($$, d): IDataRow[] {
308
+ return d.values.filter(v => isNumber(v.value) || Boolean(v.value));
309
+ },
310
+
311
+ // the pre-calculated center x is in points[2]
312
+ // the current position is kept when there are no points (during the hide transition)
313
+ textX($$, points, d, textElement, labelDimension?): number {
314
+ if (!points) {
315
+ return getElementPos(textElement, "x");
316
+ }
317
+
318
+ return (points[2]?.[0] ?? points[0][0]) +
319
+ $$.getCenteredTextPos(d, points, textElement, "x", labelDimension) +
320
+ getTextPos.call($$, d, "x");
321
+ },
322
+
323
+ // the pre-calculated center y is in points[2], and it is kept as well without points
324
+ textY($$, points, d, textElement, rect, labelDimension?): number {
325
+ if (!points) {
326
+ return getElementPos(textElement, "y");
327
+ }
328
+
329
+ let yPos = (points[2]?.[1] ?? points[0][1]) + rect.height / 2 - 3;
330
+
331
+ if (!$$.config.axis_rotated) {
332
+ yPos += $$.getCenteredTextPos(d, points, textElement, "y", labelDimension);
333
+ }
334
+
335
+ return yPos + getTextPos.call($$, d, "y");
336
+ }
337
+ };
338
+
288
339
  export default {
340
+ /**
341
+ * Whether the data belongs to the funnel type.
342
+ * @param {object} d Data object
343
+ * @returns {boolean}
344
+ * @private
345
+ */
346
+ isFunnelType(d): boolean {
347
+ return this.isTypeOf(d, "funnel");
348
+ },
349
+
289
350
  /**
290
351
  * Initialize funnel
291
352
  * @private
@@ -343,6 +404,16 @@ export default {
343
404
  $$.hideTooltip();
344
405
  $$.setOverOut(false, data);
345
406
  }
407
+ })
408
+ // use the clicked path itself: getTarget() takes the tooltip API's receiver for an
409
+ // untrusted event, and the background path has no data
410
+ .on("click", event => {
411
+ const {target} = event;
412
+ const data = /^path$/i.test(target.tagName) ?
413
+ d3Select(target).datum() as IDataRow :
414
+ null;
415
+
416
+ data?.id && config.data_onclick.bind($$.api)(data, target);
346
417
  });
347
418
  },
348
419
 
@@ -360,7 +431,7 @@ export default {
360
431
  }
361
432
 
362
433
  const classChartFunnel = $$.getChartClass("Funnel");
363
- const classFunnel = $$.getClass("funnel", true);
434
+ const classFunnel = $$.getClass("funnel", true, true);
364
435
  const targets = _getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
365
436
 
366
437
  const mainFunnelUpdate = $$.filterNullish(targets);
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {select as d3Select} from "d3-selection";
6
+ import {$COMMON, $FOCUS, $SHAPE} from "../../config/classes";
7
+ import shapeHeatmapCommon, {$HEATMAP, type IHeatmapCell, type IHeatmapText} from "./core/heatmap";
8
+
9
+ const ANCHOR = {left: "start", right: "end", center: "middle"};
10
+ const DY = {middle: ".35em", top: ".71em", bottom: "0"};
11
+
12
+ export default {
13
+ ...shapeHeatmapCommon,
14
+
15
+ /**
16
+ * Initialize heatmap
17
+ * @private
18
+ */
19
+ initHeatmap(): void {
20
+ const $$ = this;
21
+ const {$el} = $$;
22
+
23
+ $el.heatmap = $el.main.select(`.${$COMMON.chart}`)
24
+ .append("g")
25
+ .classed($HEATMAP.chartHeatmap, true);
26
+
27
+ // the gradient of the color bar
28
+ $el.heatmap.append("defs");
29
+ $el.heatmap.append("g").classed($HEATMAP.heatmapRows, true);
30
+ $el.heatmap.append("g").classed($HEATMAP.heatmapNames, true);
31
+ $el.heatmap.append("g").classed($HEATMAP.heatmapColorbar, true);
32
+
33
+ $$.bindHeatmapEvent();
34
+ },
35
+
36
+ /**
37
+ * Bind events
38
+ * @private
39
+ */
40
+ bindHeatmapEvent(): void {
41
+ const $$ = this;
42
+ const {$el: {heatmap}, config, state} = $$;
43
+
44
+ if (!config.interaction_enabled) {
45
+ return;
46
+ }
47
+
48
+ const getTarget = event => {
49
+ // events emulated by the tooltip API are dispatched on the group itself
50
+ const target = event.target === heatmap.node() ?
51
+ state.eventReceiver.rect?.node?.() :
52
+ event.target;
53
+
54
+ if (target && /^rect$/i.test(target.tagName)) {
55
+ const datum: IHeatmapCell | undefined = d3Select(target).datum() as any;
56
+
57
+ // a cell without a value is not hit
58
+ if (datum?.id !== undefined && datum.value !== undefined && datum.value !== null) {
59
+ state.event = event;
60
+ return $$.getHeatmapCellData(datum);
61
+ }
62
+ }
63
+ };
64
+
65
+ const isTouch = state.inputType === "touch";
66
+
67
+ heatmap
68
+ .on(isTouch ? "touchstart" : "mouseover mousemove", event => {
69
+ const data = getTarget(event);
70
+
71
+ if (data) {
72
+ $$.showTooltip([data], $$.$el.svg.node());
73
+ /^(touchstart|mouseover)$/.test(event.type) &&
74
+ $$.setOverOut(true, data, event.target);
75
+ }
76
+ }, isTouch ? {passive: true} : undefined)
77
+ .on(isTouch ? "touchend" : "mouseout", event => {
78
+ const data = getTarget(event);
79
+
80
+ if (config.interaction_onout) {
81
+ $$.hideTooltip();
82
+ $$.setOverOut(false, data, event.target);
83
+ }
84
+ })
85
+ .on("click", event => {
86
+ const data = getTarget(event);
87
+
88
+ data && config.data_onclick.bind($$.api)(data, event.target);
89
+ });
90
+ },
91
+
92
+ /**
93
+ * Update targets for heatmap.
94
+ * The cells are made from all the series together, on redraw.
95
+ * @private
96
+ */
97
+ updateTargetsForHeatmap(): void {
98
+ const $$ = this;
99
+
100
+ !$$.$el.heatmap && $$.initHeatmap();
101
+ },
102
+
103
+ /**
104
+ * Draw a text of the axis or of the color bar
105
+ * @param {d3Selection} sel Text selection
106
+ * @param {boolean} withTransition Whether to transit
107
+ * @private
108
+ */
109
+ setHeatmapText(sel, withTransition?: boolean): void {
110
+ const $$ = this;
111
+
112
+ sel.each(function(d: IHeatmapText) {
113
+ d3Select(this)
114
+ .attr("class", $HEATMAP.heatmapAxis)
115
+ .text(d.text)
116
+ .attr("dy", DY[d.baseline])
117
+ .style("text-anchor", ANCHOR[d.align]);
118
+ });
119
+
120
+ $$.$T(sel, withTransition)
121
+ .attr("x", d => d.x)
122
+ .attr("y", d => d.y);
123
+ },
124
+
125
+ /**
126
+ * Render heatmap
127
+ * @param {boolean} withTransition Whether to transit
128
+ * @private
129
+ */
130
+ redrawHeatmap(withTransition?: boolean): void {
131
+ const $$ = this;
132
+ const {$el: {heatmap}, config, state} = $$;
133
+ const {cells, rows, axisX, axisY, colorbar} = $$.getHeatmapLayout();
134
+ const radius = config.heatmap_cell_radius;
135
+ const borderWidth = config.heatmap_cell_border_width;
136
+ const byRow = new Map<string, IHeatmapCell[]>(rows.map(id => [id, []]));
137
+
138
+ cells.forEach(d => byRow.get(d.id)?.push(d));
139
+
140
+ // rows: the target class of the id makes show(), hide(), focus() and tooltip.show() find it
141
+ const row = heatmap.select(`.${$HEATMAP.heatmapRows}`)
142
+ .selectAll(`.${$HEATMAP.heatmapRow}`)
143
+ .data(rows, d => d);
144
+
145
+ row.exit().remove();
146
+
147
+ const rowMerge = row.enter().append("g").merge(row)
148
+ .attr("class", id => $HEATMAP.heatmapRow + $$.classTarget(id));
149
+
150
+ rowMerge.each(function(id) {
151
+ const g = d3Select(this);
152
+ const rowCells = byRow.get(id) as IHeatmapCell[];
153
+ const cell = g.selectAll<SVGRectElement, IHeatmapCell>(`.${$HEATMAP.heatmapCell}`)
154
+ .data(rowCells, d => d.index);
155
+
156
+ cell.exit().remove();
157
+
158
+ const cellMerge = cell.enter()
159
+ .append("rect")
160
+ .style("opacity", "0")
161
+ .merge(cell)
162
+ .attr("class",
163
+ d => `${$SHAPE.shape} ${$SHAPE.shape}-${d.index} ${$HEATMAP.heatmapCell}`)
164
+ .style("fill", d => d.color)
165
+ .style("stroke", <any>(borderWidth ? config.heatmap_cell_border_color : null))
166
+ .style("stroke-width", <any>(borderWidth ? `${borderWidth}px` : null))
167
+ .attr("rx", radius || null);
168
+
169
+ $$.$T(cellMerge, withTransition)
170
+ .attr("x", d => d.x0)
171
+ .attr("y", d => d.y0)
172
+ .attr("width", d => Math.max(0, d.x1 - d.x0))
173
+ .attr("height", d => Math.max(0, d.y1 - d.y0))
174
+ .style("opacity", null);
175
+
176
+ // the values in the cells
177
+ const label = g.selectAll<SVGTextElement, IHeatmapCell>(`.${$HEATMAP.heatmapLabel}`)
178
+ .data(config.heatmap_label_show ? rowCells.filter(d => d.value !== null) : [],
179
+ d => d.index);
180
+
181
+ label.exit().remove();
182
+ label.enter().append("text").merge(label)
183
+ .attr("class", $HEATMAP.heatmapLabel)
184
+ .attr("x", d => (d.x0 + d.x1) / 2)
185
+ .attr("y", d => (d.y0 + d.y1) / 2)
186
+ .attr("dy", ".35em")
187
+ .style("text-anchor", "middle")
188
+ .style("fill", d => $$.getHeatmapLabelColor(d))
189
+ .text(d => $$.getHeatmapLabel(d));
190
+ });
191
+
192
+ // the names of the columns and of the rows
193
+ const axis = heatmap.select(`.${$HEATMAP.heatmapNames}`)
194
+ .selectAll("text")
195
+ .data(axisX.concat(axisY), (d: IHeatmapText) => `${d.align}${d.text}`);
196
+
197
+ axis.exit().remove();
198
+ $$.setHeatmapText(axis.enter().append("text").merge(axis), withTransition);
199
+
200
+ // the color bar
201
+ const bar = heatmap.select(`.${$HEATMAP.heatmapColorbar}`);
202
+ const gradientId = `${state.datetimeId}-heatmap-colorbar`;
203
+
204
+ bar.selectAll("*").remove();
205
+ heatmap.select("defs").selectAll("*").remove();
206
+
207
+ if (colorbar) {
208
+ heatmap.select("defs")
209
+ .append("linearGradient")
210
+ .attr("id", gradientId)
211
+ .attr("x1", 0).attr("x2", colorbar.horizontal ? 1 : 0).attr("y1", 0).attr("y2",
212
+ colorbar.horizontal ? 0 : 1)
213
+ .selectAll("stop")
214
+ .data(colorbar.stops)
215
+ .enter()
216
+ .append("stop")
217
+ .attr("offset", d => d[0])
218
+ .attr("stop-color", d => d[1]);
219
+
220
+ bar.append("rect")
221
+ .attr("x", colorbar.x)
222
+ .attr("y", colorbar.y)
223
+ .attr("width", colorbar.width)
224
+ .attr("height", colorbar.height)
225
+ .style("fill", `url(#${gradientId})`);
226
+
227
+ $$.setHeatmapText(bar.selectAll("text").data(colorbar.labels).enter().append("text"));
228
+ }
229
+
230
+ $$.fitHeatmapHeight();
231
+
232
+ // the classes are set again above: keep the focus state over a redraw
233
+ heatmap.selectAll(`.${$HEATMAP.heatmapRow}`)
234
+ .classed($FOCUS.defocused, id => $$.isHeatmapDefocused(id as string));
235
+ }
236
+ };
@@ -17,6 +17,7 @@ import {
17
17
  setTextValue,
18
18
  toArray
19
19
  } from "../../module/util";
20
+ import type {IDataRow} from "../data/IData";
20
21
 
21
22
  /**
22
23
  * Get the position value
@@ -65,6 +66,16 @@ export default {
65
66
 
66
67
  current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
67
68
 
69
+ // points take clicks even when the axis text is hidden
70
+ config.interaction_enabled && $el.radar.shapes.on("click", event => {
71
+ const {target} = event;
72
+ const data = /^circle$/i.test(target.tagName) ?
73
+ d3Select(target).datum() as IDataRow :
74
+ null;
75
+
76
+ data?.id && config.data_onclick.bind($$.api)(data, target);
77
+ });
78
+
68
79
  if (config.radar_axis_text_show) {
69
80
  config.interaction_enabled && $$.bindRadarEvent();
70
81
 
@@ -374,7 +385,25 @@ export default {
374
385
  $$.selectRectForSingle(svg.node(), index);
375
386
  isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
376
387
  }, isMouse ? undefined : {passive: true})
377
- .on("mouseout", isMouse ? hide : null);
388
+ .on("mouseout", isMouse ? hide : null)
389
+ // an axis text stands for its index, like the tooltip it shows: every row at it
390
+ .on("click", event => {
391
+ const index = $$.getDataIndexFromEvent(event);
392
+
393
+ if (isUndefined(index)) {
394
+ return;
395
+ }
396
+
397
+ const target = /tspan/i.test(event.target.tagName) ?
398
+ event.target.parentNode :
399
+ event.target;
400
+
401
+ $$.filterTargetsToShow($$.data.targets).forEach(t => {
402
+ const data = $$.getValueOnIndex(t.values, index);
403
+
404
+ data && config.data_onclick.bind($$.api)(data, target);
405
+ });
406
+ });
378
407
 
379
408
  if (!isMouse) {
380
409
  svg.on("touchstart", hide, {passive: true});
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {select as d3Select} from "d3-selection";
6
+ import {$COMMON, $FOCUS, $SHAPE} from "../../config/classes";
7
+ import shapeSankeyCommon, {$SANKEY, type ISankeyLink, type ISankeyNode} from "./core/sankey";
8
+
9
+ export default {
10
+ ...shapeSankeyCommon,
11
+
12
+ /**
13
+ * Initialize sankey
14
+ * @private
15
+ */
16
+ initSankey(): void {
17
+ const $$ = this;
18
+ const {$el} = $$;
19
+
20
+ $el.sankey = $el.main.select(`.${$COMMON.chart}`)
21
+ .append("g")
22
+ .classed($SANKEY.chartSankey, true);
23
+
24
+ // the gradients of the links, for sankey.link.color="gradient"
25
+ $el.sankey.append("defs");
26
+
27
+ // the links are under the nodes
28
+ $el.sankey.append("g").classed($SANKEY.sankeyLinks, true);
29
+ $el.sankey.append("g").classed($SANKEY.sankeyNodes, true);
30
+
31
+ $$.bindSankeyEvent();
32
+ },
33
+
34
+ /**
35
+ * Bind events
36
+ * @private
37
+ */
38
+ bindSankeyEvent(): void {
39
+ const $$ = this;
40
+ const {$el: {sankey}, config, state} = $$;
41
+
42
+ if (!config.interaction_enabled) {
43
+ return;
44
+ }
45
+
46
+ const getTarget = event => {
47
+ // events emulated by the tooltip API are dispatched on the group itself
48
+ const target = event.target === sankey.node() ?
49
+ state.eventReceiver.rect?.node?.() :
50
+ event.target;
51
+
52
+ if (target && /^(rect|path)$/i.test(target.tagName)) {
53
+ const datum: any = d3Select(target).datum();
54
+
55
+ if (datum?.sourceLinks) {
56
+ state.event = event;
57
+ return $$.getSankeyNodeData(datum);
58
+ } else if (datum?.source) {
59
+ state.event = event;
60
+ return $$.getSankeyLinkData(datum);
61
+ }
62
+ }
63
+ };
64
+
65
+ const isTouch = state.inputType === "touch";
66
+
67
+ sankey
68
+ .on(isTouch ? "touchstart" : "mouseover mousemove", event => {
69
+ const data = getTarget(event);
70
+
71
+ if (data) {
72
+ $$.showTooltip([data], $$.$el.svg.node());
73
+ /^(touchstart|mouseover)$/.test(event.type) &&
74
+ $$.setOverOut(true, data, event.target);
75
+ }
76
+ }, isTouch ? {passive: true} : undefined)
77
+ .on(isTouch ? "touchend" : "mouseout", event => {
78
+ const data = getTarget(event);
79
+
80
+ if (config.interaction_onout) {
81
+ $$.hideTooltip();
82
+ $$.setOverOut(false, data, event.target);
83
+ }
84
+ })
85
+ .on("click", event => {
86
+ const data = getTarget(event);
87
+
88
+ data && config.data_onclick.bind($$.api)(data, event.target);
89
+ });
90
+ },
91
+
92
+ /**
93
+ * Update targets for sankey.
94
+ * The nodes and the links are made from all the series together, on redraw.
95
+ * @private
96
+ */
97
+ updateTargetsForSankey(): void {
98
+ const $$ = this;
99
+
100
+ !$$.$el.sankey && $$.initSankey();
101
+ },
102
+
103
+ /**
104
+ * Set the defocused class of the links and the nodes, from the focus state.
105
+ * @private
106
+ */
107
+ updateSankeyFocus(): void {
108
+ const $$ = this;
109
+ const isDefocused = d => $$.isSankeyDefocused(d);
110
+
111
+ $$.$el.sankey?.selectAll(`.${$SANKEY.sankeyLink}, .${$SANKEY.sankeyNode}`)
112
+ .classed($FOCUS.defocused, isDefocused);
113
+ },
114
+
115
+ /**
116
+ * Render sankey
117
+ * @param {boolean} withTransition Whether to transit
118
+ * @private
119
+ */
120
+ redrawSankey(withTransition?: boolean): void {
121
+ const $$ = this;
122
+ const {$el: {sankey}, config, state} = $$;
123
+ const {nodes, links} = $$.getSankeyLayout();
124
+ const rotated = config.sankey_rotated;
125
+ const borderWidth = config.sankey_node_border_width;
126
+ const linkKey = (d: ISankeyLink) => `${d.source.id}\u0000${d.target.id}\u0000${d.index}`;
127
+ const nodeKey = (d: ISankeyNode) => d.id;
128
+ const gradientId = (d: ISankeyLink) => `${state.datetimeId}-sankey-link-${d.index}`;
129
+
130
+ // sankey.link.opacity: the stylesheet reads it, and keeps the hover highlight over it
131
+ sankey.style("--bb-sankey-link-opacity", config.sankey_link_opacity ?? null);
132
+
133
+ // links
134
+ const link = sankey.select(`.${$SANKEY.sankeyLinks}`)
135
+ .selectAll(`.${$SANKEY.sankeyLink}`)
136
+ .data(links, linkKey);
137
+
138
+ link.exit().remove();
139
+
140
+ const linkMerge = link.enter()
141
+ .append("path")
142
+ .style("opacity", "0")
143
+ .merge(link)
144
+ .attr("class", d => $$.generateClass($SANKEY.sankeyLink, d.source.id))
145
+ .style("stroke", d => {
146
+ const [start, end] = $$.getSankeyLinkColors(d);
147
+
148
+ return start === end ? start : `url(#${gradientId(d)})`;
149
+ });
150
+
151
+ // a gradient along the flow for each link painted with two colors
152
+ const gradient = sankey.select("defs")
153
+ .selectAll("linearGradient")
154
+ .data(links.filter(d => {
155
+ const [start, end] = $$.getSankeyLinkColors(d);
156
+
157
+ return start !== end;
158
+ }));
159
+
160
+ gradient.exit().remove();
161
+
162
+ gradient.enter()
163
+ .append("linearGradient")
164
+ .attr("gradientUnits", "userSpaceOnUse")
165
+ .call(g => {
166
+ g.append("stop").attr("offset", "0");
167
+ g.append("stop").attr("offset", "1");
168
+ })
169
+ .merge(gradient)
170
+ .attr("id", d => gradientId(d))
171
+ .each(function(d) {
172
+ const [[start], , , [end]] = $$.getSankeyLinkPoints(d, true);
173
+ const [along, across] = rotated ? ["y", "x"] : ["x", "y"];
174
+ const colors = $$.getSankeyLinkColors(d);
175
+
176
+ d3Select(this)
177
+ .attr(`${along}1`, start)
178
+ .attr(`${along}2`, end)
179
+ .attr(`${across}1`, 0)
180
+ .attr(`${across}2`, 0)
181
+ .selectAll("stop")
182
+ .attr("stop-color", (_, j) => colors[j]);
183
+ });
184
+
185
+ $$.$T(linkMerge, withTransition)
186
+ .attr("d", d => $$.getSankeyLinkPath(d))
187
+ .style("stroke-width", d => `${Math.max(1, d.width)}px`)
188
+ .style("opacity", null);
189
+
190
+ // nodes, and their names
191
+ const node = sankey.select(`.${$SANKEY.sankeyNodes}`)
192
+ .selectAll(`.${$SANKEY.sankeyNode}`)
193
+ .data(nodes, nodeKey);
194
+
195
+ node.exit().remove();
196
+
197
+ const nodeEnter = node.enter().append("g");
198
+
199
+ nodeEnter.append("rect").attr("class", $SHAPE.shape);
200
+ nodeEnter.append("text").attr("class", $SANKEY.sankeyLabel);
201
+
202
+ // the target class of the node id: show(), hide(), focus() and tooltip.show() find it so
203
+ const nodeMerge = nodeEnter.merge(node)
204
+ .attr("class", d => $SANKEY.sankeyNode + $$.classTarget(d.id));
205
+
206
+ nodeMerge.select("rect")
207
+ .datum(d => d)
208
+ .style("fill", d => d.color)
209
+ .style("stroke", borderWidth ? config.sankey_node_border_color : null)
210
+ .style("stroke-width", borderWidth ? `${borderWidth}px` : null)
211
+ .call(sel => {
212
+ $$.$T(sel, withTransition)
213
+ .attr("x", d => d.x0)
214
+ .attr("y", d => d.y0)
215
+ .attr("width", d => Math.max(1, d.x1 - d.x0))
216
+ .attr("height", d => Math.max(1, d.y1 - d.y0));
217
+ });
218
+
219
+ nodeMerge.select("text")
220
+ .datum(d => d)
221
+ .each(function(d: ISankeyNode) {
222
+ const label = $$.getSankeyLabel(d);
223
+ const text = d3Select(this);
224
+
225
+ if (label) {
226
+ text.text(label.text)
227
+ .attr("dy", {middle: ".35em", top: ".71em", bottom: "0"}[label.baseline])
228
+ .style("text-anchor",
229
+ {left: "start", right: "end", center: "middle"}[label.align]);
230
+
231
+ $$.$T(text, withTransition)
232
+ .attr("x", label.x)
233
+ .attr("y", label.y);
234
+ } else {
235
+ text.text(null);
236
+ }
237
+ });
238
+
239
+ // the classes are set again above: keep the focus state over a redraw
240
+ $$.updateSankeyFocus();
241
+ }
242
+ };
@@ -311,7 +311,7 @@ export default {
311
311
  const {hasRadar, hasTreemap} = $$.state;
312
312
  const shape = {type: <TShape>{}, indices: <TShape>{}, pos: {}};
313
313
 
314
- !hasTreemap && ["bar", "candlestick", "line", "area"].forEach(v => {
314
+ !hasTreemap && ["bar", "candlestick", "line", "area", ...$$.getAxisTypes()].forEach(v => {
315
315
  const name = capitalize(v);
316
316
 
317
317
  if (
@@ -102,6 +102,16 @@ export default {
102
102
  $$.hideTooltip();
103
103
  $$.setOverOut(false, data);
104
104
  }
105
+ })
106
+ // use the clicked tile itself: getTarget() takes the tooltip API's receiver
107
+ // for an untrusted event
108
+ .on("click", event => {
109
+ const {target} = event;
110
+ const data = /^rect$/i.test(target.tagName) ?
111
+ (d3Select(target).datum() as {data?: IDataRow})?.data :
112
+ null;
113
+
114
+ data && config.data_onclick.bind($$.api)(data, target);
105
115
  });
106
116
  }
107
117
  },
@@ -12,33 +12,6 @@ import Elements from "./Elements";
12
12
  import Options from "./Options";
13
13
  import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
14
14
 
15
- /**
16
- * HSL color object compatible with d3-interpolate
17
- */
18
- interface HSLColor {
19
- h: number;
20
- s: number;
21
- l: number;
22
- opacity: number;
23
- }
24
-
25
- /**
26
- * Creates an HSL color object.
27
- * @param {number} h Hue (0-360)
28
- * @param {number} s Saturation (0-1)
29
- * @param {number} l Lightness (0-1)
30
- * @param {number} opacity Opacity (0-1), defaults to 1
31
- * @returns {HSLColor} HSL color object
32
- */
33
- function hsl(h: number, s: number, l: number, opacity: number = 1): HSLColor {
34
- return {
35
- h: +h,
36
- s: +s,
37
- l: +l,
38
- opacity: +opacity
39
- };
40
- }
41
-
42
15
  /**
43
16
  * Stanford diagram plugin
44
17
  * - **NOTE:**
@@ -216,7 +189,7 @@ export default class Stanford extends Plugin {
216
189
 
217
190
  target.colors = isFunction(config.colors) ?
218
191
  config.colors :
219
- d3InterpolateHslLong(hsl(250, 1, 0.5), hsl(0, 1, 0.5));
192
+ d3InterpolateHslLong("hsl(250, 100%, 50%)", "hsl(0, 100%, 50%)");
220
193
 
221
194
  target.colorscale = d3ScaleSequentialLog(target.colors)
222
195
  .domain([target.minEpochs, target.maxEpochs]);