@d3plus/core 3.1.5 → 4.0.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 +9922 -78537
  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 +639 -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 +72 -31
  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 +70 -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 +17 -9
  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 +156 -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 +230 -3
  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 +31148 -19470
  501. package/umd/d3plus-core.full.js.map +1 -1
  502. package/umd/d3plus-core.full.min.js +5315 -2939
  503. package/umd/d3plus-core.js +17379 -10575
  504. package/umd/d3plus-core.js.map +1 -1
  505. package/umd/d3plus-core.min.js +3470 -1873
  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 -1454
  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,1454 +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 _possible_constructor_return(self, call) {
115
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
116
- return call;
117
- }
118
- return _assert_this_initialized(self);
119
- }
120
- function _set_prototype_of(o, p) {
121
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
122
- o.__proto__ = p;
123
- return o;
124
- };
125
- return _set_prototype_of(o, p);
126
- }
127
- function _sliced_to_array(arr, i) {
128
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
129
- }
130
- function _to_consumable_array(arr) {
131
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
132
- }
133
- function _type_of(obj) {
134
- "@swc/helpers - typeof";
135
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
136
- }
137
- function _unsupported_iterable_to_array(o, minLen) {
138
- if (!o) return;
139
- if (typeof o === "string") return _array_like_to_array(o, minLen);
140
- var n = Object.prototype.toString.call(o).slice(8, -1);
141
- if (n === "Object" && o.constructor) n = o.constructor.name;
142
- if (n === "Map" || n === "Set") return Array.from(n);
143
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
144
- }
145
- function _is_native_reflect_construct() {
146
- try {
147
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
148
- } catch (_) {}
149
- return (_is_native_reflect_construct = function() {
150
- return !!result;
151
- })();
152
- }
153
- import { extent, max, min, range as d3Range, sum } from "d3-array";
154
- import { timeFormat, timeFormatDefaultLocale } from "d3-time-format";
155
- import * as scales from "d3-scale";
156
- import { select } from "d3-selection";
157
- import { transition } from "d3-transition";
158
- // @ts-ignore
159
- import pkg from "open-color/open-color.js";
160
- var openColor = pkg.theme;
161
- import { colorContrast, colorDefaults } from "@d3plus/color";
162
- import { assign, attrize, backgroundColor, date, elem, rtl as detectRTL } from "@d3plus/dom";
163
- import { formatAbbreviate, formatDate } from "@d3plus/format";
164
- import { formatLocale, locale } from "@d3plus/locales";
165
- import { closest } from "@d3plus/math";
166
- import { fontFamily as d3plusFontFamily, textWrap } from "@d3plus/text";
167
- import { TextBox } from "../components/index.js";
168
- import * as shapes from "../shapes/index.js";
169
- import { configPrep, BaseClass, constant } from "../utils/index.js";
170
- /* catches for -0 and less*/ var isNegative = function isNegative(d) {
171
- return d < 0 || Object.is(d, -0);
172
- };
173
- var floorPow = function floorPow(d) {
174
- return Math.pow(10, Math.floor(Math.log10(Math.abs(d)))) * Math.pow(-1, isNegative(d) ? 1 : 0);
175
- };
176
- var ceilPow = function ceilPow(d) {
177
- return Math.pow(10, Math.ceil(Math.log10(Math.abs(d)))) * Math.pow(-1, isNegative(d) ? 1 : 0);
178
- };
179
- var fixFloat = function fixFloat(d) {
180
- var str = "".concat(d);
181
- if (str.includes("e-") || str === "0") return 0;
182
- var nineMatch = str.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);
183
- if (nineMatch) return +"".concat(nineMatch[1]).concat(+nineMatch[2] + 1);
184
- var zeroMatch = str.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);
185
- if (zeroMatch) return +"".concat(zeroMatch[1]).concat(+zeroMatch[2]);
186
- return d;
187
- };
188
- var maxTimezoneOffset = 1000 * 60 * 60 * 26;
189
- /**
190
- * Calculates ticks from a given scale (negative and/or positive)
191
- * @param {scale} scale A d3-scale object
192
- * @private
193
- */ function calculateStep(// eslint-disable-next-line @typescript-eslint/no-explicit-any
194
- scale) {
195
- var minorTicks = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
196
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
- var stepScale = scales.scaleLinear().domain([
198
- 200,
199
- 1200
200
- ]).range([
201
- 8,
202
- 28
203
- ]);
204
- var scaleRange = scale.range();
205
- var size = Math.abs(scaleRange[1] - scaleRange[0]);
206
- var step = Math.floor(stepScale(size));
207
- if (this._scale === "time") {
208
- if (this._data && this._data.length) {
209
- var dataExtent = extent(this._data);
210
- var distance = this._data.reduce(function(n, d, i, arr) {
211
- if (i) {
212
- var dist = Math.abs(d - arr[i - 1]);
213
- if (dist < n) n = dist;
214
- }
215
- return n;
216
- }, Infinity);
217
- var newStep = Math.round((dataExtent[1] - dataExtent[0]) / distance);
218
- step = min([
219
- step * (minorTicks ? 2 : 0.5),
220
- newStep
221
- ]);
222
- } else {
223
- step = minorTicks ? step * 2 : step / 2;
224
- }
225
- }
226
- return Math.floor(step);
227
- }
228
- /**
229
- * Calculates ticks from a given scale (negative and/or positive)
230
- * @param {scale} scale A d3-scale object
231
- * @private
232
- */ function calculateTicks(// eslint-disable-next-line @typescript-eslint/no-explicit-any
233
- scale) {
234
- var minorTicks = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
235
- var ticks = [];
236
- var scaleClone = scale.copy();
237
- if (this._scale === "time" && this._data.length) {
238
- var newDomain = extent(this._data);
239
- var range = newDomain.map(scale);
240
- scaleClone.domain(newDomain).range(range);
241
- }
242
- var domain = scaleClone.domain();
243
- var inverted = domain[1] < domain[0];
244
- var step = calculateStep.bind(this)(scaleClone, minorTicks);
245
- if (!minorTicks && this._scale === "log") {
246
- var roundDomain = domain.map(function(d) {
247
- return Math.log10(d) % 1 === 0 ? d : (inverted ? ceilPow : floorPow)(d);
248
- });
249
- var invertedRound = roundDomain[1] < roundDomain[0];
250
- var powers = roundDomain.map(function(d) {
251
- return (isNegative(d) ? -1 : 1) * ([
252
- -1,
253
- 1
254
- ].includes(d) || Math.abs(d) < 1 ? 1 : Math.log10(Math.abs(d)));
255
- });
256
- var powMod = Math.ceil((Math.abs(powers[1] - powers[0]) + 1) / (step * 0.65));
257
- ticks = powMod <= 1 && powers[0] === powers[1] || invertedRound !== inverted ? scaleClone.ticks(step).filter(function(d) {
258
- return +"".concat(d).replace("0.", "") % 2 === 0;
259
- }) : d3Range(powers[0], powers[1], powers[1] < powers[0] ? -1 : 1).concat([
260
- powers[1]
261
- ]).filter(function(d) {
262
- return Math.abs(d) % powMod === 0;
263
- }).map(function(d) {
264
- return +"".concat((isNegative(d) ? -1 : 1) * (d ? Math.pow(10, Math.abs(d)) : Math.sign(1 / d) > 0 ? 1 : -1)).replace(/9+/g, "1");
265
- });
266
- } else {
267
- ticks = scaleClone.ticks(step);
268
- if (!minorTicks && ![
269
- "log",
270
- "time"
271
- ].includes(this._scale) && ticks.length > 1) {
272
- var majorDiff = Math.abs(fixFloat(ticks[1] - ticks[0]) * 2);
273
- ticks = ticks.filter(function(d) {
274
- var mod = Math.abs(d) % majorDiff;
275
- var modFloat = fixFloat(mod);
276
- if (modFloat !== mod) {
277
- return !modFloat || modFloat === majorDiff;
278
- }
279
- return mod === 0;
280
- });
281
- }
282
- }
283
- // for time scale, if data array has been provided, filter out ticks that are not in the array
284
- if (this._scale === "time" && this._data.length) {
285
- var dataNumbers = this._data.map(Number);
286
- ticks = ticks.filter(function(t) {
287
- var tn = +t;
288
- return dataNumbers.find(function(n) {
289
- return n >= tn - maxTimezoneOffset && n <= tn + maxTimezoneOffset;
290
- });
291
- });
292
- }
293
- // forces min/max into ticks, if not present
294
- if (!this._d3ScaleNegative || isNegative(domain[inverted ? 1 : 0]) === ticks.some(function(d) {
295
- return isNegative(d);
296
- })) {
297
- if (!ticks.map(Number).includes(+domain[0])) {
298
- ticks.unshift(domain[0]);
299
- }
300
- }
301
- if (!this._d3ScaleNegative || isNegative(domain[inverted ? 0 : 1]) === ticks.some(function(d) {
302
- return isNegative(d);
303
- })) {
304
- if (!ticks.map(Number).includes(+domain[1])) {
305
- ticks.push(domain[1]);
306
- }
307
- }
308
- return ticks;
309
- }
310
- var Axis = /*#__PURE__*/ function(BaseClass) {
311
- "use strict";
312
- _inherits(Axis, BaseClass);
313
- function Axis() {
314
- _class_call_check(this, Axis);
315
- var _this;
316
- _this = _call_super(this, Axis), _define_property(_this, "_select", void 0), _define_property(_this, "_align", void 0), _define_property(_this, "_barConfig", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
317
- _define_property(_this, "_data", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
318
- _define_property(_this, "_domain", void 0), _define_property(_this, "_duration", void 0), _define_property(_this, "_gridConfig", void 0), _define_property(_this, "_gridLog", void 0), _define_property(_this, "_gridSize", void 0), _define_property(_this, "_grid", void 0), _define_property(_this, "_height", void 0), _define_property(_this, "_labelOffset", void 0), _define_property(_this, "_labelRotation", void 0), _define_property(_this, "_labels", void 0), _define_property(_this, "_margin", void 0), _define_property(_this, "_maxSize", void 0), _define_property(_this, "_minSize", void 0), _define_property(_this, "_orient", void 0), _define_property(_this, "_outerBounds", void 0), _define_property(_this, "_padding", void 0), _define_property(_this, "_paddingInner", void 0), _define_property(_this, "_paddingOuter", void 0), _define_property(_this, "_position", void 0), _define_property(_this, "_range", void 0), _define_property(_this, "_rounding", void 0), _define_property(_this, "_roundingInsideMinPrefix", void 0), _define_property(_this, "_roundingInsideMinSuffix", void 0), _define_property(_this, "_roundingInsideMaxPrefix", void 0), _define_property(_this, "_roundingInsideMaxSuffix", void 0), _define_property(_this, "_scale", void 0), _define_property(_this, "_scalePadding", void 0), _define_property(_this, "_shape", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
319
- _define_property(_this, "_shapeConfig", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
320
- _define_property(_this, "_tickFormat", void 0), _define_property(_this, "_ticks", void 0), _define_property(_this, "_tickSize", void 0), _define_property(_this, "_tickSuffix", void 0), _define_property(_this, "_tickUnit", void 0), _define_property(_this, "_timeLocale", void 0), _define_property(_this, "_title", void 0), _define_property(_this, "_titleClass", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
321
- _define_property(_this, "_titleConfig", void 0), _define_property(_this, "_width", void 0), // D3 scales have complex polymorphic types that vary at runtime
322
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
323
- _define_property(_this, "_d3Scale", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
324
- _define_property(_this, "_d3ScaleNegative", void 0), _define_property(_this, "_group", void 0), _define_property(_this, "_lastScale", void 0), _define_property(_this, "_availableTicks", void 0), _define_property(_this, "_visibleTicks", void 0), _define_property(_this, "_transition", void 0), _define_property(_this, "_userFormat", void 0);
325
- _this._align = "middle";
326
- _this._barConfig = {
327
- stroke: function stroke() {
328
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
329
- return colorContrast(bg);
330
- },
331
- "stroke-width": 1
332
- };
333
- _this._data = [];
334
- _this._domain = [
335
- 0,
336
- 10
337
- ];
338
- _this._duration = 600;
339
- _this._gridConfig = {
340
- stroke: function stroke() {
341
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
342
- var contrast = colorContrast(bg);
343
- return contrast === colorDefaults.dark ? openColor.colors.gray[200] : openColor.colors.gray[600];
344
- },
345
- "stroke-width": 1
346
- };
347
- _this._gridLog = false;
348
- _this._height = 400;
349
- _this._labelOffset = false;
350
- _this._labelRotation = false;
351
- _this.orient("bottom");
352
- _this._outerBounds = {
353
- width: 0,
354
- height: 0,
355
- x: 0,
356
- y: 0
357
- };
358
- _this._padding = 5;
359
- _this._paddingInner = 0.1;
360
- _this._paddingOuter = 0.1;
361
- _this._rounding = "none";
362
- _this._roundingInsideMinPrefix = "< ";
363
- _this._roundingInsideMinSuffix = "";
364
- _this._roundingInsideMaxPrefix = "";
365
- _this._roundingInsideMaxSuffix = "+";
366
- _this._scale = "linear";
367
- _this._scalePadding = 0.5;
368
- _this._shape = "Line";
369
- _this._shapeConfig = {
370
- fill: function fill() {
371
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
372
- return colorContrast(bg);
373
- },
374
- height: function height(d) {
375
- return d.tick ? 8 : 0;
376
- },
377
- label: function label(d) {
378
- return d.text;
379
- },
380
- labelBounds: function labelBounds(d) {
381
- return d.labelBounds;
382
- },
383
- labelConfig: {
384
- fontColor: function fontColor() {
385
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
386
- return colorContrast(bg);
387
- },
388
- fontResize: false,
389
- fontSize: constant(12),
390
- padding: 5,
391
- textAnchor: function textAnchor() {
392
- var rtl = detectRTL();
393
- return _this._orient === "left" ? rtl ? "start" : "end" : _this._orient === "right" ? rtl ? "end" : "start" : _this._labelRotation ? _this._orient === "bottom" ? "end" : "start" : "middle";
394
- },
395
- verticalAlign: function verticalAlign() {
396
- return _this._orient === "bottom" ? "top" : _this._orient === "top" ? "bottom" : "middle";
397
- }
398
- },
399
- r: function r(d) {
400
- return d.tick ? 4 : 0;
401
- },
402
- stroke: function stroke() {
403
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
404
- return colorContrast(bg);
405
- },
406
- strokeWidth: 1,
407
- width: function width(d) {
408
- return d.tick ? 8 : 0;
409
- }
410
- };
411
- _this._tickSize = 8;
412
- _this._tickSuffix = "normal";
413
- _this._tickUnit = 0;
414
- _this._timeLocale = undefined;
415
- _this._titleClass = new TextBox();
416
- _this._titleConfig = {
417
- fontColor: function fontColor() {
418
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
419
- return colorContrast(bg);
420
- },
421
- fontSize: 12,
422
- textAnchor: "middle"
423
- };
424
- _this._width = 400;
425
- _this._margin = {
426
- top: 0,
427
- right: 0,
428
- bottom: 0,
429
- left: 0
430
- };
431
- _this._availableTicks = [];
432
- _this._visibleTicks = [];
433
- return _this;
434
- }
435
- _create_class(Axis, [
436
- {
437
- /**
438
- Sets positioning for the axis bar.
439
- @param bar @private
440
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
441
- key: "_barPosition",
442
- value: function _barPosition(bar) {
443
- var _this__position = this._position, height = _this__position.height, x = _this__position.x, y = _this__position.y, opposite = _this__position.opposite, offset = this._margin[opposite], position = [
444
- "top",
445
- "left"
446
- ].includes(this._orient) ? this._outerBounds[y] + this._outerBounds[height] - offset : this._outerBounds[y] + offset;
447
- var x1mod = this._scale === "band" ? this._d3Scale.step() - this._d3Scale.bandwidth() : this._scale === "point" ? this._d3Scale.step() * this._d3Scale.padding() : 0;
448
- var x2mod = this._scale === "band" ? this._d3Scale.step() : this._scale === "point" ? this._d3Scale.step() * this._d3Scale.padding() : 0;
449
- var sortedDomain = (this._d3ScaleNegative ? this._d3ScaleNegative.domain() : []).concat(this._d3Scale ? this._d3Scale.domain() : []).sort(function(a, b) {
450
- return a - b;
451
- });
452
- bar.call(attrize, this._barConfig).attr("".concat(x, "1"), this._getPosition(sortedDomain[0]) - x1mod).attr("".concat(x, "2"), this._getPosition(sortedDomain[sortedDomain.length - 1]) + x2mod).attr("".concat(y, "1"), position).attr("".concat(y, "2"), position);
453
- }
454
- },
455
- {
456
- /**
457
- Returns the scale's domain, taking into account negative and positive log scales.
458
- @private
459
- */ key: "_getDomain",
460
- value: function _getDomain() {
461
- var ticks = [];
462
- if (this._d3ScaleNegative) ticks = this._d3ScaleNegative.domain();
463
- if (this._d3Scale) ticks = ticks.concat(this._d3Scale.domain());
464
- var domain = [
465
- "band",
466
- "ordinal",
467
- "point"
468
- ].includes(this._scale) ? ticks : extent(ticks);
469
- return ticks[0] > ticks[1] ? domain.reverse() : domain;
470
- }
471
- },
472
- {
473
- /**
474
- Returns a value's scale position, taking into account negative and positive log scales.
475
- @param d @private
476
- */ key: "_getPosition",
477
- value: function _getPosition(d) {
478
- if (this._scale === "log") {
479
- if (d === 0) return (this._d3Scale || this._d3ScaleNegative).range()[this._d3Scale ? 0 : 1];
480
- return (isNegative(d) ? this._d3ScaleNegative || function() {
481
- return 0;
482
- } : this._d3Scale)(d);
483
- }
484
- return this._d3Scale(d);
485
- }
486
- },
487
- {
488
- /**
489
- Returns the scale's range, taking into account negative and positive log scales.
490
- @private
491
- */ key: "_getRange",
492
- value: function _getRange() {
493
- var ticks = [];
494
- if (this._d3ScaleNegative) ticks = this._d3ScaleNegative.range();
495
- if (this._d3Scale) ticks = ticks.concat(this._d3Scale.range());
496
- return ticks[0] > ticks[1] ? extent(ticks).reverse() : extent(ticks);
497
- }
498
- },
499
- {
500
- /**
501
- Returns the scale's labels, taking into account negative and positive log scales.
502
- @private
503
- */ key: "_getLabels",
504
- value: function _getLabels() {
505
- var labels = [];
506
- if (this._d3ScaleNegative) labels = labels.concat(calculateTicks.bind(this)(this._d3ScaleNegative, false));
507
- if (this._d3Scale) labels = labels.concat(calculateTicks.bind(this)(this._d3Scale, false));
508
- if (this._scale === "log") {
509
- var diverging = labels.some(function(d) {
510
- return isNegative(d);
511
- }) && labels.some(function(d) {
512
- return d > 0;
513
- });
514
- if (diverging) {
515
- var minValue = min(_to_consumable_array(this._d3ScaleNegative.domain().map(Math.abs)).concat(_to_consumable_array(this._d3Scale.domain())));
516
- // add minValue if it does not exist, and should
517
- if (!labels.includes(minValue)) {
518
- labels.splice(labels.findIndex(function(d) {
519
- return d > minValue;
520
- }), 0, minValue);
521
- }
522
- // remove -minValue if minValue also exists
523
- if (labels.includes(-minValue) && labels.includes(minValue)) {
524
- labels.splice(labels.indexOf(-minValue), 1);
525
- }
526
- }
527
- }
528
- return labels;
529
- }
530
- },
531
- {
532
- /**
533
- Returns the scale's ticks, taking into account negative and positive log scales.
534
- @private
535
- */ key: "_getTicks",
536
- value: function _getTicks() {
537
- if ([
538
- "band",
539
- "ordinal",
540
- "point",
541
- "time"
542
- ].includes(this._scale) && this._data.length && this._data.length < this._width / 4) {
543
- return this._scale === "time" ? this._data.map(date) : this._data;
544
- }
545
- var ticks = [];
546
- if (this._d3ScaleNegative) ticks = ticks.concat(calculateTicks.bind(this)(this._d3ScaleNegative, true));
547
- if (this._d3Scale) ticks = ticks.concat(calculateTicks.bind(this)(this._d3Scale, true));
548
- if (this._scale === "log" && ticks.includes(-1) && ticks.includes(1)) ticks.splice(ticks.indexOf(-1), 1);
549
- return ticks;
550
- }
551
- },
552
- {
553
- /**
554
- Sets positioning for the grid lines.
555
- @param lines @private
556
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
557
- key: "_gridPosition",
558
- value: function _gridPosition(lines) {
559
- var last = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
560
- var _this__position = this._position, height = _this__position.height, x = _this__position.x, y = _this__position.y, opposite = _this__position.opposite, offset = this._margin[opposite], position = [
561
- "top",
562
- "left"
563
- ].includes(this._orient) ? this._outerBounds[y] + this._outerBounds[height] - offset : this._outerBounds[y] + offset, scale = last ? this._lastScale || this._getPosition.bind(this) : this._getPosition.bind(this), size = [
564
- "top",
565
- "left"
566
- ].includes(this._orient) ? offset : -offset, xDiff = this._scale === "band" ? this._d3Scale.bandwidth() / 2 : 0, xPos = function xPos(d) {
567
- return scale(d.id) + xDiff;
568
- };
569
- lines.call(attrize, this._gridConfig).attr("".concat(x, "1"), xPos).attr("".concat(x, "2"), xPos).attr("".concat(y, "1"), position).attr("".concat(y, "2"), last ? position : position + size);
570
- }
571
- },
572
- {
573
- /**
574
- Renders the current Axis to the page.
575
- @param callback Optional callback invoked after rendering completes.
576
- */ key: "render",
577
- value: function render(callback) {
578
- var _this = this;
579
- var _this1 = this;
580
- /**
581
- * Creates an SVG element to contain the axis if none
582
- * has been specified using the "select" method.
583
- */ if (this._select === void 0) {
584
- this.select(select("body").append("svg").attr("width", "".concat(this._width, "px")).attr("height", "".concat(this._height, "px")).node());
585
- }
586
- var timeLocale = this._timeLocale || locale[this._locale] || locale["en-US"];
587
- timeFormatDefaultLocale(timeLocale);
588
- /**
589
- * Declares some commonly used variables.
590
- */ var _this__position = this._position, width = _this__position.width, height = _this__position.height, x = _this__position.x, y = _this__position.y, horizontal = _this__position.horizontal, opposite = _this__position.opposite, clipId = "d3plus-Axis-clip-".concat(this._uuid), flip = [
591
- "top",
592
- "left"
593
- ].includes(this._orient), p = this._padding, parent = this._select, rangeOuter = [
594
- p,
595
- this["_".concat(width)] - p
596
- ], t = transition().duration(this._duration);
597
- var tickValue = this._shape === "Circle" ? this._shapeConfig.r : this._shape === "Rect" ? this._shapeConfig[width] : this._shapeConfig.strokeWidth;
598
- var tickGet = typeof tickValue !== "function" ? function() {
599
- return tickValue;
600
- } : tickValue;
601
- /**
602
- * Zeros out the margins for re-calculation.
603
- */ var margin = this._margin = {
604
- top: 0,
605
- right: 0,
606
- bottom: 0,
607
- left: 0
608
- };
609
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
- var labels = [], range = [], ticks = [];
611
- /**
612
- * Constructs the tick formatter function.
613
- */ var tickFormat = this._tickFormat ? this._tickFormat : function(d) {
614
- if (isNaN(d) || [
615
- "band",
616
- "ordinal",
617
- "point"
618
- ].includes(_this._scale)) {
619
- return d;
620
- } else if (_this._scale === "time") {
621
- var refData = (_this._data.length ? _this._data : _this._domain).map(function(v) {
622
- return date(v);
623
- }).filter(function(d) {
624
- return _instanceof(d, Date);
625
- }).sort(function(a, b) {
626
- return +a - +b;
627
- });
628
- return formatDate(d, refData, timeFormat).replace(/^Q/g, timeLocale.quarter);
629
- } else if (_this._scale === "linear" && _this._tickSuffix === "smallest") {
630
- var loc = _type_of(_this._locale) === "object" ? _this._locale : formatLocale[_this._locale];
631
- var separator = loc.separator, suffixes = loc.suffixes;
632
- var suff = d >= 1000 ? suffixes[_this._tickUnit + 8] : "";
633
- var tick = d / Math.pow(10, 3 * _this._tickUnit);
634
- var number = formatAbbreviate(tick, loc, ",.".concat(tick.toString().length, "r"));
635
- return "".concat(number).concat(separator).concat(suff);
636
- } else {
637
- var inverted = ticks[1] < ticks[0];
638
- var minTick = inverted ? ticks.length - 1 : 0;
639
- var maxTick = inverted ? 0 : ticks.length - 1;
640
- var prefix = _this._rounding === "inside" ? ticks.indexOf(d) === minTick ? _this._roundingInsideMinPrefix : ticks.indexOf(d) === maxTick ? _this._roundingInsideMaxPrefix : "" : "";
641
- var suffix = _this._rounding === "inside" ? ticks.indexOf(d) === minTick ? _this._roundingInsideMinSuffix : ticks.indexOf(d) === maxTick ? _this._roundingInsideMaxSuffix : "" : "";
642
- return "".concat(prefix).concat(formatAbbreviate(d, _this._locale)).concat(suffix);
643
- }
644
- };
645
- /**
646
- * (Re)calculates the internal d3 scale
647
- * @param {} newRange
648
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
649
- var setScale = function setScale() {
650
- var newRange = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _this1._range;
651
- /**
652
- * Calculates the internal "range" array to use, including
653
- * fallbacks if not specified with the "range" method.
654
- */ range = newRange ? newRange.slice() : [
655
- undefined,
656
- undefined
657
- ];
658
- var _rangeOuter = _sliced_to_array(rangeOuter, 2), minRange = _rangeOuter[0], maxRange = _rangeOuter[1];
659
- if (_this1._range) {
660
- if (_this1._range[0] !== undefined) minRange = _this1._range[0];
661
- if (_this1._range[_this1._range.length - 1] !== undefined) maxRange = _this1._range[_this1._range.length - 1];
662
- }
663
- if (range[0] === undefined || range[0] < minRange) range[0] = minRange;
664
- if (range[1] === undefined || range[1] > maxRange) range[1] = maxRange;
665
- var sizeInner = maxRange - minRange;
666
- if (_this1._scale === "ordinal" && _this1._domain.length > range.length) {
667
- if (newRange === _this1._range) {
668
- var buckets = _this1._domain.length + 1;
669
- range = d3Range(buckets).map(function(d) {
670
- return range[0] + sizeInner * (d / (buckets - 1));
671
- }).slice(1, buckets);
672
- range = range.map(function(d) {
673
- return d - range[0] / 2;
674
- });
675
- } else {
676
- var buckets1 = _this1._domain.length;
677
- var size = range[1] - range[0];
678
- range = d3Range(buckets1).map(function(d) {
679
- return range[0] + size * (d / (buckets1 - 1));
680
- });
681
- }
682
- }
683
- /**
684
- * Sets up the initial d3 scale, using this._domain and the
685
- * previously defined range variable.
686
- */ var scale = "scale".concat(_this1._scale.charAt(0).toUpperCase()).concat(_this1._scale.slice(1));
687
- var initialDomain = _this1._domain.slice();
688
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
689
- _this1._d3Scale = scales[scale]().domain(_this1._scale === "time" ? initialDomain.map(date) : initialDomain).range(range);
690
- if (_this1._rounding !== "none") {
691
- var roundDomain = function roundDomain() {
692
- var zeroLength = function zeroLength(d) {
693
- if (smallScale) {
694
- if (!d) return 0;
695
- var m = "".concat(d).match(/0\.(0*)/);
696
- if (m) return +"0.".concat(Array(m[1].length + 1).fill(0).join(""), "1");
697
- }
698
- return "".concat(Math.round(Math.abs(d))).length;
699
- };
700
- var smallScale = initialDomain.every(function(d) {
701
- return Math.abs(d) < 1;
702
- });
703
- var zeroArray = [
704
- zeroLength(initialDomain[0]),
705
- zeroLength(initialDomain[1])
706
- ].filter(Boolean).sort();
707
- var diverging = initialDomain.some(function(d) {
708
- return isNegative(d);
709
- }) && initialDomain.some(function(d) {
710
- return d > 0;
711
- });
712
- var zeros = zeroArray.length === 1 ? zeroArray[0] : zeroArray[0] > 1 && zeroArray[0] === zeroArray[1] ? zeroArray[0] - 1 : _this1._rounding === "outside" || !diverging ? zeroArray[0] + (zeroArray[1] - zeroArray[0]) / 2 : max(zeroArray);
713
- var factor = zeros < 1 ? fixFloat(zeros) : +"1".concat(Array(Math.floor(fixFloat(zeros)) - 1).fill(0).join(""));
714
- if (factor >= Math.abs(initialDomain[1] - initialDomain[0])) factor /= 2;
715
- var inverted = initialDomain[1] < initialDomain[0];
716
- var newDomain = [
717
- Math[_this1._rounding === "outside" ? inverted ? "ceil" : "floor" : inverted ? "floor" : "ceil"](initialDomain[0] / factor) * factor,
718
- Math[_this1._rounding === "outside" ? inverted ? "floor" : "ceil" : inverted ? "ceil" : "floor"](initialDomain[1] / factor) * factor
719
- ];
720
- if (_this1._scale === "log") {
721
- if (newDomain[0] === 0) newDomain[0] = initialDomain[0];
722
- if (newDomain[1] === 0) newDomain[1] = initialDomain[1];
723
- }
724
- _this1._d3Scale.domain(newDomain.map(fixFloat));
725
- };
726
- if (_this1._scale === "linear") {
727
- roundDomain.bind(_this1)();
728
- } else if (_this1._scale === "log") {
729
- var powDomain = [];
730
- var inverted = initialDomain[1] < initialDomain[0];
731
- powDomain[0] = (_this1._rounding === "outside" ? isNegative(initialDomain[0]) ? inverted ? floorPow : ceilPow : inverted ? ceilPow : floorPow : isNegative(initialDomain[0]) ? inverted ? ceilPow : floorPow : inverted ? floorPow : ceilPow)(initialDomain[0]);
732
- powDomain[1] = (_this1._rounding === "inside" ? isNegative(initialDomain[1]) ? inverted ? floorPow : ceilPow : inverted ? ceilPow : floorPow : isNegative(initialDomain[1]) ? inverted ? ceilPow : floorPow : inverted ? floorPow : ceilPow)(initialDomain[1]);
733
- var powInverted = powDomain[1] < powDomain[0];
734
- if (powDomain[0] !== powDomain[1] && powDomain.some(function(d) {
735
- return Math.abs(d) > 10;
736
- }) && powInverted === inverted) {
737
- _this1._d3Scale.domain(powDomain);
738
- } else {
739
- roundDomain.bind(_this1)();
740
- }
741
- }
742
- }
743
- if (_this1._d3Scale.padding) _this1._d3Scale.padding(_this1._scalePadding);
744
- if (_this1._d3Scale.paddingInner) _this1._d3Scale.paddingInner(_this1._paddingInner);
745
- if (_this1._d3Scale.paddingOuter) _this1._d3Scale.paddingOuter(_this1._paddingOuter);
746
- /**
747
- * Constructs a separate "negative only" scale for logarithmic
748
- * domains, as they cannot pass zero.
749
- */ _this1._d3ScaleNegative = null;
750
- if (_this1._scale === "log") {
751
- var domain = _this1._d3Scale.domain();
752
- if (domain[0] === 0) {
753
- var smallestNumber = min([
754
- min(_this1._data),
755
- Math.abs(domain[1])
756
- ]);
757
- domain[0] = smallestNumber === 0 || smallestNumber === 1 ? 1e-6 : smallestNumber <= 1 ? floorPow(smallestNumber) : 1;
758
- if (isNegative(domain[1])) domain[0] *= -1;
759
- } else if (domain[domain.length - 1] === 0) {
760
- var smallestNumber1 = min([
761
- min(_this1._data),
762
- Math.abs(domain[0])
763
- ]);
764
- domain[domain.length - 1] = smallestNumber1 === 0 || smallestNumber1 === 1 ? 1e-6 : smallestNumber1 <= 1 ? floorPow(smallestNumber1) : 1;
765
- if (isNegative(domain[0])) domain[domain.length - 1] *= -1;
766
- }
767
- var range1 = _this1._d3Scale.range();
768
- // all negatives
769
- if (isNegative(domain[0]) && isNegative(domain[domain.length - 1])) {
770
- _this1._d3ScaleNegative = _this1._d3Scale.copy().domain(domain).range(range1);
771
- _this1._d3Scale = null;
772
- } else if (domain[0] > 0 && domain[domain.length - 1] > 0) {
773
- _this1._d3Scale.domain(domain).range(range1);
774
- } else {
775
- var powers = domain.map(function(d) {
776
- return Math.log10(Math.abs(d));
777
- }).map(function(d) {
778
- return d || -1e-6;
779
- });
780
- var leftPercentage = powers[0] / sum(powers);
781
- var zero = leftPercentage * (range1[1] - range1[0]);
782
- var minPositive = min([
783
- min(_this1._data.filter(function(d) {
784
- return d >= 0;
785
- })),
786
- Math.abs(domain[1])
787
- ]);
788
- if (minPositive === 1) minPositive = 1e-6;
789
- var minNegative = min([
790
- min(_this1._data.filter(isNegative)),
791
- Math.abs(domain[0])
792
- ]);
793
- if (minNegative === 1) minNegative = 1e-6;
794
- var minPosPow = minPositive === 0 ? 1e-6 : minPositive <= 1 ? floorPow(minPositive) : 1;
795
- var minNegPow = minNegative === 0 ? -1e-6 : minNegative <= 1 ? floorPow(minNegative) : 1;
796
- var minValue = min([
797
- Math.abs(minPosPow),
798
- Math.abs(minNegPow)
799
- ]);
800
- _this1._d3ScaleNegative = _this1._d3Scale.copy();
801
- (isNegative(domain[0]) ? _this1._d3Scale : _this1._d3ScaleNegative).domain([
802
- isNegative(domain[0]) ? minValue : -minValue,
803
- domain[1]
804
- ]).range([
805
- range1[0] + zero,
806
- range1[1]
807
- ]);
808
- (isNegative(domain[0]) ? _this1._d3ScaleNegative : _this1._d3Scale).domain([
809
- domain[0],
810
- isNegative(domain[0]) ? -minValue : minValue
811
- ]).range([
812
- range1[0],
813
- range1[0] + zero
814
- ]);
815
- }
816
- }
817
- /**
818
- * Determines the of values array to use
819
- * for the "ticks" and the "labels"
820
- */ ticks = (_this1._ticks ? _this1._scale === "time" ? _this1._ticks.map(date) : _this1._ticks : (_this1._d3Scale ? _this1._d3Scale.ticks : _this1._d3ScaleNegative.ticks) ? _this1._getTicks() : _this1._domain).slice();
821
- labels = (_this1._labels ? _this1._scale === "time" ? _this1._labels.map(date) : _this1._labels : (_this1._d3Scale ? _this1._d3Scale.ticks : _this1._d3ScaleNegative.ticks) ? _this1._getLabels() : ticks).slice();
822
- if (_this1._scale === "time") {
823
- ticks = ticks.map(Number);
824
- labels = labels.map(Number);
825
- }
826
- ticks = ticks.sort(function(a, b) {
827
- return _this1._getPosition(a) - _this1._getPosition(b);
828
- });
829
- labels = labels.sort(function(a, b) {
830
- return _this1._getPosition(a) - _this1._getPosition(b);
831
- });
832
- /**
833
- * Get the smallest suffix.
834
- */ if (_this1._scale === "linear" && _this1._tickSuffix === "smallest") {
835
- var suffixes = labels.filter(function(d) {
836
- return d >= 1000;
837
- });
838
- if (suffixes.length > 0) {
839
- var _Math;
840
- var minVal = (_Math = Math).min.apply(_Math, _to_consumable_array(suffixes));
841
- var i = 1;
842
- while(i && i < 7){
843
- var n = Math.pow(10, 3 * i);
844
- if (minVal / n >= 1) {
845
- _this1._tickUnit = i;
846
- i += 1;
847
- } else {
848
- break;
849
- }
850
- }
851
- }
852
- }
853
- /**
854
- * Removes ticks when they overlap other ticks.
855
- */ var pixels = [];
856
- _this1._availableTicks = ticks;
857
- ticks.forEach(function(d, i) {
858
- var s = tickGet({
859
- id: d,
860
- tick: true
861
- }, i);
862
- if (_this1._shape === "Circle") s *= 2;
863
- var t = _this1._getPosition(d);
864
- if (!pixels.length || Math.abs(closest(t, pixels.filter(function(p) {
865
- return p !== false;
866
- })) - t) > s * 2) pixels.push(t);
867
- else pixels.push(false);
868
- });
869
- ticks = ticks.filter(function(_d, i) {
870
- return pixels[i] !== false;
871
- });
872
- _this1._visibleTicks = ticks;
873
- };
874
- setScale();
875
- /**
876
- * Pre-calculates the size of the title, if defined, in order
877
- * to adjust the internal margins.
878
- */ if (this._title) {
879
- var _this__titleConfig = this._titleConfig, fontFamily = _this__titleConfig.fontFamily, fontSize = _this__titleConfig.fontSize, lineHeight = _this__titleConfig.lineHeight;
880
- var titleWrap = textWrap().fontFamily(typeof fontFamily === "function" ? fontFamily() : fontFamily).fontSize(typeof fontSize === "function" ? fontSize() : fontSize).lineHeight(typeof lineHeight === "function" ? lineHeight() : lineHeight).width(range[range.length - 1] - range[0] - p * 2)// eslint-disable-next-line @typescript-eslint/no-explicit-any
881
- .height(this["_".concat(height)] - this._tickSize - p * 2);
882
- var lines = titleWrap(this._title).lines.length;
883
- margin[this._orient] = lines * titleWrap.lineHeight() + p;
884
- }
885
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
886
- var hBuff = this._shape === "Circle" ? typeof this._shapeConfig.r === "function" ? this._shapeConfig.r({
887
- tick: true
888
- }) : this._shapeConfig.r : this._shape === "Rect" ? typeof this._shapeConfig[height] === "function" ? this._shapeConfig[height]({
889
- tick: true
890
- }) : this._shapeConfig[height] : this._tickSize, // eslint-disable-next-line @typescript-eslint/no-explicit-any
891
- wBuff = tickGet({
892
- tick: true
893
- });
894
- if (typeof hBuff === "function") hBuff = max(ticks.map(hBuff));
895
- if (this._shape === "Rect") hBuff /= 2;
896
- if (typeof wBuff === "function") wBuff = max(ticks.map(wBuff));
897
- if (this._shape !== "Circle") wBuff /= 2;
898
- /**
899
- * Calculates the text wrapping and size of a given textData object.
900
- * @param {Object} datum
901
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
902
- var calculateLabelSize = function calculateLabelSize(datum) {
903
- var d = datum.d, i = datum.i, fF = datum.fF, fP = datum.fP, fS = datum.fS, rotate = datum.rotate, space = datum.space;
904
- var h = rotate ? "width" : "height", w = rotate ? "height" : "width";
905
- var wSize = min([
906
- _this._maxSize,
907
- _this._width
908
- ]);
909
- var hSize = min([
910
- _this._maxSize,
911
- _this._height
912
- ]);
913
- var wrap = textWrap().fontFamily(fF).fontSize(fS).lineHeight(_this._shapeConfig.lineHeight ? _this._shapeConfig.lineHeight(d, i) : undefined);
914
- wrap[w](horizontal ? space : wSize - hBuff - p - _this._margin.left - _this._margin.right);
915
- wrap[h](horizontal ? hSize - hBuff - p - _this._margin.top - _this._margin.bottom : space);
916
- var res = wrap(tickFormat(d));
917
- res.lines = res.lines.filter(function(d) {
918
- return d !== "";
919
- });
920
- res.width = res.lines.length ? Math.ceil(max(res.widths)) : 0;
921
- res.height = res.lines.length ? Math.ceil(res.lines.length * wrap.lineHeight()) + fP : 0;
922
- return res;
923
- };
924
- /** Calculates label offsets*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
925
- var calculateOffset = function calculateOffset() {
926
- var arr = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
927
- var offset = 0;
928
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
929
- arr.forEach(function(datum) {
930
- var prev = arr[datum.i - 1];
931
- var h = datum.rotate && horizontal || !datum.rotate && !horizontal ? "width" : "height", w = datum.rotate && horizontal || !datum.rotate && !horizontal ? "height" : "width";
932
- if (!prev) {
933
- offset = 1;
934
- } else if (prev.position + prev[w] / 2 > datum.position - datum[w] / 2) {
935
- if (offset) {
936
- datum.offset = prev[h];
937
- offset = 0;
938
- } else offset = 1;
939
- }
940
- });
941
- };
942
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
943
- var textData = [];
944
- var createTextData = function createTextData() {
945
- var offset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
946
- var fontSize = _this1._shapeConfig.labelConfig.fontSize;
947
- var fontFamily = _this1._shapeConfig.labelConfig.fontFamily || d3plusFontFamily;
948
- var fontPadding = _this1._shapeConfig.labelConfig.padding;
949
- /**
950
- * Calculates the space each label would take up, given
951
- * the provided this._space size.
952
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
953
- textData = labels.map(function(d, i) {
954
- var fF = typeof fontFamily === "function" ? fontFamily(d, i) : fontFamily, fP = typeof fontPadding === "function" ? fontPadding(d, i) : fontPadding, fS = typeof fontSize === "function" ? fontSize(d, i) : fontSize, position = _this1._getPosition(d);
955
- var lineHeight = _this1._shapeConfig.lineHeight ? _this1._shapeConfig.lineHeight(d, i) : fS * 1.4;
956
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
957
- var datum = {
958
- d: d,
959
- i: i,
960
- fF: fF,
961
- fP: fP,
962
- fS: fS,
963
- lineHeight: lineHeight,
964
- position: position,
965
- rotate: _this1._labelRotation
966
- };
967
- return datum;
968
- });
969
- var maxSpace = _this1._scale === "band" ? _this1._d3Scale.bandwidth() : textData.reduce(function(s, d, i) {
970
- var position = d.position;
971
- var prevPosition = !i ? textData.length === 1 ? rangeOuter[0] : position - (textData[i + 1].position - position) : position - (position - textData[i - 1].position);
972
- var prevSpace = Math.abs(position - prevPosition);
973
- var nextPosition = i == textData.length - 1 ? textData.length === 1 ? rangeOuter[1] : position + (position - textData[i - 1].position) : position - (position - textData[i + 1].position);
974
- var nextSpace = Math.abs(position - nextPosition);
975
- var mod = _this1._scale === "point" ? 1 : 2;
976
- return max([
977
- max([
978
- prevSpace,
979
- nextSpace
980
- ]) * mod,
981
- s
982
- ]);
983
- }, 0);
984
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
985
- textData = textData.map(function(datum) {
986
- datum.space = maxSpace - datum.fP * 2;
987
- var res = calculateLabelSize(datum);
988
- return Object.assign(res, datum);
989
- });
990
- var reverseTextData = textData.slice().reverse();
991
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
992
- textData.forEach(function(datum) {
993
- var fP = datum.fP, i = datum.i, position = datum.position;
994
- var sizeName = horizontal ? "width" : "height";
995
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
996
- var prev = i ? reverseTextData.find(function(t) {
997
- return t.i < i && !t.truncated;
998
- }) : false;
999
- if (i === textData.length - 1) {
1000
- while(prev && position - datum[sizeName] / 2 - fP < prev.position + prev[sizeName] / 2){
1001
- prev.truncated = true;
1002
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1003
- prev = reverseTextData.find(function(t) {
1004
- return t.i < i && !t.truncated;
1005
- });
1006
- }
1007
- }
1008
- datum.truncated = prev ? position - datum[sizeName] / 2 - fP < prev.position + prev[sizeName] / 2 : false;
1009
- });
1010
- if (offset > 1) calculateOffset(textData);
1011
- };
1012
- createTextData();
1013
- var offsetEnabled = // eslint-disable-next-line @typescript-eslint/no-explicit-any
1014
- this._labelOffset && textData.some(function(d) {
1015
- return d.truncated;
1016
- });
1017
- if (offsetEnabled) createTextData(2);
1018
- /**
1019
- * "spillover" will contain the pixel spillover of the first and last label,
1020
- * and then adjust the scale range accordingly.
1021
- */ var spillovers = [
1022
- 0,
1023
- 1
1024
- ].map(function(index) {
1025
- var datum = textData[index ? textData.length - 1 : 0];
1026
- if (!datum) return 0;
1027
- var dHeight = datum.height, position = datum.position, rotate = datum.rotate, dWidth = datum.width;
1028
- var compPosition = index ? rangeOuter[1] : rangeOuter[0];
1029
- var halfSpace = (rotate || !horizontal ? dHeight : dWidth) / 2;
1030
- if (Math.abs(position - compPosition) >= halfSpace) return 0;
1031
- var spill = halfSpace - (position - compPosition);
1032
- return Math.abs(spill);
1033
- });
1034
- var _range = _sliced_to_array(range, 2), first = _range[0], last = _range[1];
1035
- var newRange = [
1036
- first + spillovers[0],
1037
- last - spillovers[1]
1038
- ];
1039
- if (this._range) {
1040
- if (this._range[0] !== undefined) newRange[0] = this._range[0];
1041
- if (this._range[this._range.length - 1] !== undefined) newRange[1] = this._range[this._range.length - 1];
1042
- }
1043
- if (newRange[0] !== first || newRange[1] !== last) {
1044
- setScale(newRange);
1045
- createTextData(offsetEnabled ? 2 : 1);
1046
- }
1047
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1048
- var labelHeight = max(textData, function(t) {
1049
- return t.height;
1050
- }) || 0;
1051
- this._labelRotation = horizontal && this._labelRotation === undefined ? textData.some(function(datum) {
1052
- var i = datum.i, dH = datum.height, position = datum.position, truncated = datum.truncated;
1053
- var prev = textData[i - 1];
1054
- return truncated || i && prev.position + prev.height / 2 > position - dH / 2;
1055
- }) : this._labelRotation;
1056
- var globalOffset = this._labelOffset ? max(textData, function(d) {
1057
- return d.offset || 0;
1058
- }) : 0;
1059
- textData.forEach(// eslint-disable-next-line @typescript-eslint/no-explicit-any
1060
- function(datum) {
1061
- return datum.offset = datum.offset ? globalOffset : 0;
1062
- });
1063
- var tBuff = this._shape === "Line" ? 0 : hBuff;
1064
- var _obj;
1065
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1066
- var bounds = this._outerBounds = (_obj = {}, _define_property(_obj, height, // eslint-disable-next-line @typescript-eslint/no-explicit-any
1067
- (max(textData, function(t) {
1068
- return Math.ceil(t[t.rotate || !horizontal ? "width" : "height"] + t.offset);
1069
- }) || 0) + (textData.length ? p : 0)), _define_property(_obj, width, rangeOuter[rangeOuter.length - 1] - rangeOuter[0]), _define_property(_obj, x, rangeOuter[0]), _obj);
1070
- bounds[height] = max([
1071
- this._minSize,
1072
- bounds[height]
1073
- ]);
1074
- margin[this._orient] += hBuff;
1075
- margin[opposite] = this._gridSize !== undefined ? max([
1076
- this._gridSize,
1077
- tBuff
1078
- ]) : this["_".concat(height)] - margin[this._orient] - bounds[height] - p;
1079
- bounds[height] += margin[opposite] + margin[this._orient];
1080
- bounds[y] = this._align === "start" ? this._padding : this._align === "end" ? this["_".concat(height)] - bounds[height] - this._padding : this["_".concat(height)] / 2 - bounds[height] / 2;
1081
- var group = elem("g#d3plus-Axis-".concat(this._uuid), {
1082
- parent: parent
1083
- });
1084
- this._group = group;
1085
- var grid = elem("g.grid", {
1086
- parent: group
1087
- }).selectAll("line").data((this._gridSize !== 0 ? this._grid || this._scale === "log" && !this._gridLog ? labels : ticks : []).map(function(d) {
1088
- return {
1089
- id: d
1090
- };
1091
- }), // eslint-disable-next-line @typescript-eslint/no-explicit-any
1092
- function(d) {
1093
- return d.id;
1094
- });
1095
- grid.exit().transition(t).attr("opacity", 0).call(this._gridPosition.bind(this)).remove();
1096
- grid.enter().append("line").attr("opacity", 0).attr("clip-path", "url(#".concat(clipId, ")")).call(this._gridPosition.bind(this), true).merge(grid).transition(t).attr("opacity", 1).call(this._gridPosition.bind(this));
1097
- var labelOnly = labels.filter(function(d, i) {
1098
- return textData[i].lines.length && !ticks.includes(d);
1099
- });
1100
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1101
- var rotated = textData.some(function(d) {
1102
- return d.rotate;
1103
- });
1104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1105
- var tickData = ticks.concat(labelOnly).map(function(d) {
1106
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1107
- var data = textData.find(function(td) {
1108
- return td.d === d;
1109
- });
1110
- var xPos = _this._getPosition(d);
1111
- var space = data ? data.space : 0;
1112
- var lines = data ? data.lines.length : 1;
1113
- var lineHeight = data ? data.lineHeight : 1;
1114
- var fP = data ? data.fP : 0;
1115
- var labelOffset = data && _this._labelOffset ? data.offset : 0;
1116
- var labelWidth = horizontal ? space : bounds.width - margin[_this._position.opposite] - hBuff - margin[_this._orient] + p;
1117
- var offset = margin[opposite], size = (hBuff + labelOffset) * (flip ? -1 : 1), yPos = flip ? bounds[y] + bounds[height] - offset : bounds[y] + offset;
1118
- var _obj;
1119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1120
- var tickConfig = (_obj = {
1121
- id: d,
1122
- labelBounds: rotated && data ? {
1123
- x: -data.width / 2 + data.fS / 4,
1124
- y: _this._orient === "bottom" ? size + (data.width - lineHeight * lines) / 2 + fP : size * 2 - (data.width + lineHeight * lines) / 2 + fP,
1125
- width: data.width,
1126
- height: data.height
1127
- } : {
1128
- x: horizontal ? -space / 2 : _this._orient === "left" ? -labelWidth - p + size : size + p,
1129
- y: horizontal ? _this._orient === "bottom" ? size + fP : size - labelHeight - fP : -space / 2,
1130
- width: horizontal ? space : labelWidth,
1131
- height: horizontal ? labelHeight : space
1132
- },
1133
- rotate: data ? data.rotate : false,
1134
- size: labels.includes(d) || _this._scale === "log" && Math.log10(Math.abs(d)) % 1 === 0 ? size : ticks.includes(d) ? Math.ceil(size / 2) : _this._data.find(function(t) {
1135
- return +t === d;
1136
- }) ? Math.ceil(size / 4) : 0,
1137
- text: // eslint-disable-next-line @typescript-eslint/no-explicit-any
1138
- !(data || {}).truncated && labels.includes(d) ? tickFormat(d) : false,
1139
- tick: ticks.includes(d)
1140
- }, _define_property(_obj, x, xPos + (_this._scale === "band" ? _this._d3Scale.bandwidth() / 2 : 0)), _define_property(_obj, y, yPos), _obj);
1141
- return tickConfig;
1142
- });
1143
- if (this._shape === "Line") {
1144
- tickData = tickData.concat(// eslint-disable-next-line @typescript-eslint/no-explicit-any
1145
- tickData.map(function(d) {
1146
- var dupe = Object.assign({}, d);
1147
- dupe[y] += d.size;
1148
- return dupe;
1149
- }));
1150
- }
1151
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1152
- new shapes[this._shape]().data(tickData).duration(this._duration).labelConfig({
1153
- ellipsis: function ellipsis(d) {
1154
- return d && d.length ? "".concat(d, "...") : "";
1155
- },
1156
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1157
- rotate: function rotate(d) {
1158
- return d.rotate ? -90 : 0;
1159
- }
1160
- }).select(elem("g.ticks", {
1161
- parent: group
1162
- }).node())// eslint-disable-next-line @typescript-eslint/no-explicit-any
1163
- .config(configPrep.bind(this)(this._shapeConfig)).labelConfig({
1164
- padding: 0
1165
- }).render();
1166
- var bar = group.selectAll("line.bar").data([
1167
- null
1168
- ]);
1169
- bar.enter().append("line").attr("class", "bar").attr("opacity", 0).call(this._barPosition.bind(this)).merge(bar).transition(t).attr("opacity", 1).call(this._barPosition.bind(this));
1170
- this._titleClass.data(this._title ? [
1171
- {
1172
- text: this._title
1173
- }
1174
- ] : []).duration(this._duration).height(margin[this._orient]).rotate(this._orient === "left" ? -90 : this._orient === "right" ? 90 : 0).select(elem("g.d3plus-Axis-title", {
1175
- parent: group
1176
- }).node()).text(function(d) {
1177
- return d.text;
1178
- }).verticalAlign("middle").width(range[range.length - 1] - range[0]).x(horizontal ? range[0] : this._orient === "left" ? bounds.x + margin.left / 2 - (range[range.length - 1] - range[0]) / 2 : bounds.x + bounds.width - margin.right / 2 - (range[range.length - 1] - range[0]) / 2).y(horizontal ? this._orient === "bottom" ? bounds.y + bounds.height - margin.bottom : bounds.y : range[0] + (range[range.length - 1] - range[0]) / 2 - margin[this._orient] / 2)// eslint-disable-next-line @typescript-eslint/no-explicit-any
1179
- .config(configPrep.bind(this)(this._titleConfig)).render();
1180
- this._lastScale = this._getPosition.bind(this);
1181
- if (callback) setTimeout(callback, this._duration + 100);
1182
- return this;
1183
- }
1184
- },
1185
- {
1186
- key: "align",
1187
- value: function align(_) {
1188
- return arguments.length ? (this._align = _, this) : this._align;
1189
- }
1190
- },
1191
- {
1192
- key: "barConfig",
1193
- value: function barConfig(_) {
1194
- return arguments.length ? (this._barConfig = Object.assign(this._barConfig, _), this) : this._barConfig;
1195
- }
1196
- },
1197
- {
1198
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1199
- key: "data",
1200
- value: function data(_) {
1201
- return arguments.length ? (this._data = _, this) : this._data;
1202
- }
1203
- },
1204
- {
1205
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1206
- key: "domain",
1207
- value: function domain(_) {
1208
- return arguments.length ? (this._domain = _, this) : this._domain;
1209
- }
1210
- },
1211
- {
1212
- key: "duration",
1213
- value: function duration(_) {
1214
- return arguments.length ? (this._duration = _, this) : this._duration;
1215
- }
1216
- },
1217
- {
1218
- key: "grid",
1219
- value: function grid(_) {
1220
- return arguments.length ? (this._grid = _, this) : this._grid;
1221
- }
1222
- },
1223
- {
1224
- key: "gridConfig",
1225
- value: function gridConfig(_) {
1226
- return arguments.length ? (this._gridConfig = Object.assign(this._gridConfig, _), this) : this._gridConfig;
1227
- }
1228
- },
1229
- {
1230
- key: "gridLog",
1231
- value: function gridLog(_) {
1232
- return arguments.length ? (this._gridLog = _, this) : this._gridLog;
1233
- }
1234
- },
1235
- {
1236
- key: "gridSize",
1237
- value: function gridSize(_) {
1238
- return arguments.length ? (this._gridSize = _, this) : this._gridSize;
1239
- }
1240
- },
1241
- {
1242
- key: "height",
1243
- value: function height(_) {
1244
- return arguments.length ? (this._height = _, this) : this._height;
1245
- }
1246
- },
1247
- {
1248
- key: "labels",
1249
- value: function labels(_) {
1250
- return arguments.length ? (this._labels = _, this) : this._labels;
1251
- }
1252
- },
1253
- {
1254
- key: "labelOffset",
1255
- value: function labelOffset(_) {
1256
- return arguments.length ? (this._labelOffset = _, this) : this._labelOffset;
1257
- }
1258
- },
1259
- {
1260
- key: "labelRotation",
1261
- value: function labelRotation(_) {
1262
- return arguments.length ? (this._labelRotation = _, this) : this._labelRotation;
1263
- }
1264
- },
1265
- {
1266
- key: "maxSize",
1267
- value: function maxSize(_) {
1268
- return arguments.length ? (this._maxSize = _, this) : this._maxSize;
1269
- }
1270
- },
1271
- {
1272
- key: "minSize",
1273
- value: function minSize(_) {
1274
- return arguments.length ? (this._minSize = _, this) : this._minSize;
1275
- }
1276
- },
1277
- {
1278
- key: "orient",
1279
- value: function orient(_) {
1280
- if (arguments.length) {
1281
- var horizontal = [
1282
- "top",
1283
- "bottom"
1284
- ].includes(_), opps = {
1285
- top: "bottom",
1286
- right: "left",
1287
- bottom: "top",
1288
- left: "right"
1289
- };
1290
- this._position = {
1291
- horizontal: horizontal,
1292
- width: horizontal ? "width" : "height",
1293
- height: horizontal ? "height" : "width",
1294
- x: horizontal ? "x" : "y",
1295
- y: horizontal ? "y" : "x",
1296
- opposite: opps[_]
1297
- };
1298
- return this._orient = _, this;
1299
- }
1300
- return this._orient;
1301
- }
1302
- },
1303
- {
1304
- /**
1305
- Returns the outer bounds of the axis content. Must be called after rendering.
1306
- @example
1307
- {"width": 180, "height": 24, "x": 10, "y": 20}
1308
- */ key: "outerBounds",
1309
- value: function outerBounds() {
1310
- return this._outerBounds;
1311
- }
1312
- },
1313
- {
1314
- key: "padding",
1315
- value: function padding(_) {
1316
- return arguments.length ? (this._padding = _, this) : this._padding;
1317
- }
1318
- },
1319
- {
1320
- key: "paddingInner",
1321
- value: function paddingInner(_) {
1322
- return arguments.length ? (this._paddingInner = _, this) : this._paddingInner;
1323
- }
1324
- },
1325
- {
1326
- key: "paddingOuter",
1327
- value: function paddingOuter(_) {
1328
- return arguments.length ? (this._paddingOuter = _, this) : this._paddingOuter;
1329
- }
1330
- },
1331
- {
1332
- key: "range",
1333
- value: function range(_) {
1334
- return arguments.length ? (this._range = _, this) : this._range;
1335
- }
1336
- },
1337
- {
1338
- key: "rounding",
1339
- value: function rounding(_) {
1340
- return arguments.length ? (this._rounding = _, this) : this._rounding;
1341
- }
1342
- },
1343
- {
1344
- key: "roundingInsideMinPrefix",
1345
- value: function roundingInsideMinPrefix(_) {
1346
- return arguments.length ? (this._roundingInsideMinPrefix = _, this) : this._roundingInsideMinPrefix;
1347
- }
1348
- },
1349
- {
1350
- key: "roundingInsideMinSuffix",
1351
- value: function roundingInsideMinSuffix(_) {
1352
- return arguments.length ? (this._roundingInsideMinSuffix = _, this) : this._roundingInsideMinSuffix;
1353
- }
1354
- },
1355
- {
1356
- key: "roundingInsideMaxPrefix",
1357
- value: function roundingInsideMaxPrefix(_) {
1358
- return arguments.length ? (this._roundingInsideMaxPrefix = _, this) : this._roundingInsideMaxPrefix;
1359
- }
1360
- },
1361
- {
1362
- key: "roundingInsideMaxSuffix",
1363
- value: function roundingInsideMaxSuffix(_) {
1364
- return arguments.length ? (this._roundingInsideMaxSuffix = _, this) : this._roundingInsideMaxSuffix;
1365
- }
1366
- },
1367
- {
1368
- key: "scale",
1369
- value: function scale(_) {
1370
- return arguments.length ? (this._scale = _, this) : this._scale;
1371
- }
1372
- },
1373
- {
1374
- key: "scalePadding",
1375
- value: function scalePadding(_) {
1376
- return arguments.length ? (this._scalePadding = _, this) : this._scalePadding;
1377
- }
1378
- },
1379
- {
1380
- key: "select",
1381
- value: function select1(_) {
1382
- return arguments.length ? (this._select = select(_), this) : this._select;
1383
- }
1384
- },
1385
- {
1386
- key: "shape",
1387
- value: function shape(_) {
1388
- return arguments.length ? (this._shape = _, this) : this._shape;
1389
- }
1390
- },
1391
- {
1392
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1393
- key: "shapeConfig",
1394
- value: function shapeConfig(_) {
1395
- return arguments.length ? (this._shapeConfig = assign(this._shapeConfig, _), this) : this._shapeConfig;
1396
- }
1397
- },
1398
- {
1399
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1400
- key: "tickFormat",
1401
- value: function tickFormat(_) {
1402
- return arguments.length ? (this._tickFormat = _, this) : this._tickFormat;
1403
- }
1404
- },
1405
- {
1406
- key: "ticks",
1407
- value: function ticks(_) {
1408
- return arguments.length ? (this._ticks = _, this) : this._ticks;
1409
- }
1410
- },
1411
- {
1412
- key: "tickSize",
1413
- value: function tickSize(_) {
1414
- return arguments.length ? (this._tickSize = _, this) : this._tickSize;
1415
- }
1416
- },
1417
- {
1418
- key: "tickSuffix",
1419
- value: function tickSuffix(_) {
1420
- return arguments.length ? (this._tickSuffix = _, this) : this._tickSuffix;
1421
- }
1422
- },
1423
- {
1424
- key: "timeLocale",
1425
- value: function timeLocale(_) {
1426
- return arguments.length ? (this._timeLocale = _, this) : this._timeLocale;
1427
- }
1428
- },
1429
- {
1430
- key: "title",
1431
- value: function title(_) {
1432
- return arguments.length ? (this._title = _, this) : this._title;
1433
- }
1434
- },
1435
- {
1436
- key: "titleConfig",
1437
- value: function titleConfig(_) {
1438
- return arguments.length ? (this._titleConfig = Object.assign(this._titleConfig, _), this) : this._titleConfig;
1439
- }
1440
- },
1441
- {
1442
- key: "width",
1443
- value: function width(_) {
1444
- return arguments.length ? (this._width = _, this) : this._width;
1445
- }
1446
- }
1447
- ]);
1448
- return Axis;
1449
- }(BaseClass);
1450
- /**
1451
- Creates an SVG scale based on an array of data.
1452
- */ export { Axis as default };
1453
-
1454
- //# sourceMappingURL=Axis.js.map