@d3plus/core 3.1.6 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. package/README.md +9924 -78528
  2. package/es/index.js +8 -0
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +54 -0
  5. package/es/internal.js.map +1 -0
  6. package/es/src/charts/AreaPlot/index.js +36 -0
  7. package/es/src/charts/AreaPlot/index.js.map +1 -0
  8. package/es/src/charts/BarChart/index.js +48 -0
  9. package/es/src/charts/BarChart/index.js.map +1 -0
  10. package/es/src/charts/BoxWhisker/index.js +52 -0
  11. package/es/src/charts/BoxWhisker/index.js.map +1 -0
  12. package/es/src/charts/BumpChart/index.js +81 -0
  13. package/es/src/charts/BumpChart/index.js.map +1 -0
  14. package/es/src/charts/Donut/index.js +42 -0
  15. package/es/src/charts/Donut/index.js.map +1 -0
  16. package/es/src/charts/Geomap/applyLayout.js +208 -0
  17. package/es/src/charts/Geomap/applyLayout.js.map +1 -0
  18. package/es/src/charts/Geomap/emit.js +169 -0
  19. package/es/src/charts/Geomap/emit.js.map +1 -0
  20. package/es/src/charts/Geomap/index.js +521 -0
  21. package/es/src/charts/Geomap/index.js.map +1 -0
  22. package/es/src/charts/LinePlot/index.js +32 -0
  23. package/es/src/charts/LinePlot/index.js.map +1 -0
  24. package/es/src/charts/Matrix/applyLayout.js +92 -0
  25. package/es/src/charts/Matrix/applyLayout.js.map +1 -0
  26. package/es/src/charts/Matrix/emit.js +44 -0
  27. package/es/src/charts/Matrix/emit.js.map +1 -0
  28. package/es/src/charts/Matrix/index.js +154 -0
  29. package/es/src/charts/Matrix/index.js.map +1 -0
  30. package/es/src/charts/Network/applyLayout.js +322 -0
  31. package/es/src/charts/Network/applyLayout.js.map +1 -0
  32. package/es/src/charts/Network/emit.js +273 -0
  33. package/es/src/charts/Network/emit.js.map +1 -0
  34. package/es/src/charts/Network/index.js +422 -0
  35. package/es/src/charts/Network/index.js.map +1 -0
  36. package/es/src/charts/Pack/applyLayout.js +46 -0
  37. package/es/src/charts/Pack/applyLayout.js.map +1 -0
  38. package/es/src/charts/Pack/emit.js +116 -0
  39. package/es/src/charts/Pack/emit.js.map +1 -0
  40. package/es/src/charts/Pack/index.js +194 -0
  41. package/es/src/charts/Pack/index.js.map +1 -0
  42. package/es/src/charts/Pack/recursionCircles.js +18 -0
  43. package/es/src/charts/Pack/recursionCircles.js.map +1 -0
  44. package/es/src/charts/Pie/applyLayout.js +44 -0
  45. package/es/src/charts/Pie/applyLayout.js.map +1 -0
  46. package/es/src/charts/Pie/emit.js +111 -0
  47. package/es/src/charts/Pie/emit.js.map +1 -0
  48. package/es/src/charts/Pie/index.js +134 -0
  49. package/es/src/charts/Pie/index.js.map +1 -0
  50. package/es/src/charts/Plot/draw.js +424 -0
  51. package/es/src/charts/Plot/draw.js.map +1 -0
  52. package/es/src/charts/Plot/index.js +827 -0
  53. package/es/src/charts/Plot/index.js.map +1 -0
  54. package/es/src/charts/Plot/labelPlacement.js +36 -0
  55. package/es/src/charts/Plot/labelPlacement.js.map +1 -0
  56. package/es/src/charts/Plot/pipeline.js +594 -0
  57. package/es/src/charts/Plot/pipeline.js.map +1 -0
  58. package/es/src/charts/Plot/pipelineDomains.js +254 -0
  59. package/es/src/charts/Plot/pipelineDomains.js.map +1 -0
  60. package/es/src/charts/Plot/pipelineLineLabels.js +210 -0
  61. package/es/src/charts/Plot/pipelineLineLabels.js.map +1 -0
  62. package/es/src/charts/Plot/shapeDefaults.js +189 -0
  63. package/es/src/charts/Plot/shapeDefaults.js.map +1 -0
  64. package/es/src/charts/Plot/stackHelpers.js +52 -0
  65. package/es/src/charts/Plot/stackHelpers.js.map +1 -0
  66. package/es/src/charts/Priestley/applyLayout.js +121 -0
  67. package/es/src/charts/Priestley/applyLayout.js.map +1 -0
  68. package/es/src/charts/Priestley/emit.js +129 -0
  69. package/es/src/charts/Priestley/emit.js.map +1 -0
  70. package/es/src/charts/Priestley/index.js +97 -0
  71. package/es/src/charts/Priestley/index.js.map +1 -0
  72. package/es/src/charts/Radar/applyLayout.js +326 -0
  73. package/es/src/charts/Radar/applyLayout.js.map +1 -0
  74. package/es/src/charts/Radar/emit.js +28 -0
  75. package/es/src/charts/Radar/emit.js.map +1 -0
  76. package/es/src/charts/Radar/index.js +98 -0
  77. package/es/src/charts/Radar/index.js.map +1 -0
  78. package/es/src/charts/RadialMatrix/applyLayout.js +132 -0
  79. package/es/src/charts/RadialMatrix/applyLayout.js.map +1 -0
  80. package/es/src/charts/RadialMatrix/emit.js +33 -0
  81. package/es/src/charts/RadialMatrix/emit.js.map +1 -0
  82. package/es/src/charts/RadialMatrix/index.js +144 -0
  83. package/es/src/charts/RadialMatrix/index.js.map +1 -0
  84. package/es/src/charts/Rings/applyLayout.js +508 -0
  85. package/es/src/charts/Rings/applyLayout.js.map +1 -0
  86. package/es/src/charts/Rings/emit.js +222 -0
  87. package/es/src/charts/Rings/emit.js.map +1 -0
  88. package/es/src/charts/Rings/index.js +245 -0
  89. package/es/src/charts/Rings/index.js.map +1 -0
  90. package/es/src/charts/Sankey/applyLayout.js +107 -0
  91. package/es/src/charts/Sankey/applyLayout.js.map +1 -0
  92. package/es/src/charts/Sankey/emit.js +134 -0
  93. package/es/src/charts/Sankey/emit.js.map +1 -0
  94. package/es/src/charts/Sankey/index.js +219 -0
  95. package/es/src/charts/Sankey/index.js.map +1 -0
  96. package/es/src/charts/StackedArea/index.js +27 -0
  97. package/es/src/charts/StackedArea/index.js.map +1 -0
  98. package/es/src/charts/Tree/applyLayout.js +233 -0
  99. package/es/src/charts/Tree/applyLayout.js.map +1 -0
  100. package/es/src/charts/Tree/emit.js +257 -0
  101. package/es/src/charts/Tree/emit.js.map +1 -0
  102. package/es/src/charts/Tree/index.js +105 -0
  103. package/es/src/charts/Tree/index.js.map +1 -0
  104. package/es/src/charts/Treemap/applyLayout.js +85 -0
  105. package/es/src/charts/Treemap/applyLayout.js.map +1 -0
  106. package/es/src/charts/Treemap/emit.js +141 -0
  107. package/es/src/charts/Treemap/emit.js.map +1 -0
  108. package/es/src/charts/Treemap/index.js +177 -0
  109. package/es/src/charts/Treemap/index.js.map +1 -0
  110. package/es/src/charts/Treemap/thresholdFunction.js +112 -0
  111. package/es/src/charts/Treemap/thresholdFunction.js.map +1 -0
  112. package/es/src/charts/definition/ChartDefinition.js +12 -0
  113. package/es/src/charts/definition/ChartDefinition.js.map +1 -0
  114. package/es/src/charts/definition/applyDefinition.js +107 -0
  115. package/es/src/charts/definition/applyDefinition.js.map +1 -0
  116. package/es/src/charts/definition/makeChart.js +153 -0
  117. package/es/src/charts/definition/makeChart.js.map +1 -0
  118. package/es/src/charts/drawSteps/zoomControls.js +231 -96
  119. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  120. package/es/src/charts/events/click.legend.js +2 -2
  121. package/es/src/charts/events/click.legend.js.map +1 -1
  122. package/es/src/charts/events/click.shape.js +5 -5
  123. package/es/src/charts/events/click.shape.js.map +1 -1
  124. package/es/src/charts/events/mouseenter.js +20 -1
  125. package/es/src/charts/events/mouseenter.js.map +1 -1
  126. package/es/src/charts/events/mouseleave.js +19 -4
  127. package/es/src/charts/events/mouseleave.js.map +1 -1
  128. package/es/src/charts/events/mousemove.legend.js +10 -10
  129. package/es/src/charts/events/mousemove.legend.js.map +1 -1
  130. package/es/src/charts/events/mousemove.shape.js +14 -8
  131. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  132. package/es/src/charts/events/touchstart.body.js.map +1 -1
  133. package/es/src/charts/features/axes.js +432 -0
  134. package/es/src/charts/features/axes.js.map +1 -0
  135. package/es/src/charts/features/chartGeometry.js +66 -0
  136. package/es/src/charts/features/chartGeometry.js.map +1 -0
  137. package/es/src/charts/features/colorScaleBucket.js +92 -0
  138. package/es/src/charts/features/colorScaleBucket.js.map +1 -0
  139. package/es/src/charts/features/emitHelpers.js +217 -0
  140. package/es/src/charts/features/emitHelpers.js.map +1 -0
  141. package/es/src/charts/features/ensureZoomDom.js +71 -0
  142. package/es/src/charts/features/ensureZoomDom.js.map +1 -0
  143. package/es/src/charts/features/features.js +650 -0
  144. package/es/src/charts/features/features.js.map +1 -0
  145. package/es/src/charts/features/featuresLegend.js +180 -0
  146. package/es/src/charts/features/featuresLegend.js.map +1 -0
  147. package/es/src/charts/features/legendLabel.js +12 -0
  148. package/es/src/charts/features/legendLabel.js.map +1 -0
  149. package/es/src/charts/features/lineLabels.js +154 -0
  150. package/es/src/charts/features/lineLabels.js.map +1 -0
  151. package/es/src/charts/features/plotPaint.js +512 -0
  152. package/es/src/charts/features/plotPaint.js.map +1 -0
  153. package/es/src/charts/features/shapeEmit.js +273 -0
  154. package/es/src/charts/features/shapeEmit.js.map +1 -0
  155. package/es/src/charts/helpers/matrixData.js +3 -3
  156. package/es/src/charts/helpers/matrixData.js.map +1 -1
  157. package/es/src/charts/index.js +21 -21
  158. package/es/src/charts/index.js.map +1 -1
  159. package/es/src/charts/pipeline/resolveSpec.js +44 -0
  160. package/es/src/charts/pipeline/resolveSpec.js.map +1 -0
  161. package/es/src/charts/pipeline/runChartDraw.js +109 -0
  162. package/es/src/charts/pipeline/runChartDraw.js.map +1 -0
  163. package/es/src/charts/pipeline/runVizPipeline.js +84 -0
  164. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -0
  165. package/es/src/charts/pipeline/stages.js +103 -0
  166. package/es/src/charts/pipeline/stages.js.map +1 -0
  167. package/es/src/charts/pipeline/vizContext.js +29 -0
  168. package/es/src/charts/pipeline/vizContext.js.map +1 -0
  169. package/es/src/charts/pipeline/vizDraw.js +37 -0
  170. package/es/src/charts/pipeline/vizDraw.js.map +1 -0
  171. package/es/src/charts/pipeline/vizDrawPure.js +174 -0
  172. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -0
  173. package/es/src/charts/pipeline/vizPreDraw.js +145 -0
  174. package/es/src/charts/pipeline/vizPreDraw.js.map +1 -0
  175. package/es/src/charts/pipeline/vizPreDrawPure.js +279 -0
  176. package/es/src/charts/pipeline/vizPreDrawPure.js.map +1 -0
  177. package/es/src/charts/plotBuffers/Bar.js +4 -4
  178. package/es/src/charts/plotBuffers/Bar.js.map +1 -1
  179. package/es/src/charts/plotBuffers/Box.js +4 -4
  180. package/es/src/charts/plotBuffers/Box.js.map +1 -1
  181. package/es/src/charts/plotBuffers/Circle.js +2 -2
  182. package/es/src/charts/plotBuffers/Circle.js.map +1 -1
  183. package/es/src/charts/plotBuffers/Line.js +5 -5
  184. package/es/src/charts/plotBuffers/Line.js.map +1 -1
  185. package/es/src/charts/plotBuffers/Rect.js +2 -2
  186. package/es/src/charts/plotBuffers/Rect.js.map +1 -1
  187. package/es/src/charts/plotBuffers/discreteBuffer.js +1 -2
  188. package/es/src/charts/plotBuffers/discreteBuffer.js.map +1 -1
  189. package/es/src/charts/plotBuffers/numericBuffer.js +1 -2
  190. package/es/src/charts/plotBuffers/numericBuffer.js.map +1 -1
  191. package/es/src/charts/viz/Viz.js +985 -0
  192. package/es/src/charts/viz/Viz.js.map +1 -0
  193. package/es/src/charts/viz/VizBase.js +447 -0
  194. package/es/src/charts/viz/VizBase.js.map +1 -0
  195. package/es/src/charts/viz/VizBaseConfig.js +504 -0
  196. package/es/src/charts/viz/VizBaseConfig.js.map +1 -0
  197. package/es/src/charts/viz/interactionOpacity.js +247 -0
  198. package/es/src/charts/viz/interactionOpacity.js.map +1 -0
  199. package/es/src/charts/viz/ordinalColor.js +71 -0
  200. package/es/src/charts/viz/ordinalColor.js.map +1 -0
  201. package/es/src/charts/viz/trailCatchup.js +127 -0
  202. package/es/src/charts/viz/trailCatchup.js.map +1 -0
  203. package/es/src/charts/viz/vizDefaults.js +602 -0
  204. package/es/src/charts/viz/vizDefaults.js.map +1 -0
  205. package/es/src/charts/viz/vizRender.js +251 -0
  206. package/es/src/charts/viz/vizRender.js.map +1 -0
  207. package/es/src/charts/viz/vizTypes.js +28 -0
  208. package/es/src/charts/viz/vizTypes.js.map +1 -0
  209. package/es/src/components/Axis/Axis.js +691 -0
  210. package/es/src/components/Axis/Axis.js.map +1 -0
  211. package/es/src/components/Axis/AxisBottom.js.map +1 -0
  212. package/es/src/components/Axis/AxisLeft.js.map +1 -0
  213. package/es/src/components/Axis/AxisRight.js.map +1 -0
  214. package/es/src/components/Axis/AxisTop.js.map +1 -0
  215. package/es/src/components/Axis/axisLayout.js +208 -0
  216. package/es/src/components/Axis/axisLayout.js.map +1 -0
  217. package/es/src/components/Axis/axisLayoutLabels.js +177 -0
  218. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -0
  219. package/es/src/components/Axis/axisLayoutScale.js +374 -0
  220. package/es/src/components/Axis/axisLayoutScale.js.map +1 -0
  221. package/es/src/components/Axis/axisRender.js +535 -0
  222. package/es/src/components/Axis/axisRender.js.map +1 -0
  223. package/es/src/components/ColorScale/ColorScale.js +506 -0
  224. package/es/src/components/ColorScale/ColorScale.js.map +1 -0
  225. package/es/src/components/ColorScale/colorScaleRender.js +277 -0
  226. package/es/src/components/ColorScale/colorScaleRender.js.map +1 -0
  227. package/es/src/components/ColorScale/colorScaleScale.js +274 -0
  228. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -0
  229. package/es/src/components/Legend/Legend.js +445 -0
  230. package/es/src/components/Legend/Legend.js.map +1 -0
  231. package/es/src/components/Legend/legendConfig.js +87 -0
  232. package/es/src/components/Legend/legendConfig.js.map +1 -0
  233. package/es/src/components/Legend/legendRender.js +245 -0
  234. package/es/src/components/Legend/legendRender.js.map +1 -0
  235. package/es/src/components/Message.js.map +1 -1
  236. package/es/src/components/TextBox.js +655 -453
  237. package/es/src/components/TextBox.js.map +1 -1
  238. package/es/src/components/Timeline/Timeline.js +674 -0
  239. package/es/src/components/Timeline/Timeline.js.map +1 -0
  240. package/es/src/components/Timeline/timelineConfig.js +115 -0
  241. package/es/src/components/Timeline/timelineConfig.js.map +1 -0
  242. package/es/src/components/Timeline/timelineRender.js +267 -0
  243. package/es/src/components/Timeline/timelineRender.js.map +1 -0
  244. package/es/src/components/Tooltip.js +288 -249
  245. package/es/src/components/Tooltip.js.map +1 -1
  246. package/es/src/components/index.js +8 -8
  247. package/es/src/components/index.js.map +1 -1
  248. package/es/src/fluent.js +265 -0
  249. package/es/src/fluent.js.map +1 -0
  250. package/es/src/shapes/Area.js +96 -114
  251. package/es/src/shapes/Area.js.map +1 -1
  252. package/es/src/shapes/Bar.js +71 -86
  253. package/es/src/shapes/Bar.js.map +1 -1
  254. package/es/src/shapes/Box.js +295 -190
  255. package/es/src/shapes/Box.js.map +1 -1
  256. package/es/src/shapes/Circle.js +84 -35
  257. package/es/src/shapes/Circle.js.map +1 -1
  258. package/es/src/shapes/Image.js +164 -85
  259. package/es/src/shapes/Image.js.map +1 -1
  260. package/es/src/shapes/Line.js +51 -94
  261. package/es/src/shapes/Line.js.map +1 -1
  262. package/es/src/shapes/Path.js +33 -41
  263. package/es/src/shapes/Path.js.map +1 -1
  264. package/es/src/shapes/Rect.js +86 -37
  265. package/es/src/shapes/Rect.js.map +1 -1
  266. package/es/src/shapes/Shape.js +655 -678
  267. package/es/src/shapes/Shape.js.map +1 -1
  268. package/es/src/shapes/Whisker.js +156 -61
  269. package/es/src/shapes/Whisker.js.map +1 -1
  270. package/es/src/shapes/buildLabelData.js +125 -0
  271. package/es/src/shapes/buildLabelData.js.map +1 -0
  272. package/es/src/shapes/emitLabels.js +84 -0
  273. package/es/src/shapes/emitLabels.js.map +1 -0
  274. package/es/src/shapes/hitAreaNode.js +37 -0
  275. package/es/src/shapes/hitAreaNode.js.map +1 -0
  276. package/es/src/shapes/sceneSort.js +57 -0
  277. package/es/src/shapes/sceneSort.js.map +1 -0
  278. package/es/src/shapes/shapeConfig.js +31 -0
  279. package/es/src/shapes/shapeConfig.js.map +1 -0
  280. package/es/src/utils/BaseClass.js +35 -19
  281. package/es/src/utils/BaseClass.js.map +1 -1
  282. package/es/src/utils/D3Scale.js +16 -0
  283. package/es/src/utils/D3Scale.js.map +1 -0
  284. package/es/src/utils/D3plusConfig.js.map +1 -1
  285. package/es/src/utils/configPrep.js +8 -3
  286. package/es/src/utils/configPrep.js.map +1 -1
  287. package/es/src/utils/getProp.js +1 -1
  288. package/es/src/utils/getProp.js.map +1 -1
  289. package/es/src/utils/index.js +1 -0
  290. package/es/src/utils/index.js.map +1 -1
  291. package/es/src/utils/paintComponentScene.js +59 -0
  292. package/es/src/utils/paintComponentScene.js.map +1 -0
  293. package/es/umd-entry.js +16 -0
  294. package/es/umd-entry.js.map +1 -0
  295. package/package.json +15 -10
  296. package/types/index.d.ts +3 -1
  297. package/types/internal.d.ts +54 -0
  298. package/types/src/charts/AreaPlot/index.d.ts +10 -0
  299. package/types/src/charts/BarChart/index.d.ts +10 -0
  300. package/types/src/charts/BoxWhisker/index.d.ts +11 -0
  301. package/types/src/charts/BumpChart/index.d.ts +11 -0
  302. package/types/src/charts/ChartDefinition.d.ts +75 -0
  303. package/types/src/charts/Donut/index.d.ts +13 -0
  304. package/types/src/charts/Geomap/applyLayout.d.ts +7 -0
  305. package/types/src/charts/Geomap/emit.d.ts +7 -0
  306. package/types/src/charts/Geomap/index.d.ts +14 -0
  307. package/types/src/charts/Geomap.d.ts +6 -0
  308. package/types/src/charts/LinePlot/index.d.ts +10 -0
  309. package/types/src/charts/Matrix/applyLayout.d.ts +9 -0
  310. package/types/src/charts/Matrix/emit.d.ts +6 -0
  311. package/types/src/charts/Matrix/index.d.ts +14 -0
  312. package/types/src/charts/Matrix.d.ts +0 -26
  313. package/types/src/charts/Network/applyLayout.d.ts +10 -0
  314. package/types/src/charts/Network/emit.d.ts +6 -0
  315. package/types/src/charts/Network/index.d.ts +7 -0
  316. package/types/src/charts/Network.d.ts +0 -24
  317. package/types/src/charts/Pack/applyLayout.d.ts +16 -0
  318. package/types/src/charts/Pack/emit.d.ts +6 -0
  319. package/types/src/charts/Pack/index.d.ts +15 -0
  320. package/types/src/charts/Pack/recursionCircles.d.ts +7 -0
  321. package/types/src/charts/Pack.d.ts +0 -13
  322. package/types/src/charts/Pie/applyLayout.d.ts +8 -0
  323. package/types/src/charts/Pie/emit.d.ts +5 -0
  324. package/types/src/charts/Pie/index.d.ts +14 -0
  325. package/types/src/charts/Pie.d.ts +0 -27
  326. package/types/src/charts/Plot/draw.d.ts +2 -0
  327. package/types/src/charts/Plot/index.d.ts +167 -0
  328. package/types/src/charts/Plot/labelPlacement.d.ts +15 -0
  329. package/types/src/charts/Plot/pipeline.d.ts +70 -0
  330. package/types/src/charts/Plot/pipelineDomains.d.ts +2 -0
  331. package/types/src/charts/Plot/pipelineLineLabels.d.ts +2 -0
  332. package/types/src/charts/Plot/shapeDefaults.d.ts +64 -0
  333. package/types/src/charts/Plot/stackHelpers.d.ts +24 -0
  334. package/types/src/charts/Plot.d.ts +23 -72
  335. package/types/src/charts/Priestley/applyLayout.d.ts +21 -0
  336. package/types/src/charts/Priestley/emit.d.ts +6 -0
  337. package/types/src/charts/Priestley/index.d.ts +14 -0
  338. package/types/src/charts/Radar/applyLayout.d.ts +10 -0
  339. package/types/src/charts/Radar/emit.d.ts +7 -0
  340. package/types/src/charts/Radar/index.d.ts +14 -0
  341. package/types/src/charts/RadialMatrix/applyLayout.d.ts +11 -0
  342. package/types/src/charts/RadialMatrix/emit.d.ts +6 -0
  343. package/types/src/charts/RadialMatrix/index.d.ts +14 -0
  344. package/types/src/charts/RadialMatrix.d.ts +0 -15
  345. package/types/src/charts/Rings/applyLayout.d.ts +2 -0
  346. package/types/src/charts/Rings/emit.d.ts +7 -0
  347. package/types/src/charts/Rings/index.d.ts +15 -0
  348. package/types/src/charts/Rings.d.ts +0 -13
  349. package/types/src/charts/Sankey/applyLayout.d.ts +7 -0
  350. package/types/src/charts/Sankey/emit.d.ts +6 -0
  351. package/types/src/charts/Sankey/index.d.ts +7 -0
  352. package/types/src/charts/Sankey.d.ts +0 -4
  353. package/types/src/charts/StackedArea/index.d.ts +10 -0
  354. package/types/src/charts/Tree/applyLayout.d.ts +2 -0
  355. package/types/src/charts/Tree/emit.d.ts +7 -0
  356. package/types/src/charts/Tree/index.d.ts +14 -0
  357. package/types/src/charts/Tree.d.ts +0 -16
  358. package/types/src/charts/Treemap/applyLayout.d.ts +16 -0
  359. package/types/src/charts/Treemap/emit.d.ts +6 -0
  360. package/types/src/charts/Treemap/index.d.ts +18 -0
  361. package/types/src/charts/Treemap/thresholdFunction.d.ts +25 -0
  362. package/types/src/charts/Treemap.d.ts +4 -13
  363. package/types/src/charts/Viz.d.ts +49 -361
  364. package/types/src/charts/VizBase.d.ts +158 -0
  365. package/types/src/charts/VizBaseConfig.d.ts +148 -0
  366. package/types/src/charts/applyDefinition.d.ts +13 -0
  367. package/types/src/charts/axes.d.ts +134 -0
  368. package/types/src/charts/chartGeometry.d.ts +58 -0
  369. package/types/src/charts/definition/ChartDefinition.d.ts +84 -0
  370. package/types/src/charts/definition/applyDefinition.d.ts +13 -0
  371. package/types/src/charts/definition/makeChart.d.ts +22 -0
  372. package/types/src/charts/drawSteps/zoomControls.d.ts +25 -5
  373. package/types/src/charts/emitHelpers.d.ts +122 -0
  374. package/types/src/charts/ensureZoomDom.d.ts +39 -0
  375. package/types/src/charts/events/click.legend.d.ts +1 -1
  376. package/types/src/charts/events/click.shape.d.ts +1 -1
  377. package/types/src/charts/events/mouseenter.d.ts +1 -1
  378. package/types/src/charts/events/mouseleave.d.ts +1 -1
  379. package/types/src/charts/events/mousemove.legend.d.ts +1 -1
  380. package/types/src/charts/events/mousemove.shape.d.ts +1 -1
  381. package/types/src/charts/events/touchstart.body.d.ts +1 -1
  382. package/types/src/charts/factories.d.ts +73 -0
  383. package/types/src/charts/features/axes.d.ts +134 -0
  384. package/types/src/charts/features/chartGeometry.d.ts +58 -0
  385. package/types/src/charts/features/colorScaleBucket.d.ts +43 -0
  386. package/types/src/charts/features/colorScaleBucketShare.d.ts +16 -0
  387. package/types/src/charts/features/emitHelpers.d.ts +123 -0
  388. package/types/src/charts/features/ensureZoomDom.d.ts +39 -0
  389. package/types/src/charts/features/features.d.ts +152 -0
  390. package/types/src/charts/features/featuresLegend.d.ts +12 -0
  391. package/types/src/charts/features/legendLabel.d.ts +11 -0
  392. package/types/src/charts/features/lineLabels.d.ts +40 -0
  393. package/types/src/charts/features/plotPaint.d.ts +233 -0
  394. package/types/src/charts/features/shapeEmit.d.ts +61 -0
  395. package/types/src/charts/features.d.ts +152 -0
  396. package/types/src/charts/featuresLegend.d.ts +12 -0
  397. package/types/src/charts/helpers/matrixData.d.ts +1 -1
  398. package/types/src/charts/index.d.ts +21 -21
  399. package/types/src/charts/legendLabel.d.ts +11 -0
  400. package/types/src/charts/lineLabels.d.ts +40 -0
  401. package/types/src/charts/makeChart.d.ts +22 -0
  402. package/types/src/charts/pipeline/resolveSpec.d.ts +51 -0
  403. package/types/src/charts/pipeline/runChartDraw.d.ts +38 -0
  404. package/types/src/charts/pipeline/runVizPipeline.d.ts +31 -0
  405. package/types/src/charts/pipeline/stages.d.ts +160 -0
  406. package/types/src/charts/pipeline/vizContext.d.ts +45 -0
  407. package/types/src/charts/pipeline/vizDraw.d.ts +25 -0
  408. package/types/src/charts/pipeline/vizDrawPure.d.ts +46 -0
  409. package/types/src/charts/pipeline/vizPreDraw.d.ts +22 -0
  410. package/types/src/charts/pipeline/vizPreDrawPure.d.ts +68 -0
  411. package/types/src/charts/plotBuffers/Bar.d.ts +6 -5
  412. package/types/src/charts/plotBuffers/Box.d.ts +6 -5
  413. package/types/src/charts/plotBuffers/Circle.d.ts +6 -5
  414. package/types/src/charts/plotBuffers/Line.d.ts +6 -5
  415. package/types/src/charts/plotBuffers/Rect.d.ts +6 -5
  416. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +2 -1
  417. package/types/src/charts/plotBuffers/numericBuffer.d.ts +2 -1
  418. package/types/src/charts/plotPaint.d.ts +233 -0
  419. package/types/src/charts/resolveSpec.d.ts +50 -0
  420. package/types/src/charts/runChartDraw.d.ts +38 -0
  421. package/types/src/charts/runVizPipeline.d.ts +31 -0
  422. package/types/src/charts/shapeEmit.d.ts +61 -0
  423. package/types/src/charts/stages.d.ts +117 -0
  424. package/types/src/charts/viz/Viz.d.ts +111 -0
  425. package/types/src/charts/viz/VizBase.d.ts +160 -0
  426. package/types/src/charts/viz/VizBaseConfig.d.ts +157 -0
  427. package/types/src/charts/viz/interactionOpacity.d.ts +23 -0
  428. package/types/src/charts/viz/ordinalColor.d.ts +14 -0
  429. package/types/src/charts/viz/trailCatchup.d.ts +14 -0
  430. package/types/src/charts/viz/vizDefaults.d.ts +8 -0
  431. package/types/src/charts/viz/vizRender.d.ts +8 -0
  432. package/types/src/charts/viz/vizTypes.d.ts +250 -0
  433. package/types/src/charts/vizContext.d.ts +46 -0
  434. package/types/src/charts/vizDefaults.d.ts +8 -0
  435. package/types/src/charts/vizDraw.d.ts +25 -0
  436. package/types/src/charts/vizDrawPure.d.ts +17 -0
  437. package/types/src/charts/vizPreDraw.d.ts +22 -0
  438. package/types/src/charts/vizPreDrawPure.d.ts +40 -0
  439. package/types/src/charts/vizRender.d.ts +8 -0
  440. package/types/src/charts/vizTypes.d.ts +202 -0
  441. package/types/src/components/Axis/Axis.d.ts +182 -0
  442. package/types/src/components/Axis/AxisBottom.d.ts +11 -0
  443. package/types/src/components/Axis/AxisLeft.d.ts +11 -0
  444. package/types/src/components/Axis/AxisRight.d.ts +11 -0
  445. package/types/src/components/Axis/AxisTop.d.ts +11 -0
  446. package/types/src/components/Axis/axisLayout.d.ts +29 -0
  447. package/types/src/components/Axis/axisLayoutLabels.d.ts +70 -0
  448. package/types/src/components/Axis/axisLayoutScale.d.ts +14 -0
  449. package/types/src/components/Axis/axisRender.d.ts +68 -0
  450. package/types/src/components/Axis.d.ts +68 -194
  451. package/types/src/components/ColorScale/ColorScale.d.ts +100 -0
  452. package/types/src/components/ColorScale/colorScaleRender.d.ts +15 -0
  453. package/types/src/components/ColorScale/colorScaleScale.d.ts +19 -0
  454. package/types/src/components/ColorScale.d.ts +1 -129
  455. package/types/src/components/Legend/Legend.d.ts +95 -0
  456. package/types/src/components/Legend/legendConfig.d.ts +7 -0
  457. package/types/src/components/Legend/legendRender.d.ts +16 -0
  458. package/types/src/components/Legend.d.ts +9 -73
  459. package/types/src/components/TextBox.d.ts +25 -218
  460. package/types/src/components/Timeline/Timeline.d.ts +118 -0
  461. package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
  462. package/types/src/components/Timeline/timelineRender.d.ts +24 -0
  463. package/types/src/components/Timeline.d.ts +7 -81
  464. package/types/src/components/Tooltip.d.ts +20 -200
  465. package/types/src/components/axisLayout.d.ts +27 -0
  466. package/types/src/components/axisLayoutLabels.d.ts +42 -0
  467. package/types/src/components/axisLayoutScale.d.ts +12 -0
  468. package/types/src/components/axisRender.d.ts +65 -0
  469. package/types/src/components/colorScaleRender.d.ts +15 -0
  470. package/types/src/components/colorScaleScale.d.ts +19 -0
  471. package/types/src/components/index.d.ts +8 -8
  472. package/types/src/components/legendConfig.d.ts +7 -0
  473. package/types/src/components/legendRender.d.ts +16 -0
  474. package/types/src/components/timelineConfig.d.ts +6 -0
  475. package/types/src/components/timelineRender.d.ts +14 -0
  476. package/types/src/fluent.d.ts +94 -0
  477. package/types/src/shapes/Area.d.ts +15 -27
  478. package/types/src/shapes/Bar.d.ts +13 -33
  479. package/types/src/shapes/Box.d.ts +17 -56
  480. package/types/src/shapes/Circle.d.ts +11 -17
  481. package/types/src/shapes/Image.d.ts +18 -84
  482. package/types/src/shapes/Line.d.ts +12 -22
  483. package/types/src/shapes/Path.d.ts +12 -19
  484. package/types/src/shapes/Rect.d.ts +11 -27
  485. package/types/src/shapes/Shape.d.ts +46 -257
  486. package/types/src/shapes/Whisker.d.ts +15 -42
  487. package/types/src/shapes/buildLabelData.d.ts +50 -0
  488. package/types/src/shapes/emitLabels.d.ts +16 -0
  489. package/types/src/shapes/hitAreaNode.d.ts +19 -0
  490. package/types/src/shapes/sceneSort.d.ts +20 -0
  491. package/types/src/shapes/shapeConfig.d.ts +226 -0
  492. package/types/src/utils/BaseClass.d.ts +13 -7
  493. package/types/src/utils/D3Scale.d.ts +48 -0
  494. package/types/src/utils/D3plusConfig.d.ts +270 -15
  495. package/types/src/utils/configPrep.d.ts +7 -4
  496. package/types/src/utils/getProp.d.ts +3 -1
  497. package/types/src/utils/index.d.ts +3 -1
  498. package/types/src/utils/paintComponentScene.d.ts +28 -0
  499. package/types/umd-entry.d.ts +15 -0
  500. package/umd/d3plus-core.full.js +30966 -19051
  501. package/umd/d3plus-core.full.js.map +1 -1
  502. package/umd/d3plus-core.full.min.js +5400 -2949
  503. package/umd/d3plus-core.js +17364 -10534
  504. package/umd/d3plus-core.js.map +1 -1
  505. package/umd/d3plus-core.min.js +3494 -1877
  506. package/es/src/charts/AreaPlot.js +0 -85
  507. package/es/src/charts/AreaPlot.js.map +0 -1
  508. package/es/src/charts/BarChart.js +0 -92
  509. package/es/src/charts/BarChart.js.map +0 -1
  510. package/es/src/charts/BoxWhisker.js +0 -92
  511. package/es/src/charts/BoxWhisker.js.map +0 -1
  512. package/es/src/charts/BumpChart.js +0 -147
  513. package/es/src/charts/BumpChart.js.map +0 -1
  514. package/es/src/charts/Donut.js +0 -84
  515. package/es/src/charts/Donut.js.map +0 -1
  516. package/es/src/charts/Geomap.js +0 -766
  517. package/es/src/charts/Geomap.js.map +0 -1
  518. package/es/src/charts/LinePlot.js +0 -83
  519. package/es/src/charts/LinePlot.js.map +0 -1
  520. package/es/src/charts/Matrix.js +0 -341
  521. package/es/src/charts/Matrix.js.map +0 -1
  522. package/es/src/charts/Network.js +0 -796
  523. package/es/src/charts/Network.js.map +0 -1
  524. package/es/src/charts/Pack.js +0 -308
  525. package/es/src/charts/Pack.js.map +0 -1
  526. package/es/src/charts/Pie.js +0 -232
  527. package/es/src/charts/Pie.js.map +0 -1
  528. package/es/src/charts/Plot.js +0 -2114
  529. package/es/src/charts/Plot.js.map +0 -1
  530. package/es/src/charts/Priestley.js +0 -296
  531. package/es/src/charts/Priestley.js.map +0 -1
  532. package/es/src/charts/Radar.js +0 -420
  533. package/es/src/charts/Radar.js.map +0 -1
  534. package/es/src/charts/RadialMatrix.js +0 -383
  535. package/es/src/charts/RadialMatrix.js.map +0 -1
  536. package/es/src/charts/Rings.js +0 -788
  537. package/es/src/charts/Rings.js.map +0 -1
  538. package/es/src/charts/Sankey.js +0 -461
  539. package/es/src/charts/Sankey.js.map +0 -1
  540. package/es/src/charts/StackedArea.js +0 -80
  541. package/es/src/charts/StackedArea.js.map +0 -1
  542. package/es/src/charts/Tree.js +0 -347
  543. package/es/src/charts/Tree.js.map +0 -1
  544. package/es/src/charts/Treemap.js +0 -454
  545. package/es/src/charts/Treemap.js.map +0 -1
  546. package/es/src/charts/Viz.js +0 -1832
  547. package/es/src/charts/Viz.js.map +0 -1
  548. package/es/src/charts/drawSteps/drawAttribution.js +0 -16
  549. package/es/src/charts/drawSteps/drawAttribution.js.map +0 -1
  550. package/es/src/charts/drawSteps/drawBack.js +0 -24
  551. package/es/src/charts/drawSteps/drawBack.js.map +0 -1
  552. package/es/src/charts/drawSteps/drawColorScale.js +0 -75
  553. package/es/src/charts/drawSteps/drawColorScale.js.map +0 -1
  554. package/es/src/charts/drawSteps/drawLegend.js +0 -122
  555. package/es/src/charts/drawSteps/drawLegend.js.map +0 -1
  556. package/es/src/charts/drawSteps/drawSubtitle.js +0 -31
  557. package/es/src/charts/drawSteps/drawSubtitle.js.map +0 -1
  558. package/es/src/charts/drawSteps/drawTimeline.js +0 -85
  559. package/es/src/charts/drawSteps/drawTimeline.js.map +0 -1
  560. package/es/src/charts/drawSteps/drawTitle.js +0 -31
  561. package/es/src/charts/drawSteps/drawTitle.js.map +0 -1
  562. package/es/src/charts/drawSteps/drawTotal.js +0 -32
  563. package/es/src/charts/drawSteps/drawTotal.js.map +0 -1
  564. package/es/src/components/Axis.js +0 -1457
  565. package/es/src/components/Axis.js.map +0 -1
  566. package/es/src/components/AxisBottom.js.map +0 -1
  567. package/es/src/components/AxisLeft.js.map +0 -1
  568. package/es/src/components/AxisRight.js.map +0 -1
  569. package/es/src/components/AxisTop.js.map +0 -1
  570. package/es/src/components/ColorScale.js +0 -843
  571. package/es/src/components/ColorScale.js.map +0 -1
  572. package/es/src/components/Legend.js +0 -622
  573. package/es/src/components/Legend.js.map +0 -1
  574. package/es/src/components/Timeline.js +0 -695
  575. package/es/src/components/Timeline.js.map +0 -1
  576. /package/es/src/components/{AxisBottom.js → Axis/AxisBottom.js} +0 -0
  577. /package/es/src/components/{AxisLeft.js → Axis/AxisLeft.js} +0 -0
  578. /package/es/src/components/{AxisRight.js → Axis/AxisRight.js} +0 -0
  579. /package/es/src/components/{AxisTop.js → Axis/AxisTop.js} +0 -0
@@ -1,1832 +0,0 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_with_holes(arr) {
7
- if (Array.isArray(arr)) return arr;
8
- }
9
- function _array_without_holes(arr) {
10
- if (Array.isArray(arr)) return _array_like_to_array(arr);
11
- }
12
- function _assert_this_initialized(self) {
13
- if (self === void 0) {
14
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
15
- }
16
- return self;
17
- }
18
- function _call_super(_this, derived, args) {
19
- derived = _get_prototype_of(derived);
20
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
21
- }
22
- function _class_call_check(instance, Constructor) {
23
- if (!(instance instanceof Constructor)) {
24
- throw new TypeError("Cannot call a class as a function");
25
- }
26
- }
27
- function _defineProperties(target, props) {
28
- for(var i = 0; i < props.length; i++){
29
- var descriptor = props[i];
30
- descriptor.enumerable = descriptor.enumerable || false;
31
- descriptor.configurable = true;
32
- if ("value" in descriptor) descriptor.writable = true;
33
- Object.defineProperty(target, descriptor.key, descriptor);
34
- }
35
- }
36
- function _create_class(Constructor, protoProps, staticProps) {
37
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
38
- if (staticProps) _defineProperties(Constructor, staticProps);
39
- return Constructor;
40
- }
41
- function _define_property(obj, key, value) {
42
- if (key in obj) {
43
- Object.defineProperty(obj, key, {
44
- value: value,
45
- enumerable: true,
46
- configurable: true,
47
- writable: true
48
- });
49
- } else {
50
- obj[key] = value;
51
- }
52
- return obj;
53
- }
54
- function _get_prototype_of(o) {
55
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
56
- return o.__proto__ || Object.getPrototypeOf(o);
57
- };
58
- return _get_prototype_of(o);
59
- }
60
- function _inherits(subClass, superClass) {
61
- if (typeof superClass !== "function" && superClass !== null) {
62
- throw new TypeError("Super expression must either be null or a function");
63
- }
64
- subClass.prototype = Object.create(superClass && superClass.prototype, {
65
- constructor: {
66
- value: subClass,
67
- writable: true,
68
- configurable: true
69
- }
70
- });
71
- if (superClass) _set_prototype_of(subClass, superClass);
72
- }
73
- function _instanceof(left, right) {
74
- "@swc/helpers - instanceof";
75
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
76
- return !!right[Symbol.hasInstance](left);
77
- } else {
78
- return left instanceof right;
79
- }
80
- }
81
- function _iterable_to_array(iter) {
82
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
83
- }
84
- function _iterable_to_array_limit(arr, i) {
85
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
86
- if (_i == null) return;
87
- var _arr = [];
88
- var _n = true;
89
- var _d = false;
90
- var _s, _e;
91
- try {
92
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
93
- _arr.push(_s.value);
94
- if (i && _arr.length === i) break;
95
- }
96
- } catch (err) {
97
- _d = true;
98
- _e = err;
99
- } finally{
100
- try {
101
- if (!_n && _i["return"] != null) _i["return"]();
102
- } finally{
103
- if (_d) throw _e;
104
- }
105
- }
106
- return _arr;
107
- }
108
- function _non_iterable_rest() {
109
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
110
- }
111
- function _non_iterable_spread() {
112
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
- }
114
- function _object_spread(target) {
115
- for(var i = 1; i < arguments.length; i++){
116
- var source = arguments[i] != null ? arguments[i] : {};
117
- var ownKeys = Object.keys(source);
118
- if (typeof Object.getOwnPropertySymbols === "function") {
119
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
120
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
121
- }));
122
- }
123
- ownKeys.forEach(function(key) {
124
- _define_property(target, key, source[key]);
125
- });
126
- }
127
- return target;
128
- }
129
- function ownKeys(object, enumerableOnly) {
130
- var keys = Object.keys(object);
131
- if (Object.getOwnPropertySymbols) {
132
- var symbols = Object.getOwnPropertySymbols(object);
133
- if (enumerableOnly) {
134
- symbols = symbols.filter(function(sym) {
135
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
136
- });
137
- }
138
- keys.push.apply(keys, symbols);
139
- }
140
- return keys;
141
- }
142
- function _object_spread_props(target, source) {
143
- source = source != null ? source : {};
144
- if (Object.getOwnPropertyDescriptors) {
145
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
146
- } else {
147
- ownKeys(Object(source)).forEach(function(key) {
148
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
149
- });
150
- }
151
- return target;
152
- }
153
- function _possible_constructor_return(self, call) {
154
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
155
- return call;
156
- }
157
- return _assert_this_initialized(self);
158
- }
159
- function _set_prototype_of(o, p) {
160
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
161
- o.__proto__ = p;
162
- return o;
163
- };
164
- return _set_prototype_of(o, p);
165
- }
166
- function _sliced_to_array(arr, i) {
167
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
168
- }
169
- function _to_consumable_array(arr) {
170
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
171
- }
172
- function _type_of(obj) {
173
- "@swc/helpers - typeof";
174
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
175
- }
176
- function _unsupported_iterable_to_array(o, minLen) {
177
- if (!o) return;
178
- if (typeof o === "string") return _array_like_to_array(o, minLen);
179
- var n = Object.prototype.toString.call(o).slice(8, -1);
180
- if (n === "Object" && o.constructor) n = o.constructor.name;
181
- if (n === "Map" || n === "Set") return Array.from(n);
182
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
183
- }
184
- function _is_native_reflect_construct() {
185
- try {
186
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
187
- } catch (_) {}
188
- return (_is_native_reflect_construct = function() {
189
- return !!result;
190
- })();
191
- }
192
- import { group, max, merge as arrayMerge, min, range, rollup } from "d3-array";
193
- import { brush } from "d3-brush";
194
- import { color } from "d3-color";
195
- import { select } from "d3-selection";
196
- import { scaleOrdinal } from "d3-scale";
197
- import { zoom } from "d3-zoom";
198
- import { colorAssign, colorContrast, colorDefaults } from "@d3plus/color";
199
- import { addToQueue, merge, unique } from "@d3plus/data";
200
- import { assign, date, getSize, inViewport } from "@d3plus/dom";
201
- import { formatAbbreviate } from "@d3plus/format";
202
- import { fontFamily, fontFamilyStringify } from "@d3plus/text";
203
- import { ColorScale, Legend, TextBox, Timeline, Tooltip } from "../components/index.js";
204
- import { accessor, BaseClass, constant } from "../utils/index.js";
205
- // import {Rect} from "../shape/index.js";
206
- import Message from "../components/Message.js";
207
- import drawBack from "./drawSteps/drawBack.js";
208
- import drawColorScale from "./drawSteps/drawColorScale.js";
209
- import { default as drawLegend, legendLabel } from "./drawSteps/drawLegend.js";
210
- import drawSubtitle from "./drawSteps/drawSubtitle.js";
211
- import drawTimeline from "./drawSteps/drawTimeline.js";
212
- import drawTitle from "./drawSteps/drawTitle.js";
213
- import drawTotal from "./drawSteps/drawTotal.js";
214
- import zoomControls from "./drawSteps/zoomControls.js";
215
- import drawAttribution from "./drawSteps/drawAttribution.js";
216
- import clickShape from "./events/click.shape.js";
217
- import clickLegend from "./events/click.legend.js";
218
- import mouseenter from "./events/mouseenter.js";
219
- import mouseleave from "./events/mouseleave.js";
220
- import mousemoveLegend from "./events/mousemove.legend.js";
221
- import mousemoveShape from "./events/mousemove.shape.js";
222
- import touchstartBody from "./events/touchstart.body.js";
223
- function debounce(// eslint-disable-next-line @typescript-eslint/no-explicit-any
224
- func, delay) {
225
- var timeout;
226
- return function() {
227
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
228
- args[_key] = arguments[_key];
229
- }
230
- var context = this;
231
- clearTimeout(timeout);
232
- timeout = setTimeout(function() {
233
- return func.apply(context, args);
234
- }, delay);
235
- };
236
- }
237
- /**
238
- * Default padding logic that will return false if the screen is less than 600 pixels wide.
239
- * @private
240
- */ function defaultPadding() {
241
- return typeof window !== "undefined" ? window.innerWidth > 600 : true;
242
- }
243
- /**
244
- * Turns an array of values into a list string.
245
- * @private
246
- */ function listify(n) {
247
- return n.reduce(function(str, item, i) {
248
- if (!i) str += item;
249
- else if (i === n.length - 1 && i === 1) str += " and ".concat(item);
250
- else if (i === n.length - 1) str += ", and ".concat(item);
251
- else str += ", ".concat(item);
252
- return str;
253
- }, "");
254
- }
255
- /**
256
- * A function that introspects the `d` Data Object for internally nested
257
- * d3plus data and indices, runs the accessor function on that user data.
258
- * @param {Function} acc Accessor function to use.
259
- * @param {Object} d Data Object
260
- * @param {Number} i Index of Data Object in Array
261
- * @private
262
- */ function accessorFetch(acc, d, i) {
263
- while(d.__d3plus__ && d.data){
264
- d = d.data;
265
- i = d.i;
266
- }
267
- return acc(d, i);
268
- }
269
- /**
270
- Minimal LRU cache backed by a Map (insertion-order iteration enables O(1) eviction).
271
- Only .get() and .set() are used by Viz.
272
- @private
273
- */ var LRU = /*#__PURE__*/ function() {
274
- "use strict";
275
- function LRU(capacity) {
276
- _class_call_check(this, LRU);
277
- _define_property(this, "_cap", void 0);
278
- _define_property(this, "_map", void 0);
279
- this._cap = capacity;
280
- this._map = new Map();
281
- }
282
- _create_class(LRU, [
283
- {
284
- key: "get",
285
- value: function get(key) {
286
- if (!this._map.has(key)) return undefined;
287
- var val = this._map.get(key);
288
- this._map.delete(key);
289
- this._map.set(key, val);
290
- return val;
291
- }
292
- },
293
- {
294
- key: "set",
295
- value: function set(key, val) {
296
- this._map.delete(key);
297
- if (this._map.size >= this._cap) this._map.delete(this._map.keys().next().value);
298
- this._map.set(key, val);
299
- }
300
- }
301
- ]);
302
- return LRU;
303
- }();
304
- var Viz = /*#__PURE__*/ function(BaseClass) {
305
- "use strict";
306
- _inherits(Viz, BaseClass);
307
- function Viz() {
308
- _class_call_check(this, Viz);
309
- var _this;
310
- _this = _call_super(this, Viz);
311
- _this._aggs = {};
312
- _this._ariaHidden = true;
313
- _this._attribution = false;
314
- var attributionBg = "rgba(255, 255, 255, 0.75)";
315
- _this._attributionStyle = {
316
- background: attributionBg,
317
- border: "1px solid rgba(0, 0, 0, 0.25)",
318
- color: colorContrast(attributionBg),
319
- display: "block",
320
- font: "400 11px/11px ".concat(fontFamilyStringify(fontFamily)),
321
- margin: "5px",
322
- opacity: 0.75,
323
- padding: "4px 6px 3px"
324
- };
325
- _this._backClass = new TextBox().on("click", function() {
326
- if (_this._history.length) _this.config(_this._history.pop()).render();
327
- else _this.depth(_this._drawDepth - 1).filter(false);
328
- _this.render();
329
- }).on("mousemove", function() {
330
- return _this._backClass.select().style("cursor", "pointer");
331
- });
332
- _this._backConfig = {
333
- fontSize: 10,
334
- padding: 5,
335
- resize: false
336
- };
337
- _this._cache = true;
338
- _this._color = function(d, i) {
339
- return _this._groupBy[0](d, i);
340
- };
341
- _this._colorDefaults = _object_spread_props(_object_spread({}, colorDefaults), {
342
- scale: scaleOrdinal().range(colorDefaults.scale.range())
343
- });
344
- _this._colorScaleClass = new ColorScale();
345
- _this._colorScaleConfig = {
346
- axisConfig: {
347
- rounding: "inside"
348
- },
349
- scale: "jenks"
350
- };
351
- _this._colorScalePadding = defaultPadding;
352
- _this._colorScalePosition = function() {
353
- return _this._width > _this._height * 1.5 ? "right" : "bottom";
354
- };
355
- _this._colorScaleMaxSize = 600;
356
- _this._data = [];
357
- _this._dataCutoff = 100;
358
- _this._detectResize = true;
359
- _this._detectResizeDelay = 400;
360
- _this._detectVisible = true;
361
- _this._detectVisibleInterval = 1000;
362
- _this._downloadButton = false;
363
- _this._downloadConfig = {
364
- type: "png"
365
- };
366
- _this._downloadPosition = "top";
367
- _this._duration = 600;
368
- _this._fontFamily = fontFamily;
369
- _this._hidden = [];
370
- _this._hiddenColor = constant("#aaa");
371
- _this._hiddenOpacity = constant(0.5);
372
- _this._history = [];
373
- _this._groupBy = [
374
- accessor("id")
375
- ];
376
- _this._legend = function(config, arr) {
377
- var maxGrouped = max(arr, function(d, i) {
378
- var id = _this._groupBy[_this._legendDepth].bind(_this)(d, i);
379
- return _instanceof(id, Array) ? id.length : 1;
380
- });
381
- return arr.length > 1 && (maxGrouped !== null && maxGrouped !== void 0 ? maxGrouped : 0) <= 2;
382
- };
383
- _this._legendClass = new Legend();
384
- _this._legendConfig = {
385
- label: legendLabel.bind(_this),
386
- shapeConfig: {
387
- ariaLabel: legendLabel.bind(_this),
388
- labelConfig: {
389
- fontColor: undefined,
390
- fontResize: false,
391
- padding: 0
392
- }
393
- }
394
- };
395
- _this._legendFilterInvert = constant(false);
396
- _this._legendPadding = defaultPadding;
397
- _this._legendPosition = function() {
398
- return _this._width > _this._height * 1.5 ? "right" : "bottom";
399
- };
400
- _this._legendSort = function(a, b) {
401
- return _this._drawLabel(a).localeCompare(_this._drawLabel(b));
402
- };
403
- _this._legendTooltip = {};
404
- _this._loadingHTML = function() {
405
- return '\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>'.concat(_this._translate("Loading Visualization"), '</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">').concat(_this._translate("Powered by D3plus"), "</a></sub>\n </div>");
406
- };
407
- _this._loadingMessage = true;
408
- _this._lrucache = new LRU(10);
409
- _this._messageClass = new Message();
410
- _this._messageMask = "rgba(0, 0, 0, 0.05)";
411
- _this._messageStyle = {
412
- bottom: "0",
413
- left: "0",
414
- position: "absolute",
415
- right: "0",
416
- "text-align": "center",
417
- top: "0"
418
- };
419
- _this._noDataHTML = function() {
420
- return '\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>'.concat(_this._translate("No Data Available"), "</strong>\n </div>");
421
- };
422
- _this._noDataMessage = true;
423
- _this._on = {
424
- "click.shape": clickShape.bind(_this),
425
- "click.legend": clickLegend.bind(_this),
426
- mouseenter: mouseenter.bind(_this),
427
- mouseleave: mouseleave.bind(_this),
428
- "mousemove.shape": mousemoveShape.bind(_this),
429
- "mousemove.legend": mousemoveLegend.bind(_this)
430
- };
431
- _this._queue = [];
432
- _this._resizeObserver = new ResizeObserver(debounce(function(entries) {
433
- var _entries__contentRect = entries[0].contentRect, width = _entries__contentRect.width, height = _entries__contentRect.height;
434
- if ((width !== _this._width && _this._autoWidth || height !== _this._height && _this._autoHeight) && width && height) {
435
- _this._setSVGSize(width, height);
436
- if (!_this._callback) _this.render();
437
- }
438
- }, _this._detectResizeDelay));
439
- _this._scrollContainer = typeof window === "undefined" ? "" : window;
440
- _this._shape = constant("Rect");
441
- _this._shapes = [];
442
- _this._shapeConfig = {
443
- ariaLabel: function ariaLabel(d, i) {
444
- return _this._drawLabel(d, i);
445
- },
446
- fill: function fill(d, i) {
447
- while(d.__d3plus__ && d.data){
448
- d = d.data;
449
- i = d.i;
450
- }
451
- if (_this._colorScale) {
452
- var c = _this._colorScale(d, i);
453
- if (c !== undefined && c !== null) {
454
- var scale = _this._colorScaleClass._colorScale;
455
- var colors = _this._colorScaleClass.color();
456
- if (!scale) return _instanceof(colors, Array) ? colors[colors.length - 1] : colors;
457
- else if (!scale.domain().length) return scale.range()[scale.range().length - 1];
458
- return scale(c);
459
- }
460
- }
461
- var c1 = _this._color(d, i);
462
- if (color(c1)) return c1;
463
- return colorAssign(typeof c1 === "string" ? c1 : JSON.stringify(c1), _this._colorDefaults);
464
- },
465
- labelConfig: {
466
- fontColor: function fontColor(d, i) {
467
- var c = typeof _this._shapeConfig.fill === "function" ? _this._shapeConfig.fill(d, i) : _this._shapeConfig.fill;
468
- return colorContrast(c);
469
- }
470
- },
471
- opacity: constant(1),
472
- stroke: function stroke(d, i) {
473
- var c = typeof _this._shapeConfig.fill === "function" ? _this._shapeConfig.fill(d, i) : _this._shapeConfig.fill;
474
- return color(c).darker(0.25);
475
- },
476
- role: "presentation",
477
- strokeWidth: constant(0)
478
- };
479
- _this._solo = [];
480
- _this._subtitleClass = new TextBox();
481
- _this._subtitleConfig = {
482
- ariaHidden: true,
483
- fontSize: 12,
484
- padding: 5,
485
- resize: false,
486
- textAnchor: "middle"
487
- };
488
- _this._subtitlePadding = defaultPadding;
489
- _this._svgDesc = "";
490
- _this._svgTitle = "";
491
- _this._timeline = true;
492
- _this._timelineClass = new Timeline().align("end");
493
- _this._timelineConfig = {
494
- padding: 5
495
- };
496
- _this._timelinePadding = defaultPadding;
497
- _this._threshold = constant(0.0001);
498
- _this._thresholdKey = undefined;
499
- _this._thresholdName = function() {
500
- return _this._translate("Values");
501
- };
502
- _this._titleClass = new TextBox();
503
- _this._titleConfig = {
504
- ariaHidden: true,
505
- fontSize: 16,
506
- padding: 5,
507
- resize: false,
508
- textAnchor: "middle"
509
- };
510
- _this._titlePadding = defaultPadding;
511
- _this._tooltip = constant(true);
512
- _this._tooltipClass = new Tooltip();
513
- _this._tooltipConfig = {
514
- pointerEvents: "none",
515
- titleStyle: {
516
- "max-width": "200px"
517
- }
518
- };
519
- _this._totalClass = new TextBox();
520
- _this._totalConfig = {
521
- fontSize: 10,
522
- padding: 5,
523
- resize: false,
524
- textAnchor: "middle"
525
- };
526
- _this._totalFormat = function(d) {
527
- return "".concat(_this._translate("Total"), ": ").concat(formatAbbreviate(d, _this._locale));
528
- };
529
- _this._totalPadding = defaultPadding;
530
- _this._zoom = false;
531
- _this._zoomBehavior = zoom();
532
- _this._zoomBrush = brush();
533
- _this._zoomBrushHandleSize = 1;
534
- _this._zoomBrushHandleStyle = {
535
- fill: "#444"
536
- };
537
- _this._zoomBrushSelectionStyle = {
538
- fill: "#777",
539
- "stroke-width": 0
540
- };
541
- var zoomBg = "rgba(255, 255, 255, 0.75)";
542
- _this._zoomControlStyle = {
543
- background: zoomBg,
544
- border: "1px solid rgba(0, 0, 0, 0.75)",
545
- color: colorContrast(zoomBg),
546
- display: "block",
547
- font: "900 15px/21px ".concat(fontFamilyStringify(fontFamily)),
548
- height: "20px",
549
- margin: "5px",
550
- opacity: 0.75,
551
- padding: 0,
552
- "text-align": "center",
553
- width: "20px"
554
- };
555
- var zoomActiveBg = "rgba(0, 0, 0, 0.75)";
556
- _this._zoomControlStyleActive = {
557
- background: zoomActiveBg,
558
- color: colorContrast(zoomActiveBg),
559
- opacity: 1
560
- };
561
- _this._zoomControlStyleHover = {
562
- cursor: "pointer",
563
- opacity: 1
564
- };
565
- _this._zoomFactor = 2;
566
- _this._zoomMax = 16;
567
- _this._zoomPadding = 20;
568
- _this._zoomPan = true;
569
- _this._zoomScroll = true;
570
- return _this;
571
- }
572
- _create_class(Viz, [
573
- {
574
- /**
575
- Called by draw before anything is drawn. Formats the data and performs preparations for draw.
576
- @private
577
- */ key: "_preDraw",
578
- value: function _preDraw() {
579
- var _this = this;
580
- var _this1 = this;
581
- var that = this;
582
- // based on the groupBy, determine the draw depth and current depth id
583
- this._drawDepth = this._depth !== void 0 ? min([
584
- this._depth >= 0 ? this._depth : 0,
585
- this._groupBy.length - 1
586
- ]) : this._groupBy.length - 1;
587
- // Returns the current unique ID for a data point, coerced to a String.
588
- this._id = function(d, i) {
589
- var groupByDrawDepth = accessorFetch(_this._groupBy[_this._drawDepth], d, i);
590
- return typeof groupByDrawDepth === "number" ? "".concat(groupByDrawDepth) : groupByDrawDepth;
591
- };
592
- // Returns an array of the current unique groupBy ID for a data point, coerced to Strings.
593
- this._ids = function(d, i) {
594
- return _this._groupBy.map(function(g) {
595
- return "".concat(accessorFetch(g, d, i));
596
- }).filter(Boolean);
597
- };
598
- this._drawLabel = function(d, i) {
599
- var depth = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _this1._drawDepth;
600
- if (!d) return "";
601
- while(d.__d3plus__ && d.data){
602
- d = d.data;
603
- i = d.i;
604
- }
605
- if (d._isAggregation) {
606
- return "".concat(_this1._thresholdName(d, i), " < ").concat(formatAbbreviate(d._threshold * 100, _this1._locale), "%");
607
- }
608
- if (_this1._label && depth === _this1._drawDepth) return "".concat(_this1._label(d, i));
609
- var l = that._ids(d, i).slice(0, depth + 1);
610
- var n = l.reverse().find(function(ll) {
611
- return !_instanceof(ll, Array);
612
- }) || l[l.length - 1];
613
- return _instanceof(n, Array) ? listify(n) : "".concat(n);
614
- };
615
- // set the default timeFilter if it has not been specified
616
- if (this._time && !this._timeFilter && this._data.length) {
617
- var dates = this._data.map(this._time).map(date);
618
- var d = this._data[0], i = 0;
619
- if (this._discrete && "_".concat(this._discrete) in this && this["_".concat(this._discrete)](d, i) === this._time(d, i)) {
620
- this._timeFilter = function() {
621
- return true;
622
- };
623
- } else {
624
- var latestTime = +max(dates);
625
- this._timeFilter = function(d, i) {
626
- return +date(_this._time(d, i)) === latestTime;
627
- };
628
- }
629
- }
630
- this._filteredData = [];
631
- this._legendData = [];
632
- var flatData = [];
633
- if (this._data.length) {
634
- flatData = this._timeFilter ? this._data.filter(this._timeFilter) : this._data;
635
- if (this._filter) flatData = flatData.filter(this._filter);
636
- var nestKeys = [];
637
- for(var i1 = 0; i1 <= this._drawDepth; i1++)nestKeys.push(this._groupBy[i1]);
638
- if (this._discrete && "_".concat(this._discrete) in this) nestKeys.push(this["_".concat(this._discrete)]);
639
- if (this._discrete && "_".concat(this._discrete, "2") in this) nestKeys.push(this["_".concat(this._discrete, "2")]);
640
- var tree = rollup.apply(void 0, [
641
- flatData,
642
- function(leaves) {
643
- var index = _this._data.indexOf(leaves[0]);
644
- var shape = _this._shape(leaves[0], index);
645
- var id = _this._id(leaves[0], index);
646
- var d = merge(leaves, _this._aggs);
647
- if (!_this._hidden.includes(id) && (!_this._solo.length || _this._solo.includes(id))) {
648
- if (!_this._discrete && shape === "Line") _this._filteredData = _this._filteredData.concat(leaves);
649
- else _this._filteredData.push(d);
650
- }
651
- _this._legendData.push(d);
652
- }
653
- ].concat(_to_consumable_array(nestKeys)));
654
- this._filteredData = this._thresholdFunction(this._filteredData, tree);
655
- }
656
- // overrides the hoverOpacity of shapes if data is larger than cutoff
657
- var uniqueIds = group(this._filteredData, this._id).size;
658
- if (uniqueIds > this._dataCutoff) {
659
- if (this._userHover === undefined) this._userHover = this._shapeConfig.hoverOpacity || 0.5;
660
- if (this._userDuration === undefined) this._userDuration = this._shapeConfig.duration || 600;
661
- this._shapeConfig.hoverOpacity = 1;
662
- this._shapeConfig.duration = 0;
663
- } else if (this._userHover !== undefined) {
664
- this._shapeConfig.hoverOpacity = this._userHover;
665
- this._shapeConfig.duration = this._userDuration;
666
- }
667
- if (this._noDataMessage && !this._filteredData.length) {
668
- this._messageClass.render({
669
- container: this._select.node().parentNode,
670
- html: this._noDataHTML(this),
671
- mask: false,
672
- style: this._messageStyle
673
- });
674
- this._select.transition().duration(this._duration).attr("opacity", 0);
675
- }
676
- }
677
- },
678
- {
679
- /**
680
- Called by render once all checks are passed.
681
- @private
682
- */ key: "_draw",
683
- value: function _draw() {
684
- // Sanitizes user input for legendPosition and colorScalePosition
685
- var legendPosition = this._legendPosition.bind(this)(this.config());
686
- if (![
687
- false,
688
- "top",
689
- "bottom",
690
- "left",
691
- "right"
692
- ].includes(legendPosition)) legendPosition = "bottom";
693
- var colorScalePosition = this._colorScalePosition.bind(this)(this.config());
694
- if (![
695
- false,
696
- "top",
697
- "bottom",
698
- "left",
699
- "right"
700
- ].includes(colorScalePosition)) colorScalePosition = "bottom";
701
- // Draws legend and colorScale if they are positioned "left" or "right"
702
- if (legendPosition === "left" || legendPosition === "right") drawLegend.bind(this)(this._legendData);
703
- if (colorScalePosition === "left" || colorScalePosition === "right" || colorScalePosition === false) drawColorScale.bind(this)();
704
- // Draws all of the top/bottom UI elements
705
- drawBack.bind(this)();
706
- drawTitle.bind(this)(this._filteredData);
707
- drawSubtitle.bind(this)(this._filteredData);
708
- drawTotal.bind(this)(this._filteredData);
709
- drawTimeline.bind(this)(this._filteredData);
710
- // Draws legend and colorScale if they are positioned "top" or "bottom"
711
- if (legendPosition === "top" || legendPosition === "bottom") drawLegend.bind(this)(this._legendData);
712
- if (colorScalePosition === "top" || colorScalePosition === "bottom") drawColorScale.bind(this)();
713
- this._shapes = [];
714
- // Draws a container and zoomGroup to test functionality.
715
- // this._testGroup = this._select.selectAll("g.d3plus-viz-testGroup").data([0]);
716
- // const enterTest = this._testGroup.enter().append("g").attr("class", "d3plus-viz-testGroup")
717
- // .merge(this._testGroup);
718
- // this._testGroup = enterTest.merge(this._testGroup);
719
- // const bgHeight = this._height - this._margin.top - this._margin.bottom;
720
- // const bgWidth = this._width - this._margin.left - this._margin.right;
721
- // new Rect()
722
- // .data([{id: "background"}])
723
- // .select(this._testGroup.node())
724
- // .x(bgWidth / 2 + this._margin.left)
725
- // .y(bgHeight / 2 + this._margin.top)
726
- // .width(bgWidth)
727
- // .height(bgHeight)
728
- // .fill("#ccc")
729
- // .render();
730
- // this._zoomGroup = this._select.selectAll("g.d3plus-viz-zoomGroup").data([0]);
731
- // const enter = this._zoomGroup.enter().append("g").attr("class", "d3plus-viz-zoomGroup")
732
- // .merge(this._zoomGroup);
733
- // this._zoomGroup = enter.merge(this._zoomGroup);
734
- // const testConfig = {
735
- // on: {
736
- // click: this._on["click.shape"],
737
- // mouseenter: this._on.mouseenter,
738
- // mouseleave: this._on.mouseleave,
739
- // mousemove: this._on["mousemove.shape"]
740
- // }
741
- // };
742
- // const testWidth = 50;
743
- // this._shapes.push(new Rect()
744
- // .config(this._shapeConfig)
745
- // .config(configPrep.bind(this)(testConfig))
746
- // .data(this._filteredData)
747
- // .label("Test Label")
748
- // .select(this._zoomGroup.node())
749
- // .id(this._id)
750
- // .x(d => {
751
- // if (!d.x) d.x = Math.random() * bgWidth;
752
- // return d.x;
753
- // })
754
- // .y(d => {
755
- // if (!d.y) d.y = Math.random() * bgHeight;
756
- // return d.y;
757
- // })
758
- // .width(testWidth)
759
- // .height(testWidth)
760
- // .render());
761
- }
762
- },
763
- {
764
- /**
765
- * Applies the threshold algorithm according to the type of chart used.
766
- * @param {Array} data The data to process.
767
- * @private
768
- */ key: "_thresholdFunction",
769
- value: function _thresholdFunction(data, _tree) {
770
- return data;
771
- }
772
- },
773
- {
774
- /**
775
- * Detects width and height and sets SVG properties
776
- * @private
777
- */ key: "_setSVGSize",
778
- value: function _setSVGSize(width, height) {
779
- var _ref = _sliced_to_array(width && height ? [
780
- width,
781
- height
782
- ] : getSize(this._select.node().parentNode), 2), w = _ref[0], h = _ref[1];
783
- w -= parseFloat(this._select.style("border-left-width"));
784
- w -= parseFloat(this._select.style("border-right-width"));
785
- h -= parseFloat(this._select.style("border-top-width"));
786
- h -= parseFloat(this._select.style("border-bottom-width"));
787
- if (this._autoWidth && this._width !== w) {
788
- this.width(w);
789
- this._select.style("width", "".concat(this._width, "px")).attr("width", "".concat(this._width, "px"));
790
- }
791
- if (this._autoHeight && this._height !== h) {
792
- this.height(h);
793
- this._select.style("height", "".concat(this._height, "px")).attr("height", "".concat(this._height, "px"));
794
- }
795
- }
796
- },
797
- {
798
- /**
799
- Draws the visualization given the specified configuration.
800
- @param callback Optional callback invoked after rendering completes.
801
- */ key: "render",
802
- value: function render(callback) {
803
- var _this = this;
804
- this._callback = callback;
805
- // Resets margins and padding
806
- this._margin = {
807
- bottom: 0,
808
- left: 0,
809
- right: 0,
810
- top: 0
811
- };
812
- this._padding = {
813
- bottom: 0,
814
- left: 0,
815
- right: 0,
816
- top: 0
817
- };
818
- // Appends a fullscreen SVG to the BODY if a container has not been provided through .select().
819
- if (this._select === void 0 || this._select.node().tagName.toLowerCase() !== "svg") {
820
- var parent = this._select === void 0 ? select("body").insert("div", "#d3plus-portal").style("height", "100dvh").style("width", "100%").style("min-height", "150px") : this._select;
821
- var svg = parent.select(".d3plus-viz").size() ? parent.select(".d3plus-viz") : parent.append("svg");
822
- this.select(svg.node());
823
- }
824
- // Calculates the width and/or height of the Viz based on the this._select, if either has not been defined.
825
- if ((!this._width || !this._height) && (!this._detectVisible || inViewport(this._select.node()))) {
826
- this._autoWidth = this._width === undefined;
827
- this._autoHeight = this._height === undefined;
828
- this._setSVGSize();
829
- }
830
- var parent1 = select(this._select.node().parentNode);
831
- this._select.attr("class", "d3plus-viz").attr("aria-hidden", this._ariaHidden).attr("aria-labelledby", "".concat(this._uuid, "-title ").concat(this._uuid, "-desc")).attr("role", "img").attr("xmlns", "http://www.w3.org/2000/svg").attr("xmlns:xlink", "http://www.w3.org/1999/xlink").style("position", "absolute").style("top", parent1.style("padding-top")).style("left", parent1.style("padding-left")).transition().duration(this._duration).style("width", this._width !== undefined ? "".concat(this._width, "px") : undefined).style("height", this._height !== undefined ? "".concat(this._height, "px") : undefined).attr("width", this._width !== undefined ? "".concat(this._width, "px") : undefined).attr("height", this._height !== undefined ? "".concat(this._height, "px") : undefined);
832
- // sets "position: relative" on the SVG parent if currently undefined
833
- var position = parent1.style("position");
834
- if (position === "static") parent1.style("position", "relative");
835
- parent1.style("font-family", fontFamilyStringify(this._fontFamily));
836
- // sets initial opacity to 1, if it has not already been set
837
- if (this._select.attr("opacity") === null) this._select.attr("opacity", 1);
838
- // Updates the <title> tag if already exists else creates a new <title> tag on this.select.
839
- var svgTitle = this._select.selectAll("title").data([
840
- 0
841
- ]);
842
- var svgTitleEnter = svgTitle.enter().append("title").attr("id", "".concat(this._uuid, "-title"));
843
- svgTitle.merge(svgTitleEnter).text(this._svgTitle);
844
- // Updates the <desc> tag if already exists else creates a new <desc> tag on this.select.
845
- var svgDesc = this._select.selectAll("desc").data([
846
- 0
847
- ]);
848
- var svgDescEnter = svgDesc.enter().append("desc").attr("id", "".concat(this._uuid, "-desc"));
849
- svgDesc.merge(svgDescEnter).text(this._svgDesc);
850
- this._visiblePoll = clearInterval(this._visiblePoll);
851
- this._resizePoll = clearTimeout(this._resizePoll);
852
- this._scrollPoll = clearTimeout(this._scrollPoll);
853
- select(this._scrollContainer).on("scroll.".concat(this._uuid), null);
854
- if (this._detectVisible && this._select.style("visibility") === "hidden") {
855
- this._visiblePoll = setInterval(function() {
856
- if (_this._select.style("visibility") !== "hidden") {
857
- _this._visiblePoll = clearInterval(_this._visiblePoll);
858
- _this.render(callback);
859
- }
860
- }, this._detectVisibleInterval);
861
- } else if (this._detectVisible && this._select.style("display") === "none") {
862
- this._visiblePoll = setInterval(function() {
863
- if (_this._select.style("display") !== "none") {
864
- _this._visiblePoll = clearInterval(_this._visiblePoll);
865
- _this.render(callback);
866
- }
867
- }, this._detectVisibleInterval);
868
- } else if (this._detectVisible && !inViewport(this._select.node())) {
869
- select(this._scrollContainer).on("scroll.".concat(this._uuid), function() {
870
- if (!_this._scrollPoll) {
871
- _this._scrollPoll = setTimeout(function() {
872
- if (inViewport(_this._select.node())) {
873
- select(_this._scrollContainer).on("scroll.".concat(_this._uuid), null);
874
- _this.render(callback);
875
- }
876
- _this._scrollPoll = clearTimeout(_this._scrollPoll);
877
- }, _this._detectVisibleInterval);
878
- }
879
- });
880
- } else {
881
- var promises = [];
882
- this._queue.forEach(function(p) {
883
- var cache = _this._cache ? _this._lrucache.get("".concat(p[3], "_").concat(p[1])) : undefined;
884
- if (!cache) {
885
- promises.push(new Promise(function(resolve) {
886
- p[0](p[1], p[2], p[3], function(err) {
887
- if (err) console.error(err);
888
- resolve();
889
- });
890
- }));
891
- } else _this["_".concat(p[3])] = p[2] ? p[2](cache) : cache;
892
- });
893
- this._queue = [];
894
- if (this._loadingMessage && promises.length) {
895
- this._messageClass.render({
896
- container: this._select.node().parentNode,
897
- html: this._loadingHTML(this),
898
- mask: this._filteredData ? this._messageMask : false,
899
- style: this._messageStyle
900
- });
901
- }
902
- Promise.all(promises).then(function() {
903
- // creates a data table as DOM elements inside of the SVG for accessibility
904
- // only if this._ariaHidden is set to true
905
- var columns = _instanceof(_this._data, Array) && _this._data.length > 0 ? Object.keys(_this._data[0]) : [];
906
- var svgTable = _this._select.selectAll("g.data-table").data(!_this._ariaHidden && _instanceof(_this._data, Array) && _this._data.length ? [
907
- 0
908
- ] : []);
909
- var svgTableEnter = svgTable.enter().append("g").attr("class", "data-table").attr("role", "table");
910
- svgTable.exit().remove();
911
- var rows = svgTable.merge(svgTableEnter).selectAll("text").data(_instanceof(_this._data, Array) ? range(0, _this._data.length + 1) : []);
912
- rows.exit().remove();
913
- var cells = rows.merge(rows.enter().append("text").attr("role", "row")).selectAll("tspan").data(function(d, i) {
914
- return columns.map(function(c) {
915
- return {
916
- role: i ? "cell" : "columnheader",
917
- text: i ? _this._data[i - 1][c] : c
918
- };
919
- });
920
- });
921
- cells.exit().remove();
922
- cells.merge(cells.enter().append("tspan")).attr("role", function(d) {
923
- return d.role;
924
- }).attr("dy", "-1000px").html(function(d) {
925
- return d.text;
926
- });
927
- // finishes the draw cycle
928
- _this._preDraw();
929
- _this._draw();
930
- zoomControls.bind(_this)();
931
- drawAttribution.bind(_this)();
932
- if (_this._messageClass._isVisible && (!_this._noDataMessage || _this._filteredData.length)) {
933
- _this._messageClass.hide();
934
- if (_this._select.attr("opacity") === "0") _this._select.transition().duration(_this._duration).attr("opacity", 1);
935
- }
936
- if (_this._detectResize && (_this._autoWidth || _this._autoHeight)) {
937
- _this._resizeObserver.observe(_this._select.node().parentNode);
938
- } else {
939
- _this._resizeObserver.unobserve(_this._select.node().parentNode);
940
- }
941
- if (callback) setTimeout(function() {
942
- callback();
943
- _this._callback = undefined;
944
- }, _this._duration + 100);
945
- });
946
- }
947
- // Attaches touchstart event listener to the BODY to hide the tooltip when the user touches any element without data
948
- select("body").on("touchstart.".concat(this._uuid), touchstartBody.bind(this));
949
- return this;
950
- }
951
- },
952
- {
953
- /**
954
- Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
955
- */ key: "destroy",
956
- value: function destroy() {
957
- this._resizeObserver.disconnect();
958
- this._tooltipClass.data([]).render();
959
- select("body").on("touchstart.".concat(this._uuid), null);
960
- return this;
961
- }
962
- },
963
- {
964
- /**
965
- The active callback function for highlighting shapes.
966
- */ key: "active",
967
- value: function active(_) {
968
- this._active = _;
969
- if (this._shapeConfig.activeOpacity !== 1) {
970
- this._shapes.forEach(function(s) {
971
- return s.active(_);
972
- });
973
- if (this._legend) this._legendClass.active(_);
974
- }
975
- return this;
976
- }
977
- },
978
- {
979
- /**
980
- Custom aggregation methods for each data key.
981
- */ key: "aggs",
982
- value: function aggs(_) {
983
- return arguments.length ? (this._aggs = assign(this._aggs, _), this) : this._aggs;
984
- }
985
- },
986
- {
987
- /**
988
- The "aria-hidden" attribute of the containing SVG element. The default value is "false", but if you need to hide the SVG from screen readers set this property to "true".
989
- */ key: "ariaHidden",
990
- value: function ariaHidden(_) {
991
- return arguments.length ? (this._ariaHidden = _, this) : this._ariaHidden;
992
- }
993
- },
994
- {
995
- /**
996
- Sets text to be shown positioned absolute on top of the visualization in the bottom-right corner. This is most often used in Geomaps to display the copyright of map tiles. The text is rendered as HTML, so any valid HTML string will render as expected (eg. anchor links work).
997
- */ key: "attribution",
998
- value: function attribution(_) {
999
- return arguments.length ? (this._attribution = _, this) : this._attribution;
1000
- }
1001
- },
1002
- {
1003
- /**
1004
- Configuration object for the attribution style.
1005
- */ key: "attributionStyle",
1006
- value: function attributionStyle(_) {
1007
- return arguments.length ? (this._attributionStyle = assign(this._attributionStyle, _), this) : this._attributionStyle;
1008
- }
1009
- },
1010
- {
1011
- /**
1012
- Configuration object for the back button.
1013
- */ key: "backConfig",
1014
- value: function backConfig(_) {
1015
- return arguments.length ? (this._backConfig = assign(this._backConfig, _), this) : this._backConfig;
1016
- }
1017
- },
1018
- {
1019
- /**
1020
- Enables a lru cache that stores up to 5 previously loaded files/URLs. Helpful when constantly writing over the data array with a URL in the render function of a react component.
1021
- */ key: "cache",
1022
- value: function cache(_) {
1023
- return arguments.length ? (this._cache = _, this) : this._cache;
1024
- }
1025
- },
1026
- {
1027
- /**
1028
- Defines the main color to be used for each data point in a visualization. Can be either an accessor function or a string key to reference in each data point. If a color value is returned, it will be used as is. If a string is returned, a unique color will be assigned based on the string.
1029
- */ key: "color",
1030
- value: function color(_) {
1031
- return arguments.length ? (this._color = !_ || typeof _ === "function" ? _ : accessor(_), this) : this._color;
1032
- }
1033
- },
1034
- {
1035
- /**
1036
- Defines the value to be used for a color scale. Can be either an accessor function or a string key to reference in each data point.
1037
- */ key: "colorScale",
1038
- value: function colorScale(_) {
1039
- return arguments.length ? (this._colorScale = !_ || typeof _ === "function" ? _ : accessor(_), this) : this._colorScale;
1040
- }
1041
- },
1042
- {
1043
- /**
1044
- A pass-through to the config method of ColorScale.
1045
- */ key: "colorScaleConfig",
1046
- value: function colorScaleConfig(_) {
1047
- return arguments.length ? (this._colorScaleConfig = assign(this._colorScaleConfig, _), this) : this._colorScaleConfig;
1048
- }
1049
- },
1050
- {
1051
- /**
1052
- Tells the colorScale whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the colorScale appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1053
- */ key: "colorScalePadding",
1054
- value: function colorScalePadding(_) {
1055
- return arguments.length ? (this._colorScalePadding = typeof _ === "function" ? _ : constant(_), this) : this._colorScalePadding;
1056
- }
1057
- },
1058
- {
1059
- /**
1060
- Defines which side of the visualization to anchor the color scale. Acceptable values are `"top"`, `"bottom"`, `"left"`, `"right"`, and `false`. A `false` value will cause the color scale to not be displayed, but will still color shapes based on the scale.
1061
- */ key: "colorScalePosition",
1062
- value: function colorScalePosition(_) {
1063
- return arguments.length ? (this._colorScalePosition = typeof _ === "function" ? _ : constant(_), this) : this._colorScalePosition;
1064
- }
1065
- },
1066
- {
1067
- /**
1068
- The maximum pixel size for drawing the color scale: width for horizontal scales and height for vertical scales.
1069
- */ key: "colorScaleMaxSize",
1070
- value: function colorScaleMaxSize(_) {
1071
- return arguments.length ? (this._colorScaleMaxSize = _, this) : this._colorScaleMaxSize;
1072
- }
1073
- },
1074
- {
1075
- /**
1076
- The primary data array used to draw the visualization. The value passed should be an *Array* of objects or a *String* representing a filepath or URL to be loaded. The following filetypes are supported: `csv`, `tsv`, `txt`, and `json`.
1077
-
1078
- If your data URL needs specific headers to be set, an Object with "url" and "headers" keys may also be passed.
1079
-
1080
- Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final array of obejcts to be used as the primary data array. For example, some JSON APIs return the headers split from the data values to save bandwidth. These would need be joined using a custom formatter.
1081
-
1082
- If you would like to specify certain configuration options based on the yet-to-be-loaded data, you can also return a full `config` object from the data formatter (including the new `data` array as a key in the object).
1083
-
1084
- Defaults to an empty array (`[]`).
1085
- @param f The data array or a URL string to load data from.
1086
- */ key: "data",
1087
- value: function data(_, f) {
1088
- if (arguments.length) {
1089
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1090
- addToQueue.bind(this)(_, f, "data");
1091
- this._hidden = [];
1092
- this._solo = [];
1093
- if (this._userData && JSON.stringify(_) !== JSON.stringify(this._userData)) {
1094
- this._timeFilter = false;
1095
- this._timelineSelection = false;
1096
- }
1097
- this._userData = _;
1098
- return this;
1099
- }
1100
- return this._data;
1101
- }
1102
- },
1103
- {
1104
- /**
1105
- If the number of visible data points exceeds this number, the default hover behavior will be disabled (helpful for very large visualizations bogging down the DOM with opacity updates).
1106
- */ key: "dataCutoff",
1107
- value: function dataCutoff(_) {
1108
- return arguments.length ? (this._dataCutoff = _, this) : this._dataCutoff;
1109
- }
1110
- },
1111
- {
1112
- /**
1113
- The current depth of the visualization. The value should correspond with an index in the [groupBy](#groupBy) array.
1114
- */ key: "depth",
1115
- value: function depth(_) {
1116
- return arguments.length ? (this._depth = _, this) : this._depth;
1117
- }
1118
- },
1119
- {
1120
- /**
1121
- If the width and/or height of a Viz is not user-defined, it is determined by the size of it's parent element. When this method is set to `true`, the Viz will listen for the `window.onresize` event and adjust it's dimensions accordingly.
1122
- */ key: "detectResize",
1123
- value: function detectResize(_) {
1124
- return arguments.length ? (this._detectResize = _, this) : this._detectResize;
1125
- }
1126
- },
1127
- {
1128
- /**
1129
- When resizing the browser window, this is the millisecond delay to trigger the resize event.
1130
- */ key: "detectResizeDelay",
1131
- value: function detectResizeDelay(_) {
1132
- return arguments.length ? (this._detectResizeDelay = _, this) : this._detectResizeDelay;
1133
- }
1134
- },
1135
- {
1136
- /**
1137
- Toggles whether or not the Viz should try to detect if it visible in the current viewport. When this method is set to `true`, the Viz will only be rendered when it has entered the viewport either through scrolling or if it's display or visibility is changed.
1138
- */ key: "detectVisible",
1139
- value: function detectVisible(_) {
1140
- return arguments.length ? (this._detectVisible = _, this) : this._detectVisible;
1141
- }
1142
- },
1143
- {
1144
- /**
1145
- The interval, in milliseconds, for checking if the visualization is visible on the page.
1146
- */ key: "detectVisibleInterval",
1147
- value: function detectVisibleInterval(_) {
1148
- return arguments.length ? (this._detectVisibleInterval = _, this) : this._detectVisibleInterval;
1149
- }
1150
- },
1151
- {
1152
- /**
1153
- If *value* is specified, sets the discrete accessor to the specified method name (usually an axis) and returns the current class instance.
1154
- */ key: "discrete",
1155
- value: function discrete(_) {
1156
- return arguments.length ? (this._discrete = _, this) : this._discrete;
1157
- }
1158
- },
1159
- {
1160
- /**
1161
- Shows a button that allows for downloading the current visualization.
1162
- */ key: "downloadButton",
1163
- value: function downloadButton(_) {
1164
- return arguments.length ? (this._downloadButton = _, this) : this._downloadButton;
1165
- }
1166
- },
1167
- {
1168
- /**
1169
- Sets specific options of the saveElement function used when downloading the visualization.
1170
- */ key: "downloadConfig",
1171
- value: function downloadConfig(_) {
1172
- return arguments.length ? (this._downloadConfig = assign(this._downloadConfig, _), this) : this._downloadConfig;
1173
- }
1174
- },
1175
- {
1176
- /**
1177
- Defines which control group to add the download button into.
1178
- */ key: "downloadPosition",
1179
- value: function downloadPosition(_) {
1180
- return arguments.length ? (this._downloadPosition = _, this) : this._downloadPosition;
1181
- }
1182
- },
1183
- {
1184
- /**
1185
- The animation duration in milliseconds.
1186
- */ key: "duration",
1187
- value: function duration(_) {
1188
- return arguments.length ? (this._duration = _, this) : this._duration;
1189
- }
1190
- },
1191
- {
1192
- /**
1193
- A filter function applied to the data before drawing.
1194
- */ key: "filter",
1195
- value: function filter(_) {
1196
- return arguments.length ? (this._filter = _, this) : this._filter;
1197
- }
1198
- },
1199
- {
1200
- /**
1201
- The font family used throughout the visualization.
1202
- */ key: "fontFamily",
1203
- value: function fontFamily(_) {
1204
- var _this = this;
1205
- if (arguments.length) {
1206
- var labelConfig = {
1207
- fontFamily: _
1208
- };
1209
- var axisConfig = {
1210
- titleConfig: labelConfig,
1211
- shapeConfig: {
1212
- labelConfig: labelConfig
1213
- }
1214
- };
1215
- this.shapeConfig({
1216
- labelConfig: labelConfig
1217
- });
1218
- this.colorScaleConfig({
1219
- axisConfig: axisConfig
1220
- });
1221
- [
1222
- "axis",
1223
- "column",
1224
- "row",
1225
- "timeline",
1226
- "x",
1227
- "y",
1228
- "x2",
1229
- "y2"
1230
- ].forEach(function(axis) {
1231
- var method = "".concat(axis, "Config");
1232
- if (_this[method]) _this[method](axisConfig);
1233
- });
1234
- [
1235
- "back",
1236
- "title",
1237
- "total",
1238
- "subtitle"
1239
- ].forEach(function(label) {
1240
- var method = "".concat(label, "Config");
1241
- if (_this[method]) _this[method](labelConfig);
1242
- });
1243
- this.tooltipConfig({
1244
- tooltipStyle: {
1245
- "font-family": fontFamilyStringify(_)
1246
- }
1247
- });
1248
- this._fontFamily = _;
1249
- return this;
1250
- }
1251
- return this._fontFamily;
1252
- }
1253
- },
1254
- {
1255
- /**
1256
- Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is "id"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.
1257
- */ key: "groupBy",
1258
- value: function groupBy(_) {
1259
- var _this = this;
1260
- if (!arguments.length) return this._groupBy;
1261
- this._groupByRaw = _;
1262
- var arr = _instanceof(_, Array) ? _ : [
1263
- _
1264
- ];
1265
- return this._groupBy = arr.map(function(k) {
1266
- if (typeof k === "function") return k;
1267
- else {
1268
- if (!_this._aggs[k]) {
1269
- _this._aggs[k] = function(a, c) {
1270
- var v = unique(a.map(c));
1271
- return v.length === 1 ? v[0] : v;
1272
- };
1273
- }
1274
- return accessor(k);
1275
- }
1276
- }), this;
1277
- }
1278
- },
1279
- {
1280
- /**
1281
- The overall height of the visualization in pixels.
1282
- */ key: "height",
1283
- value: function height(_) {
1284
- return arguments.length ? (this._height = _, this) : this._height;
1285
- }
1286
- },
1287
- {
1288
- /**
1289
- Defines the color used for legend shapes when the corresponding grouping is hidden from display (by clicking on the legend).
1290
- */ key: "hiddenColor",
1291
- value: function hiddenColor(_) {
1292
- return arguments.length ? (this._hiddenColor = typeof _ === "function" ? _ : constant(_), this) : this._hiddenColor;
1293
- }
1294
- },
1295
- {
1296
- /**
1297
- Defines the opacity used for legend labels when the corresponding grouping is hidden from display (by clicking on the legend).
1298
- */ key: "hiddenOpacity",
1299
- value: function hiddenOpacity(_) {
1300
- return arguments.length ? (this._hiddenOpacity = typeof _ === "function" ? _ : constant(_), this) : this._hiddenOpacity;
1301
- }
1302
- },
1303
- {
1304
- /**
1305
- The hover callback function for highlighting shapes on mouseover.
1306
- */ key: "hover",
1307
- value: function hover(_) {
1308
- var _this = this;
1309
- var hoverFunction = this._hover = _;
1310
- if (this._shapeConfig.hoverOpacity !== 1 && _ !== undefined) {
1311
- if (typeof _ === "function") {
1312
- var shapeData = arrayMerge(this._shapes.map(function(s) {
1313
- return s.data();
1314
- }));
1315
- shapeData = shapeData.concat(this._legendClass.data());
1316
- var activeData = _ ? shapeData.filter(_) : [];
1317
- var activeIds = [];
1318
- activeData.map(this._ids).forEach(function(ids) {
1319
- for(var x = 1; x <= ids.length; x++){
1320
- activeIds.push(JSON.stringify(ids.slice(0, x)));
1321
- }
1322
- });
1323
- activeIds = activeIds.filter(function(id, i) {
1324
- return activeIds.indexOf(id) === i;
1325
- });
1326
- if (activeIds.length) hoverFunction = function hoverFunction(d, i) {
1327
- return activeIds.includes(JSON.stringify(_this._ids(d, i)));
1328
- };
1329
- }
1330
- this._shapes.forEach(function(s) {
1331
- return s.hover(hoverFunction);
1332
- });
1333
- if (this._legend) this._legendClass.hover(hoverFunction);
1334
- }
1335
- return this;
1336
- }
1337
- },
1338
- {
1339
- /**
1340
- Accessor function or string key for the label of each data point.
1341
- */ key: "label",
1342
- value: function label(_) {
1343
- return arguments.length ? (this._label = typeof _ === "function" ? _ : constant(_), this) : this._label;
1344
- }
1345
- },
1346
- {
1347
- /**
1348
- Whether to display the legend.
1349
- */ key: "legend",
1350
- value: function legend(_) {
1351
- return arguments.length ? (this._legend = typeof _ === "function" ? _ : constant(_), this) : this._legend;
1352
- }
1353
- },
1354
- {
1355
- /**
1356
- Configuration object passed to the legend's config method.
1357
- */ key: "legendConfig",
1358
- value: function legendConfig(_) {
1359
- return arguments.length ? (this._legendConfig = assign(this._legendConfig, _), this) : this._legendConfig;
1360
- }
1361
- },
1362
- {
1363
- /**
1364
- Defines the click functionality of categorical legend squares. When set to false, clicking will hide that category and shift+clicking will solo that category. When set to true, clicking with solo that category and shift+clicking will hide that category.
1365
- */ key: "legendFilterInvert",
1366
- value: function legendFilterInvert(_) {
1367
- return arguments.length ? (this._legendFilterInvert = typeof _ === "function" ? _ : constant(_), this) : this._legendFilterInvert;
1368
- }
1369
- },
1370
- {
1371
- /**
1372
- Tells the legend whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the legend appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1373
- */ key: "legendPadding",
1374
- value: function legendPadding(_) {
1375
- return arguments.length ? (this._legendPadding = typeof _ === "function" ? _ : constant(_), this) : this._legendPadding;
1376
- }
1377
- },
1378
- {
1379
- /**
1380
- Defines which side of the visualization to anchor the legend. Expected values are `"top"`, `"bottom"`, `"left"`, and `"right"`.
1381
- */ key: "legendPosition",
1382
- value: function legendPosition(_) {
1383
- return arguments.length ? (this._legendPosition = typeof _ === "function" ? _ : constant(_), this) : this._legendPosition;
1384
- }
1385
- },
1386
- {
1387
- /**
1388
- A JavaScript [sort comparator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) used to sort the legend.
1389
- */ key: "legendSort",
1390
- value: function legendSort(_) {
1391
- return arguments.length ? (this._legendSort = _, this) : this._legendSort;
1392
- }
1393
- },
1394
- {
1395
- /**
1396
- Configuration object for the legend tooltip.
1397
- */ key: "legendTooltip",
1398
- value: function legendTooltip(_) {
1399
- return arguments.length ? (this._legendTooltip = assign(this._legendTooltip, _), this) : this._legendTooltip;
1400
- }
1401
- },
1402
- {
1403
- /**
1404
- The inner HTML of the status message displayed when loading AJAX requests and displaying errors. Must be a valid HTML string or a function that, when passed this Viz instance, returns a valid HTML string.
1405
- */ key: "loadingHTML",
1406
- value: function loadingHTML(_) {
1407
- return arguments.length ? (this._loadingHTML = typeof _ === "function" ? _ : constant(_), this) : this._loadingHTML;
1408
- }
1409
- },
1410
- {
1411
- /**
1412
- Toggles the visibility of the status message that is displayed when loading AJAX requests and displaying errors.
1413
- */ key: "loadingMessage",
1414
- value: function loadingMessage(_) {
1415
- return arguments.length ? (this._loadingMessage = _, this) : this._loadingMessage;
1416
- }
1417
- },
1418
- {
1419
- /**
1420
- The color of the mask displayed underneath the status message when loading AJAX requests and displaying errors. Set to `false` to turn off the mask completely.
1421
- */ key: "messageMask",
1422
- value: function messageMask(_) {
1423
- return arguments.length ? (this._messageMask = _, this) : this._messageMask;
1424
- }
1425
- },
1426
- {
1427
- /**
1428
- Defines the CSS style properties for the status message that is displayed when loading AJAX requests and displaying errors.
1429
- */ key: "messageStyle",
1430
- value: function messageStyle(_) {
1431
- return arguments.length ? (this._messageStyle = assign(this._messageStyle, _), this) : this._messageStyle;
1432
- }
1433
- },
1434
- {
1435
- /**
1436
- The inner HTML of the status message displayed when no data is supplied to the visualization. Must be a valid HTML string or a function that, when passed this Viz instance, returns a valid HTML string.
1437
- */ key: "noDataHTML",
1438
- value: function noDataHTML(_) {
1439
- return arguments.length ? (this._noDataHTML = typeof _ === "function" ? _ : constant(_), this) : this._noDataHTML;
1440
- }
1441
- },
1442
- {
1443
- /**
1444
- Toggles the visibility of the status message that is displayed when no data is supplied to the visualization.
1445
- */ key: "noDataMessage",
1446
- value: function noDataMessage(_) {
1447
- return arguments.length ? (this._noDataMessage = _, this) : this._noDataMessage;
1448
- }
1449
- },
1450
- {
1451
- /**
1452
- If using scroll or visibility detection, this method allow a custom override of the element to which the scroll detection function gets attached.
1453
- */ key: "scrollContainer",
1454
- value: function scrollContainer(_) {
1455
- return arguments.length ? (this._scrollContainer = _, this) : this._scrollContainer;
1456
- }
1457
- },
1458
- {
1459
- /**
1460
- The SVG container element as a d3 selector or DOM element. Defaults to `undefined`.
1461
- */ key: "select",
1462
- value: function select1(_) {
1463
- return arguments.length ? (this._select = select(_), this) : this._select;
1464
- }
1465
- },
1466
- {
1467
- /**
1468
- Changes the primary shape used to represent each data point in a visualization. Not all visualizations support changing shapes, this method can be provided the String name of a D3plus shape class (for example, "Rect" or "Circle"), or an accessor Function that returns the String class name to be used for each individual data point.
1469
- */ key: "shape",
1470
- value: function shape(_) {
1471
- return arguments.length ? (this._shape = typeof _ === "function" ? _ : constant(_), this) : this._shape;
1472
- }
1473
- },
1474
- {
1475
- /**
1476
- Configuration object with key/value pairs applied as method calls on each shape.
1477
- */ key: "shapeConfig",
1478
- value: function shapeConfig(_) {
1479
- return arguments.length ? (this._shapeConfig = assign(this._shapeConfig, _), this) : this._shapeConfig;
1480
- }
1481
- },
1482
- {
1483
- /**
1484
- Accessor function or string for the visualization's subtitle.
1485
- */ key: "subtitle",
1486
- value: function subtitle(_) {
1487
- return arguments.length ? (this._subtitle = typeof _ === "function" ? _ : constant(_), this) : this._subtitle;
1488
- }
1489
- },
1490
- {
1491
- /**
1492
- Configuration object for the subtitle.
1493
- */ key: "subtitleConfig",
1494
- value: function subtitleConfig(_) {
1495
- return arguments.length ? (this._subtitleConfig = assign(this._subtitleConfig, _), this) : this._subtitleConfig;
1496
- }
1497
- },
1498
- {
1499
- /**
1500
- Tells the subtitle whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the subtitle appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1501
- */ key: "subtitlePadding",
1502
- value: function subtitlePadding(_) {
1503
- return arguments.length ? (this._subtitlePadding = typeof _ === "function" ? _ : constant(_), this) : this._subtitlePadding;
1504
- }
1505
- },
1506
- {
1507
- /**
1508
- The description text for the SVG `<desc>` element, used for accessibility.
1509
- */ key: "svgDesc",
1510
- value: function svgDesc(_) {
1511
- return arguments.length ? (this._svgDesc = _, this) : this._svgDesc;
1512
- }
1513
- },
1514
- {
1515
- /**
1516
- The title text for the SVG `<title>` element, used for accessibility.
1517
- */ key: "svgTitle",
1518
- value: function svgTitle(_) {
1519
- return arguments.length ? (this._svgTitle = _, this) : this._svgTitle;
1520
- }
1521
- },
1522
- {
1523
- /**
1524
- The threshold value for bucketing small data points together.
1525
- */ key: "threshold",
1526
- value: function threshold(_) {
1527
- if (arguments.length) {
1528
- if (typeof _ === "function") {
1529
- this._threshold = _;
1530
- } else if (isFinite(_) && !isNaN(_)) {
1531
- this._threshold = constant(_ * 1);
1532
- }
1533
- return this;
1534
- } else return this._threshold;
1535
- }
1536
- },
1537
- {
1538
- /**
1539
- Accessor for the value used in the threshold algorithm.
1540
- @param key The data key used to group values for thresholding.
1541
- */ key: "thresholdKey",
1542
- value: function thresholdKey(key) {
1543
- if (arguments.length) {
1544
- if (typeof key === "function") {
1545
- this._thresholdKey = key;
1546
- } else {
1547
- this._thresholdKey = accessor(key);
1548
- }
1549
- return this;
1550
- } else return this._thresholdKey;
1551
- }
1552
- },
1553
- {
1554
- /**
1555
- The label displayed for bucketed threshold items.
1556
- */ key: "thresholdName",
1557
- value: function thresholdName(_) {
1558
- return arguments.length ? (this._thresholdName = typeof _ === "function" ? _ : constant(_), this) : this._thresholdName;
1559
- }
1560
- },
1561
- {
1562
- /**
1563
- Accessor function or string key for the time dimension of each data point.
1564
- */ key: "time",
1565
- value: function time(_) {
1566
- if (arguments.length) {
1567
- if (typeof _ === "function") {
1568
- this._time = _;
1569
- } else if (_) {
1570
- this._time = accessor(_);
1571
- if (!this._aggs[_]) {
1572
- this._aggs[_] = function(a, c) {
1573
- var v = unique(a.map(c));
1574
- return v.length === 1 ? v[0] : v;
1575
- };
1576
- }
1577
- if (this._userTime && JSON.stringify(_) !== JSON.stringify(this._userTime)) {
1578
- this._timeFilter = false;
1579
- this._timelineSelection = false;
1580
- }
1581
- this._userTime = _;
1582
- } else {
1583
- this._time = undefined;
1584
- this._userTime = undefined;
1585
- this._timeFilter = false;
1586
- this._timelineSelection = false;
1587
- }
1588
- return this;
1589
- } else return this._time;
1590
- }
1591
- },
1592
- {
1593
- /**
1594
- A filter function that limits which time periods are shown.
1595
- */ key: "timeFilter",
1596
- value: function timeFilter(_) {
1597
- return arguments.length ? (this._timeFilter = _, this) : this._timeFilter;
1598
- }
1599
- },
1600
- {
1601
- /**
1602
- Whether to display the timeline.
1603
- */ key: "timeline",
1604
- value: function timeline(_) {
1605
- return arguments.length ? (this._timeline = _, this) : this._timeline;
1606
- }
1607
- },
1608
- {
1609
- /**
1610
- Configuration object for the timeline.
1611
- */ key: "timelineConfig",
1612
- value: function timelineConfig(_) {
1613
- return arguments.length ? (this._timelineConfig = assign(this._timelineConfig, _), this) : this._timelineConfig;
1614
- }
1615
- },
1616
- {
1617
- /**
1618
- The starting time or range for the timeline. Can be a single Date/String, or an Array of 2 values representing the min and max.
1619
- */ key: "timelineDefault",
1620
- value: function timelineDefault(_) {
1621
- if (arguments.length) {
1622
- if (!_instanceof(_, Array)) _ = [
1623
- _,
1624
- _
1625
- ];
1626
- this._timelineDefault = _.map(function(d) {
1627
- return date(d);
1628
- }).filter(function(d) {
1629
- return d !== false;
1630
- });
1631
- return this;
1632
- } else return this._timelineDefault;
1633
- }
1634
- },
1635
- {
1636
- /**
1637
- Tells the timeline whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the timeline appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1638
- */ key: "timelinePadding",
1639
- value: function timelinePadding(_) {
1640
- return arguments.length ? (this._timelinePadding = typeof _ === "function" ? _ : constant(_), this) : this._timelinePadding;
1641
- }
1642
- },
1643
- {
1644
- /**
1645
- Accessor function or string for the visualization's title.
1646
- */ key: "title",
1647
- value: function title(_) {
1648
- return arguments.length ? (this._title = typeof _ === "function" ? _ : constant(_), this) : this._title;
1649
- }
1650
- },
1651
- {
1652
- /**
1653
- Configuration object for the title.
1654
- */ key: "titleConfig",
1655
- value: function titleConfig(_) {
1656
- return arguments.length ? (this._titleConfig = assign(this._titleConfig, _), this) : this._titleConfig;
1657
- }
1658
- },
1659
- {
1660
- /**
1661
- Tells the title whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the title appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1662
- */ key: "titlePadding",
1663
- value: function titlePadding(_) {
1664
- return arguments.length ? (this._titlePadding = typeof _ === "function" ? _ : constant(_), this) : this._titlePadding;
1665
- }
1666
- },
1667
- {
1668
- /**
1669
- Whether to display tooltips on hover.
1670
- */ key: "tooltip",
1671
- value: function tooltip(_) {
1672
- return arguments.length ? (this._tooltip = typeof _ === "function" ? _ : constant(_), this) : this._tooltip;
1673
- }
1674
- },
1675
- {
1676
- /**
1677
- Configuration object for the tooltip.
1678
- */ key: "tooltipConfig",
1679
- value: function tooltipConfig(_) {
1680
- return arguments.length ? (this._tooltipConfig = assign(this._tooltipConfig, _), this) : this._tooltipConfig;
1681
- }
1682
- },
1683
- {
1684
- /**
1685
- Accessor function or string key for the total value displayed in the visualization.
1686
- */ key: "total",
1687
- value: function total(_) {
1688
- if (arguments.length) {
1689
- if (typeof _ === "function") this._total = _;
1690
- else if (_) this._total = accessor(_);
1691
- else this._total = false;
1692
- return this;
1693
- } else return this._total;
1694
- }
1695
- },
1696
- {
1697
- /**
1698
- Configuration object for the total bar.
1699
- */ key: "totalConfig",
1700
- value: function totalConfig(_) {
1701
- return arguments.length ? (this._totalConfig = assign(this._totalConfig, _), this) : this._totalConfig;
1702
- }
1703
- },
1704
- {
1705
- /**
1706
- Formatter function for the value in the total bar.
1707
- */ key: "totalFormat",
1708
- value: function totalFormat(_) {
1709
- return arguments.length ? (this._totalFormat = _, this) : this._totalFormat;
1710
- }
1711
- },
1712
- {
1713
- /**
1714
- Tells the total whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the total appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
1715
- */ key: "totalPadding",
1716
- value: function totalPadding(_) {
1717
- return arguments.length ? (this._totalPadding = typeof _ === "function" ? _ : constant(_), this) : this._totalPadding;
1718
- }
1719
- },
1720
- {
1721
- /**
1722
- The overall width of the visualization in pixels.
1723
- */ key: "width",
1724
- value: function width(_) {
1725
- return arguments.length ? (this._width = _, this) : this._width;
1726
- }
1727
- },
1728
- {
1729
- /**
1730
- Toggles the ability to zoom/pan the visualization. Certain parameters for zooming are required to be hooked up on a visualization by visualization basis.
1731
- */ key: "zoom",
1732
- value: function zoom(_) {
1733
- return arguments.length ? (this._zoom = _, this) : this._zoom;
1734
- }
1735
- },
1736
- {
1737
- /**
1738
- The pixel stroke-width of the zoom brush area.
1739
- */ key: "zoomBrushHandleSize",
1740
- value: function zoomBrushHandleSize(_) {
1741
- return arguments.length ? (this._zoomBrushHandleSize = _, this) : this._zoomBrushHandleSize;
1742
- }
1743
- },
1744
- {
1745
- /**
1746
- An object containing CSS key/value pairs that is used to style the outer handle area of the zoom brush. Passing `false` will remove all default styling.
1747
- */ key: "zoomBrushHandleStyle",
1748
- value: function zoomBrushHandleStyle(_) {
1749
- return arguments.length ? (this._zoomBrushHandleStyle = _, this) : this._zoomBrushHandleStyle;
1750
- }
1751
- },
1752
- {
1753
- /**
1754
- An object containing CSS key/value pairs that is used to style the inner selection area of the zoom brush. Passing `false` will remove all default styling.
1755
- */ key: "zoomBrushSelectionStyle",
1756
- value: function zoomBrushSelectionStyle(_) {
1757
- return arguments.length ? (this._zoomBrushSelectionStyle = _, this) : this._zoomBrushSelectionStyle;
1758
- }
1759
- },
1760
- {
1761
- /**
1762
- An object containing CSS key/value pairs that is used to style each zoom control button (`.zoom-in`, `.zoom-out`, `.zoom-reset`, and `.zoom-brush`). Passing `false` will remove all default styling.
1763
- */ key: "zoomControlStyle",
1764
- value: function zoomControlStyle(_) {
1765
- return arguments.length ? (this._zoomControlStyle = _, this) : this._zoomControlStyle;
1766
- }
1767
- },
1768
- {
1769
- /**
1770
- An object containing CSS key/value pairs that is used to style each zoom control button when active (`.zoom-in`, `.zoom-out`, `.zoom-reset`, and `.zoom-brush`). Passing `false` will remove all default styling.
1771
- */ key: "zoomControlStyleActive",
1772
- value: function zoomControlStyleActive(_) {
1773
- return arguments.length ? (this._zoomControlStyleActive = _, this) : this._zoomControlStyleActive;
1774
- }
1775
- },
1776
- {
1777
- /**
1778
- An object containing CSS key/value pairs that is used to style each zoom control button on hover (`.zoom-in`, `.zoom-out`, `.zoom-reset`, and `.zoom-brush`). Passing `false` will remove all default styling.
1779
- */ key: "zoomControlStyleHover",
1780
- value: function zoomControlStyleHover(_) {
1781
- return arguments.length ? (this._zoomControlStyleHover = _, this) : this._zoomControlStyleHover;
1782
- }
1783
- },
1784
- {
1785
- /**
1786
- The multiplier that is used in with the control buttons when zooming in and out.
1787
- */ key: "zoomFactor",
1788
- value: function zoomFactor(_) {
1789
- return arguments.length ? (this._zoomFactor = _, this) : this._zoomFactor;
1790
- }
1791
- },
1792
- {
1793
- /**
1794
- The max zoom scale.
1795
- */ key: "zoomMax",
1796
- value: function zoomMax(_) {
1797
- return arguments.length ? (this._zoomMax = _, this) : this._zoomMax;
1798
- }
1799
- },
1800
- {
1801
- /**
1802
- Toggles panning.
1803
- */ key: "zoomPan",
1804
- value: function zoomPan(_) {
1805
- return arguments.length ? (this._zoomPan = _, this) : this._zoomPan;
1806
- }
1807
- },
1808
- {
1809
- /**
1810
- A pixel value to be used to pad all sides of a zoomed area.
1811
- */ key: "zoomPadding",
1812
- value: function zoomPadding(_) {
1813
- return arguments.length ? (this._zoomPadding = _, this) : this._zoomPadding;
1814
- }
1815
- },
1816
- {
1817
- /**
1818
- Toggles scroll zooming.
1819
- */ key: "zoomScroll",
1820
- value: function zoomScroll(_) {
1821
- return arguments.length ? (this._zoomScroll = _, this) : this._zoomScroll;
1822
- }
1823
- }
1824
- ]);
1825
- return Viz;
1826
- }(BaseClass);
1827
- /**
1828
- Creates an x/y plot based on an array of data. See [this example](https://d3plus.org/examples/d3plus-treemap/getting-started/) for help getting started using the treemap generator.
1829
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1830
- export { Viz as default };
1831
-
1832
- //# sourceMappingURL=Viz.js.map