@d3plus/core 3.1.6 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. package/README.md +9924 -78528
  2. package/es/index.js +8 -0
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +54 -0
  5. package/es/internal.js.map +1 -0
  6. package/es/src/charts/AreaPlot/index.js +36 -0
  7. package/es/src/charts/AreaPlot/index.js.map +1 -0
  8. package/es/src/charts/BarChart/index.js +48 -0
  9. package/es/src/charts/BarChart/index.js.map +1 -0
  10. package/es/src/charts/BoxWhisker/index.js +52 -0
  11. package/es/src/charts/BoxWhisker/index.js.map +1 -0
  12. package/es/src/charts/BumpChart/index.js +81 -0
  13. package/es/src/charts/BumpChart/index.js.map +1 -0
  14. package/es/src/charts/Donut/index.js +42 -0
  15. package/es/src/charts/Donut/index.js.map +1 -0
  16. package/es/src/charts/Geomap/applyLayout.js +208 -0
  17. package/es/src/charts/Geomap/applyLayout.js.map +1 -0
  18. package/es/src/charts/Geomap/emit.js +169 -0
  19. package/es/src/charts/Geomap/emit.js.map +1 -0
  20. package/es/src/charts/Geomap/index.js +521 -0
  21. package/es/src/charts/Geomap/index.js.map +1 -0
  22. package/es/src/charts/LinePlot/index.js +32 -0
  23. package/es/src/charts/LinePlot/index.js.map +1 -0
  24. package/es/src/charts/Matrix/applyLayout.js +92 -0
  25. package/es/src/charts/Matrix/applyLayout.js.map +1 -0
  26. package/es/src/charts/Matrix/emit.js +44 -0
  27. package/es/src/charts/Matrix/emit.js.map +1 -0
  28. package/es/src/charts/Matrix/index.js +154 -0
  29. package/es/src/charts/Matrix/index.js.map +1 -0
  30. package/es/src/charts/Network/applyLayout.js +322 -0
  31. package/es/src/charts/Network/applyLayout.js.map +1 -0
  32. package/es/src/charts/Network/emit.js +273 -0
  33. package/es/src/charts/Network/emit.js.map +1 -0
  34. package/es/src/charts/Network/index.js +422 -0
  35. package/es/src/charts/Network/index.js.map +1 -0
  36. package/es/src/charts/Pack/applyLayout.js +46 -0
  37. package/es/src/charts/Pack/applyLayout.js.map +1 -0
  38. package/es/src/charts/Pack/emit.js +116 -0
  39. package/es/src/charts/Pack/emit.js.map +1 -0
  40. package/es/src/charts/Pack/index.js +194 -0
  41. package/es/src/charts/Pack/index.js.map +1 -0
  42. package/es/src/charts/Pack/recursionCircles.js +18 -0
  43. package/es/src/charts/Pack/recursionCircles.js.map +1 -0
  44. package/es/src/charts/Pie/applyLayout.js +44 -0
  45. package/es/src/charts/Pie/applyLayout.js.map +1 -0
  46. package/es/src/charts/Pie/emit.js +111 -0
  47. package/es/src/charts/Pie/emit.js.map +1 -0
  48. package/es/src/charts/Pie/index.js +134 -0
  49. package/es/src/charts/Pie/index.js.map +1 -0
  50. package/es/src/charts/Plot/draw.js +424 -0
  51. package/es/src/charts/Plot/draw.js.map +1 -0
  52. package/es/src/charts/Plot/index.js +827 -0
  53. package/es/src/charts/Plot/index.js.map +1 -0
  54. package/es/src/charts/Plot/labelPlacement.js +36 -0
  55. package/es/src/charts/Plot/labelPlacement.js.map +1 -0
  56. package/es/src/charts/Plot/pipeline.js +594 -0
  57. package/es/src/charts/Plot/pipeline.js.map +1 -0
  58. package/es/src/charts/Plot/pipelineDomains.js +254 -0
  59. package/es/src/charts/Plot/pipelineDomains.js.map +1 -0
  60. package/es/src/charts/Plot/pipelineLineLabels.js +210 -0
  61. package/es/src/charts/Plot/pipelineLineLabels.js.map +1 -0
  62. package/es/src/charts/Plot/shapeDefaults.js +189 -0
  63. package/es/src/charts/Plot/shapeDefaults.js.map +1 -0
  64. package/es/src/charts/Plot/stackHelpers.js +52 -0
  65. package/es/src/charts/Plot/stackHelpers.js.map +1 -0
  66. package/es/src/charts/Priestley/applyLayout.js +121 -0
  67. package/es/src/charts/Priestley/applyLayout.js.map +1 -0
  68. package/es/src/charts/Priestley/emit.js +129 -0
  69. package/es/src/charts/Priestley/emit.js.map +1 -0
  70. package/es/src/charts/Priestley/index.js +97 -0
  71. package/es/src/charts/Priestley/index.js.map +1 -0
  72. package/es/src/charts/Radar/applyLayout.js +326 -0
  73. package/es/src/charts/Radar/applyLayout.js.map +1 -0
  74. package/es/src/charts/Radar/emit.js +28 -0
  75. package/es/src/charts/Radar/emit.js.map +1 -0
  76. package/es/src/charts/Radar/index.js +98 -0
  77. package/es/src/charts/Radar/index.js.map +1 -0
  78. package/es/src/charts/RadialMatrix/applyLayout.js +132 -0
  79. package/es/src/charts/RadialMatrix/applyLayout.js.map +1 -0
  80. package/es/src/charts/RadialMatrix/emit.js +33 -0
  81. package/es/src/charts/RadialMatrix/emit.js.map +1 -0
  82. package/es/src/charts/RadialMatrix/index.js +144 -0
  83. package/es/src/charts/RadialMatrix/index.js.map +1 -0
  84. package/es/src/charts/Rings/applyLayout.js +508 -0
  85. package/es/src/charts/Rings/applyLayout.js.map +1 -0
  86. package/es/src/charts/Rings/emit.js +222 -0
  87. package/es/src/charts/Rings/emit.js.map +1 -0
  88. package/es/src/charts/Rings/index.js +245 -0
  89. package/es/src/charts/Rings/index.js.map +1 -0
  90. package/es/src/charts/Sankey/applyLayout.js +107 -0
  91. package/es/src/charts/Sankey/applyLayout.js.map +1 -0
  92. package/es/src/charts/Sankey/emit.js +134 -0
  93. package/es/src/charts/Sankey/emit.js.map +1 -0
  94. package/es/src/charts/Sankey/index.js +219 -0
  95. package/es/src/charts/Sankey/index.js.map +1 -0
  96. package/es/src/charts/StackedArea/index.js +27 -0
  97. package/es/src/charts/StackedArea/index.js.map +1 -0
  98. package/es/src/charts/Tree/applyLayout.js +233 -0
  99. package/es/src/charts/Tree/applyLayout.js.map +1 -0
  100. package/es/src/charts/Tree/emit.js +257 -0
  101. package/es/src/charts/Tree/emit.js.map +1 -0
  102. package/es/src/charts/Tree/index.js +105 -0
  103. package/es/src/charts/Tree/index.js.map +1 -0
  104. package/es/src/charts/Treemap/applyLayout.js +85 -0
  105. package/es/src/charts/Treemap/applyLayout.js.map +1 -0
  106. package/es/src/charts/Treemap/emit.js +141 -0
  107. package/es/src/charts/Treemap/emit.js.map +1 -0
  108. package/es/src/charts/Treemap/index.js +177 -0
  109. package/es/src/charts/Treemap/index.js.map +1 -0
  110. package/es/src/charts/Treemap/thresholdFunction.js +112 -0
  111. package/es/src/charts/Treemap/thresholdFunction.js.map +1 -0
  112. package/es/src/charts/definition/ChartDefinition.js +12 -0
  113. package/es/src/charts/definition/ChartDefinition.js.map +1 -0
  114. package/es/src/charts/definition/applyDefinition.js +107 -0
  115. package/es/src/charts/definition/applyDefinition.js.map +1 -0
  116. package/es/src/charts/definition/makeChart.js +153 -0
  117. package/es/src/charts/definition/makeChart.js.map +1 -0
  118. package/es/src/charts/drawSteps/zoomControls.js +231 -96
  119. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  120. package/es/src/charts/events/click.legend.js +2 -2
  121. package/es/src/charts/events/click.legend.js.map +1 -1
  122. package/es/src/charts/events/click.shape.js +5 -5
  123. package/es/src/charts/events/click.shape.js.map +1 -1
  124. package/es/src/charts/events/mouseenter.js +20 -1
  125. package/es/src/charts/events/mouseenter.js.map +1 -1
  126. package/es/src/charts/events/mouseleave.js +19 -4
  127. package/es/src/charts/events/mouseleave.js.map +1 -1
  128. package/es/src/charts/events/mousemove.legend.js +10 -10
  129. package/es/src/charts/events/mousemove.legend.js.map +1 -1
  130. package/es/src/charts/events/mousemove.shape.js +14 -8
  131. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  132. package/es/src/charts/events/touchstart.body.js.map +1 -1
  133. package/es/src/charts/features/axes.js +432 -0
  134. package/es/src/charts/features/axes.js.map +1 -0
  135. package/es/src/charts/features/chartGeometry.js +66 -0
  136. package/es/src/charts/features/chartGeometry.js.map +1 -0
  137. package/es/src/charts/features/colorScaleBucket.js +92 -0
  138. package/es/src/charts/features/colorScaleBucket.js.map +1 -0
  139. package/es/src/charts/features/emitHelpers.js +217 -0
  140. package/es/src/charts/features/emitHelpers.js.map +1 -0
  141. package/es/src/charts/features/ensureZoomDom.js +71 -0
  142. package/es/src/charts/features/ensureZoomDom.js.map +1 -0
  143. package/es/src/charts/features/features.js +650 -0
  144. package/es/src/charts/features/features.js.map +1 -0
  145. package/es/src/charts/features/featuresLegend.js +180 -0
  146. package/es/src/charts/features/featuresLegend.js.map +1 -0
  147. package/es/src/charts/features/legendLabel.js +12 -0
  148. package/es/src/charts/features/legendLabel.js.map +1 -0
  149. package/es/src/charts/features/lineLabels.js +154 -0
  150. package/es/src/charts/features/lineLabels.js.map +1 -0
  151. package/es/src/charts/features/plotPaint.js +512 -0
  152. package/es/src/charts/features/plotPaint.js.map +1 -0
  153. package/es/src/charts/features/shapeEmit.js +273 -0
  154. package/es/src/charts/features/shapeEmit.js.map +1 -0
  155. package/es/src/charts/helpers/matrixData.js +3 -3
  156. package/es/src/charts/helpers/matrixData.js.map +1 -1
  157. package/es/src/charts/index.js +21 -21
  158. package/es/src/charts/index.js.map +1 -1
  159. package/es/src/charts/pipeline/resolveSpec.js +44 -0
  160. package/es/src/charts/pipeline/resolveSpec.js.map +1 -0
  161. package/es/src/charts/pipeline/runChartDraw.js +109 -0
  162. package/es/src/charts/pipeline/runChartDraw.js.map +1 -0
  163. package/es/src/charts/pipeline/runVizPipeline.js +84 -0
  164. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -0
  165. package/es/src/charts/pipeline/stages.js +103 -0
  166. package/es/src/charts/pipeline/stages.js.map +1 -0
  167. package/es/src/charts/pipeline/vizContext.js +29 -0
  168. package/es/src/charts/pipeline/vizContext.js.map +1 -0
  169. package/es/src/charts/pipeline/vizDraw.js +37 -0
  170. package/es/src/charts/pipeline/vizDraw.js.map +1 -0
  171. package/es/src/charts/pipeline/vizDrawPure.js +174 -0
  172. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -0
  173. package/es/src/charts/pipeline/vizPreDraw.js +145 -0
  174. package/es/src/charts/pipeline/vizPreDraw.js.map +1 -0
  175. package/es/src/charts/pipeline/vizPreDrawPure.js +279 -0
  176. package/es/src/charts/pipeline/vizPreDrawPure.js.map +1 -0
  177. package/es/src/charts/plotBuffers/Bar.js +4 -4
  178. package/es/src/charts/plotBuffers/Bar.js.map +1 -1
  179. package/es/src/charts/plotBuffers/Box.js +4 -4
  180. package/es/src/charts/plotBuffers/Box.js.map +1 -1
  181. package/es/src/charts/plotBuffers/Circle.js +2 -2
  182. package/es/src/charts/plotBuffers/Circle.js.map +1 -1
  183. package/es/src/charts/plotBuffers/Line.js +5 -5
  184. package/es/src/charts/plotBuffers/Line.js.map +1 -1
  185. package/es/src/charts/plotBuffers/Rect.js +2 -2
  186. package/es/src/charts/plotBuffers/Rect.js.map +1 -1
  187. package/es/src/charts/plotBuffers/discreteBuffer.js +1 -2
  188. package/es/src/charts/plotBuffers/discreteBuffer.js.map +1 -1
  189. package/es/src/charts/plotBuffers/numericBuffer.js +1 -2
  190. package/es/src/charts/plotBuffers/numericBuffer.js.map +1 -1
  191. package/es/src/charts/viz/Viz.js +985 -0
  192. package/es/src/charts/viz/Viz.js.map +1 -0
  193. package/es/src/charts/viz/VizBase.js +447 -0
  194. package/es/src/charts/viz/VizBase.js.map +1 -0
  195. package/es/src/charts/viz/VizBaseConfig.js +504 -0
  196. package/es/src/charts/viz/VizBaseConfig.js.map +1 -0
  197. package/es/src/charts/viz/interactionOpacity.js +247 -0
  198. package/es/src/charts/viz/interactionOpacity.js.map +1 -0
  199. package/es/src/charts/viz/ordinalColor.js +71 -0
  200. package/es/src/charts/viz/ordinalColor.js.map +1 -0
  201. package/es/src/charts/viz/trailCatchup.js +127 -0
  202. package/es/src/charts/viz/trailCatchup.js.map +1 -0
  203. package/es/src/charts/viz/vizDefaults.js +602 -0
  204. package/es/src/charts/viz/vizDefaults.js.map +1 -0
  205. package/es/src/charts/viz/vizRender.js +251 -0
  206. package/es/src/charts/viz/vizRender.js.map +1 -0
  207. package/es/src/charts/viz/vizTypes.js +28 -0
  208. package/es/src/charts/viz/vizTypes.js.map +1 -0
  209. package/es/src/components/Axis/Axis.js +691 -0
  210. package/es/src/components/Axis/Axis.js.map +1 -0
  211. package/es/src/components/Axis/AxisBottom.js.map +1 -0
  212. package/es/src/components/Axis/AxisLeft.js.map +1 -0
  213. package/es/src/components/Axis/AxisRight.js.map +1 -0
  214. package/es/src/components/Axis/AxisTop.js.map +1 -0
  215. package/es/src/components/Axis/axisLayout.js +208 -0
  216. package/es/src/components/Axis/axisLayout.js.map +1 -0
  217. package/es/src/components/Axis/axisLayoutLabels.js +177 -0
  218. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -0
  219. package/es/src/components/Axis/axisLayoutScale.js +374 -0
  220. package/es/src/components/Axis/axisLayoutScale.js.map +1 -0
  221. package/es/src/components/Axis/axisRender.js +535 -0
  222. package/es/src/components/Axis/axisRender.js.map +1 -0
  223. package/es/src/components/ColorScale/ColorScale.js +506 -0
  224. package/es/src/components/ColorScale/ColorScale.js.map +1 -0
  225. package/es/src/components/ColorScale/colorScaleRender.js +277 -0
  226. package/es/src/components/ColorScale/colorScaleRender.js.map +1 -0
  227. package/es/src/components/ColorScale/colorScaleScale.js +274 -0
  228. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -0
  229. package/es/src/components/Legend/Legend.js +445 -0
  230. package/es/src/components/Legend/Legend.js.map +1 -0
  231. package/es/src/components/Legend/legendConfig.js +87 -0
  232. package/es/src/components/Legend/legendConfig.js.map +1 -0
  233. package/es/src/components/Legend/legendRender.js +245 -0
  234. package/es/src/components/Legend/legendRender.js.map +1 -0
  235. package/es/src/components/Message.js.map +1 -1
  236. package/es/src/components/TextBox.js +655 -453
  237. package/es/src/components/TextBox.js.map +1 -1
  238. package/es/src/components/Timeline/Timeline.js +674 -0
  239. package/es/src/components/Timeline/Timeline.js.map +1 -0
  240. package/es/src/components/Timeline/timelineConfig.js +115 -0
  241. package/es/src/components/Timeline/timelineConfig.js.map +1 -0
  242. package/es/src/components/Timeline/timelineRender.js +267 -0
  243. package/es/src/components/Timeline/timelineRender.js.map +1 -0
  244. package/es/src/components/Tooltip.js +288 -249
  245. package/es/src/components/Tooltip.js.map +1 -1
  246. package/es/src/components/index.js +8 -8
  247. package/es/src/components/index.js.map +1 -1
  248. package/es/src/fluent.js +265 -0
  249. package/es/src/fluent.js.map +1 -0
  250. package/es/src/shapes/Area.js +96 -114
  251. package/es/src/shapes/Area.js.map +1 -1
  252. package/es/src/shapes/Bar.js +71 -86
  253. package/es/src/shapes/Bar.js.map +1 -1
  254. package/es/src/shapes/Box.js +295 -190
  255. package/es/src/shapes/Box.js.map +1 -1
  256. package/es/src/shapes/Circle.js +84 -35
  257. package/es/src/shapes/Circle.js.map +1 -1
  258. package/es/src/shapes/Image.js +164 -85
  259. package/es/src/shapes/Image.js.map +1 -1
  260. package/es/src/shapes/Line.js +51 -94
  261. package/es/src/shapes/Line.js.map +1 -1
  262. package/es/src/shapes/Path.js +33 -41
  263. package/es/src/shapes/Path.js.map +1 -1
  264. package/es/src/shapes/Rect.js +86 -37
  265. package/es/src/shapes/Rect.js.map +1 -1
  266. package/es/src/shapes/Shape.js +655 -678
  267. package/es/src/shapes/Shape.js.map +1 -1
  268. package/es/src/shapes/Whisker.js +156 -61
  269. package/es/src/shapes/Whisker.js.map +1 -1
  270. package/es/src/shapes/buildLabelData.js +125 -0
  271. package/es/src/shapes/buildLabelData.js.map +1 -0
  272. package/es/src/shapes/emitLabels.js +84 -0
  273. package/es/src/shapes/emitLabels.js.map +1 -0
  274. package/es/src/shapes/hitAreaNode.js +37 -0
  275. package/es/src/shapes/hitAreaNode.js.map +1 -0
  276. package/es/src/shapes/sceneSort.js +57 -0
  277. package/es/src/shapes/sceneSort.js.map +1 -0
  278. package/es/src/shapes/shapeConfig.js +31 -0
  279. package/es/src/shapes/shapeConfig.js.map +1 -0
  280. package/es/src/utils/BaseClass.js +35 -19
  281. package/es/src/utils/BaseClass.js.map +1 -1
  282. package/es/src/utils/D3Scale.js +16 -0
  283. package/es/src/utils/D3Scale.js.map +1 -0
  284. package/es/src/utils/D3plusConfig.js.map +1 -1
  285. package/es/src/utils/configPrep.js +8 -3
  286. package/es/src/utils/configPrep.js.map +1 -1
  287. package/es/src/utils/getProp.js +1 -1
  288. package/es/src/utils/getProp.js.map +1 -1
  289. package/es/src/utils/index.js +1 -0
  290. package/es/src/utils/index.js.map +1 -1
  291. package/es/src/utils/paintComponentScene.js +59 -0
  292. package/es/src/utils/paintComponentScene.js.map +1 -0
  293. package/es/umd-entry.js +16 -0
  294. package/es/umd-entry.js.map +1 -0
  295. package/package.json +15 -10
  296. package/types/index.d.ts +3 -1
  297. package/types/internal.d.ts +54 -0
  298. package/types/src/charts/AreaPlot/index.d.ts +10 -0
  299. package/types/src/charts/BarChart/index.d.ts +10 -0
  300. package/types/src/charts/BoxWhisker/index.d.ts +11 -0
  301. package/types/src/charts/BumpChart/index.d.ts +11 -0
  302. package/types/src/charts/ChartDefinition.d.ts +75 -0
  303. package/types/src/charts/Donut/index.d.ts +13 -0
  304. package/types/src/charts/Geomap/applyLayout.d.ts +7 -0
  305. package/types/src/charts/Geomap/emit.d.ts +7 -0
  306. package/types/src/charts/Geomap/index.d.ts +14 -0
  307. package/types/src/charts/Geomap.d.ts +6 -0
  308. package/types/src/charts/LinePlot/index.d.ts +10 -0
  309. package/types/src/charts/Matrix/applyLayout.d.ts +9 -0
  310. package/types/src/charts/Matrix/emit.d.ts +6 -0
  311. package/types/src/charts/Matrix/index.d.ts +14 -0
  312. package/types/src/charts/Matrix.d.ts +0 -26
  313. package/types/src/charts/Network/applyLayout.d.ts +10 -0
  314. package/types/src/charts/Network/emit.d.ts +6 -0
  315. package/types/src/charts/Network/index.d.ts +7 -0
  316. package/types/src/charts/Network.d.ts +0 -24
  317. package/types/src/charts/Pack/applyLayout.d.ts +16 -0
  318. package/types/src/charts/Pack/emit.d.ts +6 -0
  319. package/types/src/charts/Pack/index.d.ts +15 -0
  320. package/types/src/charts/Pack/recursionCircles.d.ts +7 -0
  321. package/types/src/charts/Pack.d.ts +0 -13
  322. package/types/src/charts/Pie/applyLayout.d.ts +8 -0
  323. package/types/src/charts/Pie/emit.d.ts +5 -0
  324. package/types/src/charts/Pie/index.d.ts +14 -0
  325. package/types/src/charts/Pie.d.ts +0 -27
  326. package/types/src/charts/Plot/draw.d.ts +2 -0
  327. package/types/src/charts/Plot/index.d.ts +167 -0
  328. package/types/src/charts/Plot/labelPlacement.d.ts +15 -0
  329. package/types/src/charts/Plot/pipeline.d.ts +70 -0
  330. package/types/src/charts/Plot/pipelineDomains.d.ts +2 -0
  331. package/types/src/charts/Plot/pipelineLineLabels.d.ts +2 -0
  332. package/types/src/charts/Plot/shapeDefaults.d.ts +64 -0
  333. package/types/src/charts/Plot/stackHelpers.d.ts +24 -0
  334. package/types/src/charts/Plot.d.ts +23 -72
  335. package/types/src/charts/Priestley/applyLayout.d.ts +21 -0
  336. package/types/src/charts/Priestley/emit.d.ts +6 -0
  337. package/types/src/charts/Priestley/index.d.ts +14 -0
  338. package/types/src/charts/Radar/applyLayout.d.ts +10 -0
  339. package/types/src/charts/Radar/emit.d.ts +7 -0
  340. package/types/src/charts/Radar/index.d.ts +14 -0
  341. package/types/src/charts/RadialMatrix/applyLayout.d.ts +11 -0
  342. package/types/src/charts/RadialMatrix/emit.d.ts +6 -0
  343. package/types/src/charts/RadialMatrix/index.d.ts +14 -0
  344. package/types/src/charts/RadialMatrix.d.ts +0 -15
  345. package/types/src/charts/Rings/applyLayout.d.ts +2 -0
  346. package/types/src/charts/Rings/emit.d.ts +7 -0
  347. package/types/src/charts/Rings/index.d.ts +15 -0
  348. package/types/src/charts/Rings.d.ts +0 -13
  349. package/types/src/charts/Sankey/applyLayout.d.ts +7 -0
  350. package/types/src/charts/Sankey/emit.d.ts +6 -0
  351. package/types/src/charts/Sankey/index.d.ts +7 -0
  352. package/types/src/charts/Sankey.d.ts +0 -4
  353. package/types/src/charts/StackedArea/index.d.ts +10 -0
  354. package/types/src/charts/Tree/applyLayout.d.ts +2 -0
  355. package/types/src/charts/Tree/emit.d.ts +7 -0
  356. package/types/src/charts/Tree/index.d.ts +14 -0
  357. package/types/src/charts/Tree.d.ts +0 -16
  358. package/types/src/charts/Treemap/applyLayout.d.ts +16 -0
  359. package/types/src/charts/Treemap/emit.d.ts +6 -0
  360. package/types/src/charts/Treemap/index.d.ts +18 -0
  361. package/types/src/charts/Treemap/thresholdFunction.d.ts +25 -0
  362. package/types/src/charts/Treemap.d.ts +4 -13
  363. package/types/src/charts/Viz.d.ts +49 -361
  364. package/types/src/charts/VizBase.d.ts +158 -0
  365. package/types/src/charts/VizBaseConfig.d.ts +148 -0
  366. package/types/src/charts/applyDefinition.d.ts +13 -0
  367. package/types/src/charts/axes.d.ts +134 -0
  368. package/types/src/charts/chartGeometry.d.ts +58 -0
  369. package/types/src/charts/definition/ChartDefinition.d.ts +84 -0
  370. package/types/src/charts/definition/applyDefinition.d.ts +13 -0
  371. package/types/src/charts/definition/makeChart.d.ts +22 -0
  372. package/types/src/charts/drawSteps/zoomControls.d.ts +25 -5
  373. package/types/src/charts/emitHelpers.d.ts +122 -0
  374. package/types/src/charts/ensureZoomDom.d.ts +39 -0
  375. package/types/src/charts/events/click.legend.d.ts +1 -1
  376. package/types/src/charts/events/click.shape.d.ts +1 -1
  377. package/types/src/charts/events/mouseenter.d.ts +1 -1
  378. package/types/src/charts/events/mouseleave.d.ts +1 -1
  379. package/types/src/charts/events/mousemove.legend.d.ts +1 -1
  380. package/types/src/charts/events/mousemove.shape.d.ts +1 -1
  381. package/types/src/charts/events/touchstart.body.d.ts +1 -1
  382. package/types/src/charts/factories.d.ts +73 -0
  383. package/types/src/charts/features/axes.d.ts +134 -0
  384. package/types/src/charts/features/chartGeometry.d.ts +58 -0
  385. package/types/src/charts/features/colorScaleBucket.d.ts +43 -0
  386. package/types/src/charts/features/colorScaleBucketShare.d.ts +16 -0
  387. package/types/src/charts/features/emitHelpers.d.ts +123 -0
  388. package/types/src/charts/features/ensureZoomDom.d.ts +39 -0
  389. package/types/src/charts/features/features.d.ts +152 -0
  390. package/types/src/charts/features/featuresLegend.d.ts +12 -0
  391. package/types/src/charts/features/legendLabel.d.ts +11 -0
  392. package/types/src/charts/features/lineLabels.d.ts +40 -0
  393. package/types/src/charts/features/plotPaint.d.ts +233 -0
  394. package/types/src/charts/features/shapeEmit.d.ts +61 -0
  395. package/types/src/charts/features.d.ts +152 -0
  396. package/types/src/charts/featuresLegend.d.ts +12 -0
  397. package/types/src/charts/helpers/matrixData.d.ts +1 -1
  398. package/types/src/charts/index.d.ts +21 -21
  399. package/types/src/charts/legendLabel.d.ts +11 -0
  400. package/types/src/charts/lineLabels.d.ts +40 -0
  401. package/types/src/charts/makeChart.d.ts +22 -0
  402. package/types/src/charts/pipeline/resolveSpec.d.ts +51 -0
  403. package/types/src/charts/pipeline/runChartDraw.d.ts +38 -0
  404. package/types/src/charts/pipeline/runVizPipeline.d.ts +31 -0
  405. package/types/src/charts/pipeline/stages.d.ts +160 -0
  406. package/types/src/charts/pipeline/vizContext.d.ts +45 -0
  407. package/types/src/charts/pipeline/vizDraw.d.ts +25 -0
  408. package/types/src/charts/pipeline/vizDrawPure.d.ts +46 -0
  409. package/types/src/charts/pipeline/vizPreDraw.d.ts +22 -0
  410. package/types/src/charts/pipeline/vizPreDrawPure.d.ts +68 -0
  411. package/types/src/charts/plotBuffers/Bar.d.ts +6 -5
  412. package/types/src/charts/plotBuffers/Box.d.ts +6 -5
  413. package/types/src/charts/plotBuffers/Circle.d.ts +6 -5
  414. package/types/src/charts/plotBuffers/Line.d.ts +6 -5
  415. package/types/src/charts/plotBuffers/Rect.d.ts +6 -5
  416. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +2 -1
  417. package/types/src/charts/plotBuffers/numericBuffer.d.ts +2 -1
  418. package/types/src/charts/plotPaint.d.ts +233 -0
  419. package/types/src/charts/resolveSpec.d.ts +50 -0
  420. package/types/src/charts/runChartDraw.d.ts +38 -0
  421. package/types/src/charts/runVizPipeline.d.ts +31 -0
  422. package/types/src/charts/shapeEmit.d.ts +61 -0
  423. package/types/src/charts/stages.d.ts +117 -0
  424. package/types/src/charts/viz/Viz.d.ts +111 -0
  425. package/types/src/charts/viz/VizBase.d.ts +160 -0
  426. package/types/src/charts/viz/VizBaseConfig.d.ts +157 -0
  427. package/types/src/charts/viz/interactionOpacity.d.ts +23 -0
  428. package/types/src/charts/viz/ordinalColor.d.ts +14 -0
  429. package/types/src/charts/viz/trailCatchup.d.ts +14 -0
  430. package/types/src/charts/viz/vizDefaults.d.ts +8 -0
  431. package/types/src/charts/viz/vizRender.d.ts +8 -0
  432. package/types/src/charts/viz/vizTypes.d.ts +250 -0
  433. package/types/src/charts/vizContext.d.ts +46 -0
  434. package/types/src/charts/vizDefaults.d.ts +8 -0
  435. package/types/src/charts/vizDraw.d.ts +25 -0
  436. package/types/src/charts/vizDrawPure.d.ts +17 -0
  437. package/types/src/charts/vizPreDraw.d.ts +22 -0
  438. package/types/src/charts/vizPreDrawPure.d.ts +40 -0
  439. package/types/src/charts/vizRender.d.ts +8 -0
  440. package/types/src/charts/vizTypes.d.ts +202 -0
  441. package/types/src/components/Axis/Axis.d.ts +182 -0
  442. package/types/src/components/Axis/AxisBottom.d.ts +11 -0
  443. package/types/src/components/Axis/AxisLeft.d.ts +11 -0
  444. package/types/src/components/Axis/AxisRight.d.ts +11 -0
  445. package/types/src/components/Axis/AxisTop.d.ts +11 -0
  446. package/types/src/components/Axis/axisLayout.d.ts +29 -0
  447. package/types/src/components/Axis/axisLayoutLabels.d.ts +70 -0
  448. package/types/src/components/Axis/axisLayoutScale.d.ts +14 -0
  449. package/types/src/components/Axis/axisRender.d.ts +68 -0
  450. package/types/src/components/Axis.d.ts +68 -194
  451. package/types/src/components/ColorScale/ColorScale.d.ts +100 -0
  452. package/types/src/components/ColorScale/colorScaleRender.d.ts +15 -0
  453. package/types/src/components/ColorScale/colorScaleScale.d.ts +19 -0
  454. package/types/src/components/ColorScale.d.ts +1 -129
  455. package/types/src/components/Legend/Legend.d.ts +95 -0
  456. package/types/src/components/Legend/legendConfig.d.ts +7 -0
  457. package/types/src/components/Legend/legendRender.d.ts +16 -0
  458. package/types/src/components/Legend.d.ts +9 -73
  459. package/types/src/components/TextBox.d.ts +25 -218
  460. package/types/src/components/Timeline/Timeline.d.ts +118 -0
  461. package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
  462. package/types/src/components/Timeline/timelineRender.d.ts +24 -0
  463. package/types/src/components/Timeline.d.ts +7 -81
  464. package/types/src/components/Tooltip.d.ts +20 -200
  465. package/types/src/components/axisLayout.d.ts +27 -0
  466. package/types/src/components/axisLayoutLabels.d.ts +42 -0
  467. package/types/src/components/axisLayoutScale.d.ts +12 -0
  468. package/types/src/components/axisRender.d.ts +65 -0
  469. package/types/src/components/colorScaleRender.d.ts +15 -0
  470. package/types/src/components/colorScaleScale.d.ts +19 -0
  471. package/types/src/components/index.d.ts +8 -8
  472. package/types/src/components/legendConfig.d.ts +7 -0
  473. package/types/src/components/legendRender.d.ts +16 -0
  474. package/types/src/components/timelineConfig.d.ts +6 -0
  475. package/types/src/components/timelineRender.d.ts +14 -0
  476. package/types/src/fluent.d.ts +94 -0
  477. package/types/src/shapes/Area.d.ts +15 -27
  478. package/types/src/shapes/Bar.d.ts +13 -33
  479. package/types/src/shapes/Box.d.ts +17 -56
  480. package/types/src/shapes/Circle.d.ts +11 -17
  481. package/types/src/shapes/Image.d.ts +18 -84
  482. package/types/src/shapes/Line.d.ts +12 -22
  483. package/types/src/shapes/Path.d.ts +12 -19
  484. package/types/src/shapes/Rect.d.ts +11 -27
  485. package/types/src/shapes/Shape.d.ts +46 -257
  486. package/types/src/shapes/Whisker.d.ts +15 -42
  487. package/types/src/shapes/buildLabelData.d.ts +50 -0
  488. package/types/src/shapes/emitLabels.d.ts +16 -0
  489. package/types/src/shapes/hitAreaNode.d.ts +19 -0
  490. package/types/src/shapes/sceneSort.d.ts +20 -0
  491. package/types/src/shapes/shapeConfig.d.ts +226 -0
  492. package/types/src/utils/BaseClass.d.ts +13 -7
  493. package/types/src/utils/D3Scale.d.ts +48 -0
  494. package/types/src/utils/D3plusConfig.d.ts +270 -15
  495. package/types/src/utils/configPrep.d.ts +7 -4
  496. package/types/src/utils/getProp.d.ts +3 -1
  497. package/types/src/utils/index.d.ts +3 -1
  498. package/types/src/utils/paintComponentScene.d.ts +28 -0
  499. package/types/umd-entry.d.ts +15 -0
  500. package/umd/d3plus-core.full.js +30966 -19051
  501. package/umd/d3plus-core.full.js.map +1 -1
  502. package/umd/d3plus-core.full.min.js +5400 -2949
  503. package/umd/d3plus-core.js +17364 -10534
  504. package/umd/d3plus-core.js.map +1 -1
  505. package/umd/d3plus-core.min.js +3494 -1877
  506. package/es/src/charts/AreaPlot.js +0 -85
  507. package/es/src/charts/AreaPlot.js.map +0 -1
  508. package/es/src/charts/BarChart.js +0 -92
  509. package/es/src/charts/BarChart.js.map +0 -1
  510. package/es/src/charts/BoxWhisker.js +0 -92
  511. package/es/src/charts/BoxWhisker.js.map +0 -1
  512. package/es/src/charts/BumpChart.js +0 -147
  513. package/es/src/charts/BumpChart.js.map +0 -1
  514. package/es/src/charts/Donut.js +0 -84
  515. package/es/src/charts/Donut.js.map +0 -1
  516. package/es/src/charts/Geomap.js +0 -766
  517. package/es/src/charts/Geomap.js.map +0 -1
  518. package/es/src/charts/LinePlot.js +0 -83
  519. package/es/src/charts/LinePlot.js.map +0 -1
  520. package/es/src/charts/Matrix.js +0 -341
  521. package/es/src/charts/Matrix.js.map +0 -1
  522. package/es/src/charts/Network.js +0 -796
  523. package/es/src/charts/Network.js.map +0 -1
  524. package/es/src/charts/Pack.js +0 -308
  525. package/es/src/charts/Pack.js.map +0 -1
  526. package/es/src/charts/Pie.js +0 -232
  527. package/es/src/charts/Pie.js.map +0 -1
  528. package/es/src/charts/Plot.js +0 -2114
  529. package/es/src/charts/Plot.js.map +0 -1
  530. package/es/src/charts/Priestley.js +0 -296
  531. package/es/src/charts/Priestley.js.map +0 -1
  532. package/es/src/charts/Radar.js +0 -420
  533. package/es/src/charts/Radar.js.map +0 -1
  534. package/es/src/charts/RadialMatrix.js +0 -383
  535. package/es/src/charts/RadialMatrix.js.map +0 -1
  536. package/es/src/charts/Rings.js +0 -788
  537. package/es/src/charts/Rings.js.map +0 -1
  538. package/es/src/charts/Sankey.js +0 -461
  539. package/es/src/charts/Sankey.js.map +0 -1
  540. package/es/src/charts/StackedArea.js +0 -80
  541. package/es/src/charts/StackedArea.js.map +0 -1
  542. package/es/src/charts/Tree.js +0 -347
  543. package/es/src/charts/Tree.js.map +0 -1
  544. package/es/src/charts/Treemap.js +0 -454
  545. package/es/src/charts/Treemap.js.map +0 -1
  546. package/es/src/charts/Viz.js +0 -1832
  547. package/es/src/charts/Viz.js.map +0 -1
  548. package/es/src/charts/drawSteps/drawAttribution.js +0 -16
  549. package/es/src/charts/drawSteps/drawAttribution.js.map +0 -1
  550. package/es/src/charts/drawSteps/drawBack.js +0 -24
  551. package/es/src/charts/drawSteps/drawBack.js.map +0 -1
  552. package/es/src/charts/drawSteps/drawColorScale.js +0 -75
  553. package/es/src/charts/drawSteps/drawColorScale.js.map +0 -1
  554. package/es/src/charts/drawSteps/drawLegend.js +0 -122
  555. package/es/src/charts/drawSteps/drawLegend.js.map +0 -1
  556. package/es/src/charts/drawSteps/drawSubtitle.js +0 -31
  557. package/es/src/charts/drawSteps/drawSubtitle.js.map +0 -1
  558. package/es/src/charts/drawSteps/drawTimeline.js +0 -85
  559. package/es/src/charts/drawSteps/drawTimeline.js.map +0 -1
  560. package/es/src/charts/drawSteps/drawTitle.js +0 -31
  561. package/es/src/charts/drawSteps/drawTitle.js.map +0 -1
  562. package/es/src/charts/drawSteps/drawTotal.js +0 -32
  563. package/es/src/charts/drawSteps/drawTotal.js.map +0 -1
  564. package/es/src/components/Axis.js +0 -1457
  565. package/es/src/components/Axis.js.map +0 -1
  566. package/es/src/components/AxisBottom.js.map +0 -1
  567. package/es/src/components/AxisLeft.js.map +0 -1
  568. package/es/src/components/AxisRight.js.map +0 -1
  569. package/es/src/components/AxisTop.js.map +0 -1
  570. package/es/src/components/ColorScale.js +0 -843
  571. package/es/src/components/ColorScale.js.map +0 -1
  572. package/es/src/components/Legend.js +0 -622
  573. package/es/src/components/Legend.js.map +0 -1
  574. package/es/src/components/Timeline.js +0 -695
  575. package/es/src/components/Timeline.js.map +0 -1
  576. /package/es/src/components/{AxisBottom.js → Axis/AxisBottom.js} +0 -0
  577. /package/es/src/components/{AxisLeft.js → Axis/AxisLeft.js} +0 -0
  578. /package/es/src/components/{AxisRight.js → Axis/AxisRight.js} +0 -0
  579. /package/es/src/components/{AxisTop.js → Axis/AxisTop.js} +0 -0
@@ -1,2114 +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 _assert_this_initialized(self) {
10
- if (self === void 0) {
11
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12
- }
13
- return self;
14
- }
15
- function _call_super(_this, derived, args) {
16
- derived = _get_prototype_of(derived);
17
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
18
- }
19
- function _class_call_check(instance, Constructor) {
20
- if (!(instance instanceof Constructor)) {
21
- throw new TypeError("Cannot call a class as a function");
22
- }
23
- }
24
- function _defineProperties(target, props) {
25
- for(var i = 0; i < props.length; i++){
26
- var descriptor = props[i];
27
- descriptor.enumerable = descriptor.enumerable || false;
28
- descriptor.configurable = true;
29
- if ("value" in descriptor) descriptor.writable = true;
30
- Object.defineProperty(target, descriptor.key, descriptor);
31
- }
32
- }
33
- function _create_class(Constructor, protoProps, staticProps) {
34
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
35
- if (staticProps) _defineProperties(Constructor, staticProps);
36
- return Constructor;
37
- }
38
- function _define_property(obj, key, value) {
39
- if (key in obj) {
40
- Object.defineProperty(obj, key, {
41
- value: value,
42
- enumerable: true,
43
- configurable: true,
44
- writable: true
45
- });
46
- } else {
47
- obj[key] = value;
48
- }
49
- return obj;
50
- }
51
- function _get(target, property, receiver) {
52
- if (typeof Reflect !== "undefined" && Reflect.get) {
53
- _get = Reflect.get;
54
- } else {
55
- _get = function get(target, property, receiver) {
56
- var base = _super_prop_base(target, property);
57
- if (!base) return;
58
- var desc = Object.getOwnPropertyDescriptor(base, property);
59
- if (desc.get) {
60
- return desc.get.call(receiver || target);
61
- }
62
- return desc.value;
63
- };
64
- }
65
- return _get(target, property, receiver || target);
66
- }
67
- function _get_prototype_of(o) {
68
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
69
- return o.__proto__ || Object.getPrototypeOf(o);
70
- };
71
- return _get_prototype_of(o);
72
- }
73
- function _inherits(subClass, superClass) {
74
- if (typeof superClass !== "function" && superClass !== null) {
75
- throw new TypeError("Super expression must either be null or a function");
76
- }
77
- subClass.prototype = Object.create(superClass && superClass.prototype, {
78
- constructor: {
79
- value: subClass,
80
- writable: true,
81
- configurable: true
82
- }
83
- });
84
- if (superClass) _set_prototype_of(subClass, superClass);
85
- }
86
- function _instanceof(left, right) {
87
- "@swc/helpers - instanceof";
88
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
89
- return !!right[Symbol.hasInstance](left);
90
- } else {
91
- return left instanceof right;
92
- }
93
- }
94
- function _iterable_to_array_limit(arr, i) {
95
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
96
- if (_i == null) return;
97
- var _arr = [];
98
- var _n = true;
99
- var _d = false;
100
- var _s, _e;
101
- try {
102
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
103
- _arr.push(_s.value);
104
- if (i && _arr.length === i) break;
105
- }
106
- } catch (err) {
107
- _d = true;
108
- _e = err;
109
- } finally{
110
- try {
111
- if (!_n && _i["return"] != null) _i["return"]();
112
- } finally{
113
- if (_d) throw _e;
114
- }
115
- }
116
- return _arr;
117
- }
118
- function _non_iterable_rest() {
119
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
120
- }
121
- function _possible_constructor_return(self, call) {
122
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
123
- return call;
124
- }
125
- return _assert_this_initialized(self);
126
- }
127
- function _set_prototype_of(o, p) {
128
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
129
- o.__proto__ = p;
130
- return o;
131
- };
132
- return _set_prototype_of(o, p);
133
- }
134
- function _sliced_to_array(arr, i) {
135
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
136
- }
137
- function _super_prop_base(object, property) {
138
- while(!Object.prototype.hasOwnProperty.call(object, property)){
139
- object = _get_prototype_of(object);
140
- if (object === null) break;
141
- }
142
- return object;
143
- }
144
- function _type_of(obj) {
145
- "@swc/helpers - typeof";
146
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
147
- }
148
- function _unsupported_iterable_to_array(o, minLen) {
149
- if (!o) return;
150
- if (typeof o === "string") return _array_like_to_array(o, minLen);
151
- var n = Object.prototype.toString.call(o).slice(8, -1);
152
- if (n === "Object" && o.constructor) n = o.constructor.name;
153
- if (n === "Map" || n === "Set") return Array.from(n);
154
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
155
- }
156
- function _is_native_reflect_construct() {
157
- try {
158
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
159
- } catch (_) {}
160
- return (_is_native_reflect_construct = function() {
161
- return !!result;
162
- })();
163
- }
164
- /* eslint no-cond-assign: 0*/ import { deviation, extent, groups, max, mean, merge, min, range, rollups, sum } from "d3-array";
165
- import * as scales from "d3-scale";
166
- import * as d3Shape from "d3-shape";
167
- // @ts-ignore
168
- import pkg from "open-color/open-color.js";
169
- var openColor = pkg.theme;
170
- import { colorAssign, colorContrast, colorDefaults, colorLegible } from "@d3plus/color";
171
- import { merge as d3plusMerge, unique } from "@d3plus/data";
172
- import { assign, backgroundColor, date, elem, rtl, textWidth } from "@d3plus/dom";
173
- import { largestRect } from "@d3plus/math";
174
- import { formatAbbreviate } from "@d3plus/format";
175
- import { AxisBottom, AxisLeft, AxisRight, AxisTop, TextBox } from "../components/index.js";
176
- import * as shapes from "../shapes/index.js";
177
- import { accessor, configPrep, constant } from "../utils/index.js";
178
- var testLineShape = new shapes.Line();
179
- var testTextBox = new TextBox();
180
- import Viz from "./Viz.js";
181
- import { default as discreteBuffer } from "./plotBuffers/discreteBuffer.js";
182
- import { default as BarBuffer } from "./plotBuffers/Bar.js";
183
- import { default as BoxBuffer } from "./plotBuffers/Box.js";
184
- import { default as CircleBuffer } from "./plotBuffers/Circle.js";
185
- import { default as LineBuffer } from "./plotBuffers/Line.js";
186
- import { default as RectBuffer } from "./plotBuffers/Rect.js";
187
- var defaultBuffers = {
188
- Bar: BarBuffer,
189
- Box: BoxBuffer,
190
- Circle: CircleBuffer,
191
- Line: LineBuffer,
192
- Rect: RectBuffer
193
- };
194
- /**
195
- Logic for determining default sizes of shapes using the sizeScaleD3 internal function.
196
- @private
197
- */ function defaultSize(d) {
198
- return this._sizeScaleD3(this._size ? this._size(d) : null);
199
- }
200
- /**
201
- Logic for determining stackOrder ascending using groups.
202
- @private
203
- */ function stackOrderAscending(series) {
204
- var sums = series.map(stackSum);
205
- var keys = series.map(function(d) {
206
- return d.key.split("_")[0];
207
- });
208
- return d3Shape.stackOrderNone(series).sort(function(a, b) {
209
- return keys[b].localeCompare(keys[a]) || sums[a] - sums[b];
210
- });
211
- }
212
- /**
213
- Logic for determining stackOrder descending using groups.
214
- @private
215
- */ function stackOrderDescending(series) {
216
- return stackOrderAscending(series).reverse();
217
- }
218
- /**
219
- Logic for determining default sum of shapes using the stackSum function used in d3Shape.
220
- @private
221
- */ function stackSum(series) {
222
- var i = -1, s = 0, v;
223
- var n = series.length;
224
- while(++i < n)if (v = +series[i][1]) s += v;
225
- return s;
226
- }
227
- /**
228
- Logic for determining default sum of shapes using the stackSum function used in d3Shape.
229
- @private
230
- */ function stackOffsetDiverging(series, order) {
231
- var n;
232
- if (!((n = series.length) > 0)) return;
233
- var d, dy, i, yn, yp;
234
- var m = series[order[0]].length;
235
- for(var j = 0; j < m; ++j){
236
- for(yp = yn = 0, i = 0; i < n; ++i){
237
- if ((dy = (d = series[order[i]][j])[1] - d[0]) >= 0) {
238
- d[0] = yp, d[1] = yp += dy;
239
- } else if (dy < 0) {
240
- d[1] = yn, d[0] = yn += dy;
241
- } else {
242
- d[0] = yp;
243
- }
244
- }
245
- }
246
- }
247
- /**
248
- * Determines if a Bar label should be placed outside of the Bar.
249
- * @param {@} d
250
- * @param {*} i
251
- * @private
252
- */ function outside(d, i) {
253
- // Force all Stacked Bars to use "inside" labels.
254
- if (this._stacked) return false;
255
- // Detect user "outside" or "inside" override.
256
- var labelPosition = this._labelPosition(d, i);
257
- if (labelPosition === "outside") return true;
258
- else if (labelPosition === "inside") return false;
259
- // Run "auto" logic based on available space.
260
- var other = this._discrete.charAt(0) === "x" ? "y" : "x";
261
- var nonDiscrete = this._discrete.replace(this._discrete.charAt(0), other);
262
- var range = this["_".concat(nonDiscrete, "Axis")]._d3Scale.range();
263
- var value = this["_".concat(nonDiscrete)](d, i);
264
- var negative = value < 0;
265
- var zero = this["_".concat(nonDiscrete, "Axis")]._getPosition(0);
266
- var space = nonDiscrete === "y" ? negative ? range[1] - zero : zero - range[0] : negative ? zero - range[0] : range[1] - zero;
267
- var pos = this["_".concat(nonDiscrete, "Axis")]._getPosition(value);
268
- var size = Math.abs(negative ? zero - pos : pos - zero);
269
- return size < space / 2;
270
- }
271
- var Plot = /*#__PURE__*/ function(Viz) {
272
- "use strict";
273
- _inherits(Plot, Viz);
274
- function Plot() {
275
- _class_call_check(this, Plot);
276
- var _this;
277
- _this = _call_super(this, Plot);
278
- _this._axisPersist = false;
279
- _this._annotations = [];
280
- _this._backgroundConfig = {
281
- duration: 0,
282
- fill: "transparent"
283
- };
284
- _this._barPadding = 0;
285
- _this._buffer = assign({}, defaultBuffers, {
286
- Bar: false,
287
- Line: false
288
- });
289
- _this._confidenceConfig = {
290
- fill: function fill(d, i) {
291
- var c = typeof _this._shapeConfig.Line.stroke === "function" ? _this._shapeConfig.Line.stroke(d, i) : _this._shapeConfig.Line.stroke;
292
- return c;
293
- },
294
- fillOpacity: constant(0.5)
295
- };
296
- _this._discreteCutoff = 100;
297
- _this._groupPadding = 5;
298
- _this._labelConnectorConfig = {
299
- strokeDasharray: "1 1"
300
- };
301
- _this._labelPosition = constant("auto");
302
- _this._lineMarkerConfig = {
303
- fill: function fill(d, i) {
304
- return colorAssign(_this._id(d, i));
305
- },
306
- r: constant(3)
307
- };
308
- _this._lineMarkers = false;
309
- _this._previousAnnotations = {
310
- back: [],
311
- front: []
312
- };
313
- _this._previousShapes = [];
314
- _this._shape = constant("Circle");
315
- _this._shapeConfig = assign(_this._shapeConfig, {
316
- Area: {
317
- label: function label(d, i) {
318
- return _this._stacked ? _this._drawLabel(d, i) : false;
319
- },
320
- labelBounds: function labelBounds(d, i, aes) {
321
- var r = largestRect(aes.points, {
322
- angle: range(-20, 20, 5)
323
- });
324
- if (!r || r.height < 20 || r.width < 50) r = largestRect(aes.points, {
325
- angle: range(-80, 80, 5)
326
- });
327
- if (!r) return null;
328
- var x = min(aes.points, function(d) {
329
- return d[0];
330
- });
331
- var y = max(aes.points.filter(function(d) {
332
- return d[0] === x;
333
- }), function(d) {
334
- return d[1];
335
- });
336
- return {
337
- angle: r.angle,
338
- width: r.width,
339
- height: r.height,
340
- x: r.cx - r.width / 2 - x,
341
- y: r.cy - r.height / 2 - y
342
- };
343
- },
344
- labelConfig: {
345
- fontMin: 6,
346
- fontResize: true,
347
- padding: 10
348
- }
349
- },
350
- ariaLabel: function ariaLabel(d, i) {
351
- var ariaLabelStr = "";
352
- if (d.nested) ariaLabelStr = "".concat(_this._drawLabel(d.data, d.i));
353
- else {
354
- ariaLabelStr = "".concat(_this._drawLabel(d, i));
355
- if (_this._x(d, i) !== undefined) ariaLabelStr += ", x: ".concat(_this._x(d, i));
356
- if (_this._y(d, i) !== undefined) ariaLabelStr += ", y: ".concat(_this._y(d, i));
357
- if (_this._x2(d, i) !== undefined) ariaLabelStr += ", x2: ".concat(_this._x2(d, i));
358
- if (_this._y2(d, i) !== undefined) ariaLabelStr += ", y2: ".concat(_this._y2(d, i));
359
- }
360
- return "".concat(ariaLabelStr, ".");
361
- },
362
- Bar: {
363
- labelBounds: function labelBounds(d, i, s) {
364
- var padding = 1;
365
- var width = this._discrete === "y" ? "width" : "height";
366
- var height = this._discrete === "y" ? "height" : "width";
367
- var other = this._discrete.charAt(0) === "x" ? "y" : "x";
368
- var invert = other === "y";
369
- var nonDiscrete = this._discrete.replace(this._discrete.charAt(0), other);
370
- var range = this["_".concat(nonDiscrete, "Axis")]._d3Scale.range();
371
- var space = Math.abs(range[1] - range[0]);
372
- var negative = this["_".concat(nonDiscrete)](d, i) < 0;
373
- if (outside.bind(this)(d, i)) {
374
- var _obj;
375
- return _obj = {}, _define_property(_obj, width, space - s[width]), _define_property(_obj, height, s[height]), _define_property(_obj, "x", invert ? -s.width / 2 : negative ? -space : s.width + padding), _define_property(_obj, "y", invert ? negative ? s.height + padding : -space : -s.height / 2 + 1), _obj;
376
- }
377
- var _obj1;
378
- return _obj1 = {}, _define_property(_obj1, width, s[width]), _define_property(_obj1, height, s[height]), _define_property(_obj1, "x", invert ? -s.width / 2 : negative ? this._stacked ? padding - s.width : padding - s.width : -padding), _define_property(_obj1, "y", invert ? negative ? this._stacked ? padding : padding : -s.height + padding : -s.height / 2 + padding), _obj1;
379
- },
380
- labelConfig: {
381
- fontMax: 16,
382
- fontMin: 6,
383
- fontResize: true,
384
- fontColor: function fontColor(d, i) {
385
- if (outside.bind(this)(d, i)) {
386
- var bg = this._backgroundConfig.fill === "transparent" ? backgroundColor(this._select.node()) : this._backgroundConfig.fill;
387
- return colorContrast(bg);
388
- }
389
- return colorContrast(typeof this._shapeConfig.fill === "function" ? this._shapeConfig.fill(d, i) : this._shapeConfig.fill);
390
- },
391
- fontStroke: function fontStroke(d, i) {
392
- if (outside.bind(this)(d, i)) {
393
- var bg = this._backgroundConfig.fill === "transparent" ? backgroundColor(this._select.node()) : this._backgroundConfig.fill;
394
- return colorContrast(bg);
395
- }
396
- return "transparent";
397
- },
398
- fontStrokeWidth: function fontStrokeWidth(d, i) {
399
- return outside.bind(this)(d, i) ? 0.1 : 0;
400
- },
401
- padding: 3,
402
- textAnchor: function textAnchor(d, i) {
403
- var other = this._discrete.charAt(0) === "x" ? "y" : "x";
404
- var invert = other === "y";
405
- var nonDiscrete = this._discrete.replace(this._discrete.charAt(0), other);
406
- var negative = this["_".concat(nonDiscrete)](d, i) < 0;
407
- var anchor = invert ? "middle" : outside.bind(this)(d, i) ? negative ? "end" : "start" : negative ? "start" : "end";
408
- return rtl() ? anchor === "start" ? "end" : anchor === "end" ? "start" : anchor : anchor;
409
- },
410
- verticalAlign: function verticalAlign(d, i) {
411
- var other = this._discrete.charAt(0) === "x" ? "y" : "x";
412
- var invert = other === "y";
413
- var nonDiscrete = this._discrete.replace(this._discrete.charAt(0), other);
414
- var negative = this["_".concat(nonDiscrete)](d, i) < 0;
415
- return invert ? outside.bind(this)(d, i) ? negative ? "top" : "bottom" : negative ? "bottom" : "top" : "middle";
416
- }
417
- }
418
- },
419
- Circle: {
420
- r: defaultSize.bind(_this)
421
- },
422
- Line: {
423
- curve: function curve() {
424
- return _this._discrete ? "monotone".concat(_this._discrete.charAt(0).toUpperCase()) : "linear";
425
- },
426
- fill: constant("none"),
427
- labelConfig: {
428
- fontColor: function fontColor(d, i) {
429
- var c = typeof _this._shapeConfig.Line.stroke === "function" ? _this._shapeConfig.Line.stroke(d, i) : _this._shapeConfig.Line.stroke;
430
- return colorLegible(c);
431
- },
432
- fontResize: false,
433
- padding: 5,
434
- textAnchor: "start",
435
- verticalAlign: "middle"
436
- },
437
- strokeWidth: constant(2)
438
- },
439
- Rect: {
440
- height: function height(d) {
441
- return defaultSize.bind(_this)(d) * 2;
442
- },
443
- width: function width(d) {
444
- return defaultSize.bind(_this)(d) * 2;
445
- }
446
- }
447
- });
448
- _this._shapeOrder = [
449
- "Area",
450
- "Path",
451
- "Bar",
452
- "Box",
453
- "Line",
454
- "Rect",
455
- "Circle"
456
- ];
457
- _this._shapeSort = function(a, b) {
458
- return _this._shapeOrder.indexOf(a) - _this._shapeOrder.indexOf(b);
459
- };
460
- _this._sizeMax = 20;
461
- _this._sizeMin = 5;
462
- _this._sizeScale = "sqrt";
463
- _this._stackOffset = stackOffsetDiverging;
464
- _this._stackOrder = stackOrderDescending;
465
- _this._timelineConfig = assign(_this._timelineConfig, {
466
- brushMin: function brushMin() {
467
- return _this._xTime || _this._yTime || _this._x2Time || _this._y2Time ? 2 : 1;
468
- }
469
- });
470
- _this._x = accessor("x");
471
- _this._xKey = "x";
472
- _this._xAxis = new AxisBottom().align("end");
473
- _this._xTest = new AxisBottom().align("end").gridSize(0);
474
- _this._xConfig = {
475
- gridConfig: {
476
- stroke: function stroke(d) {
477
- if (_this._discrete && _this._discrete.charAt(0) === "x") return "transparent";
478
- var range = _this._xAxis.range();
479
- var position = _this._xAxis._getPosition.bind(_this._xAxis)(d.id);
480
- if (range[0] === position) return "transparent";
481
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
482
- var contrast = colorContrast(bg);
483
- return contrast === colorDefaults.dark ? openColor.colors.gray[200] : openColor.colors.gray[600];
484
- }
485
- }
486
- };
487
- _this._xCutoff = 150;
488
- _this._x2 = accessor("x2");
489
- _this._x2Key = "x2";
490
- _this._x2Axis = new AxisTop().align("start");
491
- _this._x2Test = new AxisTop().align("start").gridSize(0);
492
- _this._x2Config = {};
493
- _this._y = accessor("y");
494
- _this._yKey = "y";
495
- _this._yAxis = new AxisLeft().align("start");
496
- _this._yKey = "y";
497
- _this._yTest = new AxisLeft().align("start").gridSize(0);
498
- _this._yConfig = {
499
- gridConfig: {
500
- stroke: function stroke(d) {
501
- if (_this._discrete && _this._discrete.charAt(0) === "y") return "transparent";
502
- var range = _this._yAxis.range();
503
- var position = _this._yAxis._getPosition.bind(_this._yAxis)(d.id);
504
- if (range[range.length - 1] === position) return "transparent";
505
- var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
506
- var contrast = colorContrast(bg);
507
- return contrast === colorDefaults.dark ? openColor.colors.gray[200] : openColor.colors.gray[600];
508
- }
509
- }
510
- };
511
- _this._yCutoff = 150;
512
- _this._y2 = accessor("y2");
513
- _this._y2Key = "y2";
514
- _this._y2Axis = new AxisRight().align("end");
515
- _this._y2Test = new AxisLeft().align("end").gridSize(0);
516
- _this._y2Config = {};
517
- return _this;
518
- }
519
- _create_class(Plot, [
520
- {
521
- /**
522
- Extends the preDraw behavior of the abstract Viz class.
523
- @private
524
- */ key: "_preDraw",
525
- value: function _preDraw() {
526
- var _this = this;
527
- // logic repeated for each axis
528
- [
529
- "x",
530
- "y",
531
- "x2",
532
- "y2"
533
- ].forEach(function(k) {
534
- // if user has supplied a String key as the main method value
535
- if (_this["_".concat(k, "Key")]) {
536
- var str = _this["_".concat(k, "Key")];
537
- // if axis is discrete and numerical, do not sum values
538
- if (!_this._aggs[str] && _this._discrete === k) {
539
- _this._aggs[str] = function(a, c) {
540
- var v = Array.from(new Set(a.map(c)));
541
- return v.length === 1 ? v[0] : v;
542
- };
543
- }
544
- // set axis title if not discrete
545
- if (str !== k && _this["_".concat(k, "Title")] === _this["_".concat(k, "Config")].title && _this._discrete !== k) {
546
- _this["_".concat(k, "Title")] = str;
547
- _this["_".concat(k, "Config")].title = str;
548
- }
549
- }
550
- });
551
- _get(_get_prototype_of(Plot.prototype), "_preDraw", this).call(this);
552
- }
553
- },
554
- {
555
- /**
556
- Extends the draw behavior of the abstract Viz class.
557
- @private
558
- */ key: "_draw",
559
- value: function _draw(callback) {
560
- var _this = this;
561
- if (!this._filteredData.length && !this._annotations.length) return this;
562
- /* Determines whether or not any of the x or y axes are a "time" axis.*/ var firstElemTime = this._time ? this._time(this._filteredData[0], 0) : false;
563
- var x2Time = this._x2Time = firstElemTime && this._x2(this._filteredData[0], 0) === firstElemTime, xTime = this._xTime = firstElemTime && this._x(this._filteredData[0], 0) === firstElemTime, y2Time = this._y2Time = firstElemTime && this._y2(this._filteredData[0], 0) === firstElemTime, yTime = this._yTime = firstElemTime && this._y(this._filteredData[0], 0) === firstElemTime;
564
- var timeAxis = xTime || x2Time || yTime || y2Time;
565
- var stackGroup = function stackGroup(d, i) {
566
- return "".concat(!timeAxis && _this._time ? _this._time(d, i) : "time", "_").concat(_this._stacked ? "".concat(_this._groupBy.length > 1 ? _this._ids(d, i).slice(0, -1).join("_") : "group") : "".concat(_this._ids(d, i).join("_")));
567
- };
568
- var prepData = function prepData(d, i) {
569
- var newD = {
570
- __d3plus__: true,
571
- data: d,
572
- group: stackGroup(d, i),
573
- i: i,
574
- hci: _this._confidence && _this._confidence[1] && _this._confidence[1](d, i),
575
- id: _this._ids(d, i).slice(0, _this._drawDepth + 1).join("_"),
576
- lci: _this._confidence && _this._confidence[0] && _this._confidence[0](d, i),
577
- shape: _this._shape(d, i),
578
- x: xTime ? date(_this._x(d, i)) : _this._x(d, i),
579
- x2: x2Time ? date(_this._x2(d, i)) : _this._x2(d, i),
580
- y: yTime ? date(_this._y(d, i)) : _this._y(d, i),
581
- y2: y2Time ? date(_this._y2(d, i)) : _this._y2(d, i)
582
- };
583
- newD.discrete = newD.shape === "Bar" ? "".concat(newD[_this._discrete], "_").concat(newD.group) : "".concat(newD[_this._discrete]);
584
- newD.id = newD.shape === "Bar" ? "".concat(newD.id, "_").concat(newD[_this._discrete]) : newD.id;
585
- return newD;
586
- };
587
- var data = this._formattedData = this._filteredData.map(prepData);
588
- var axisData = this._axisPersist ? this._data.map(prepData) : data;
589
- if (this._size) {
590
- var rExtent = extent(axisData, function(d) {
591
- return _this._size(d.data);
592
- });
593
- this._sizeScaleD3 = scales["scale".concat(this._sizeScale.charAt(0).toUpperCase()).concat(this._sizeScale.slice(1))]().domain(rExtent).range([
594
- rExtent[0] === rExtent[1] ? this._sizeMax : min([
595
- this._sizeMax / 2,
596
- this._sizeMin
597
- ]),
598
- this._sizeMax
599
- ]);
600
- } else {
601
- this._sizeScaleD3 = function() {
602
- return _this._sizeMin;
603
- };
604
- }
605
- var x2Exists = axisData.some(function(d) {
606
- return d.x2 !== undefined;
607
- }), y2Exists = axisData.some(function(d) {
608
- return d.y2 !== undefined;
609
- });
610
- var height = this._height - this._margin.top - this._margin.bottom, opp = this._discrete ? this._discrete === "x" ? "y" : "x" : undefined, opp2 = this._discrete ? this._discrete === "x" ? "y2" : "x2" : undefined, opps = [
611
- opp,
612
- opp2
613
- ].filter(function(d) {
614
- return d;
615
- }), parent = this._select, transition = this._transition, width = this._width - this._margin.left - this._margin.right;
616
- /**
617
- Returns all unique values for a given axis.
618
- @param axis Which axis to return values for, "x" or "y".
619
- @private
620
- */ function getAxisValues(axis) {
621
- var _this = this;
622
- var timeData = this["_".concat(axis, "Time")];
623
- var localData = timeData ? data : axisData;
624
- var filteredData = localData.filter(function(d) {
625
- return ![
626
- NaN,
627
- undefined,
628
- false
629
- ].includes(d[axis]);
630
- });
631
- if (!filteredData.length) return [];
632
- var numericValue = typeof filteredData[0][axis] === "number";
633
- var myData = this._discrete === axis ? rollups(filteredData, function(leaves) {
634
- return leaves.length === 1 ? leaves[0].data : d3plusMerge(leaves.map(function(d) {
635
- return d.data;
636
- }), _this._aggs);
637
- }, function(d) {
638
- return d[axis];
639
- }).sort(function(a, b) {
640
- if (_this["_".concat(axis, "Sort")]) return _this["_".concat(axis, "Sort")](a[1], b[1]);
641
- var aKey = timeData || numericValue ? parseFloat(a[0]) : a[0];
642
- var bKey = timeData || numericValue ? parseFloat(b[0]) : b[0];
643
- return aKey - bKey;
644
- }).map(function(param) {
645
- var _param = _sliced_to_array(param, 1), key = _param[0];
646
- return timeData ? date(key) : numericValue ? parseFloat(key) : key;
647
- }) : unique(filteredData.sort(function(a, b) {
648
- return _this["_".concat(axis, "Sort")] ? _this["_".concat(axis, "Sort")](a.data, b.data) : a[axis] - b[axis];
649
- }).map(function(d) {
650
- return d[axis];
651
- }), function(d) {
652
- return "".concat(d);
653
- });
654
- if (this._discrete !== axis.charAt(0) && this._confidence) {
655
- if (this._confidence[0]) myData = myData.concat(localData.map(function(d) {
656
- return d.lci;
657
- }));
658
- if (this._confidence[1]) myData = myData.concat(localData.map(function(d) {
659
- return d.hci;
660
- }));
661
- }
662
- return myData;
663
- }
664
- var xData = getAxisValues.bind(this)("x");
665
- var x2Data = getAxisValues.bind(this)("x2");
666
- var yData = getAxisValues.bind(this)("y");
667
- var y2Data = getAxisValues.bind(this)("y2");
668
- var discreteKeys, domains, stackData, stackKeys;
669
- if (this._stacked) {
670
- var stackedData = axisData.filter(function(d) {
671
- return [
672
- "Area",
673
- "Bar"
674
- ].includes(d.shape);
675
- });
676
- var groupValues = groups(stackedData, function(d) {
677
- return d.group;
678
- }).reduce(function(obj, param) {
679
- var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
680
- if (!obj[key]) obj[key] = 0;
681
- obj[key] += sum(values, function(dd) {
682
- return dd[opp];
683
- });
684
- return obj;
685
- }, {});
686
- axisData.sort(function(a, b) {
687
- if (_this["_".concat(_this._discrete, "Sort")]) return _this["_".concat(_this._discrete, "Sort")](a.data, b.data);
688
- var a1 = a[_this._discrete], b1 = b[_this._discrete];
689
- if (a1 - b1 !== 0) return a1 - b1;
690
- if (a.group !== b.group) return groupValues[b.group] - groupValues[a.group];
691
- return b[opp] - a[opp];
692
- });
693
- discreteKeys = Array.from(new Set(axisData.map(function(d) {
694
- return d.discrete;
695
- })));
696
- stackKeys = Array.from(new Set(axisData.map(function(d) {
697
- return d.id;
698
- })));
699
- stackData = groups(axisData, function(d) {
700
- return d.discrete;
701
- }).map(function(param) {
702
- var _param = _sliced_to_array(param, 2), values = _param[1];
703
- return values;
704
- });
705
- stackData.forEach(function(g) {
706
- var ids = Array.from(new Set(g.map(function(d) {
707
- return d.id;
708
- })));
709
- if (ids.length < stackKeys.length) {
710
- stackKeys.forEach(function(k) {
711
- if (!ids.includes(k)) {
712
- var d = axisData.filter(function(d) {
713
- return d.id === k;
714
- })[0];
715
- if (d.shape === "Area") {
716
- var group = stackGroup(d.data, d.i);
717
- var _obj;
718
- var fillerPoint = (_obj = {
719
- __d3plus__: true,
720
- data: d.data,
721
- discrete: d.shape === "Bar" ? "".concat(g[0][_this._discrete], "_").concat(group) : "".concat(g[0][_this._discrete]),
722
- group: group,
723
- id: d.id,
724
- ids: k,
725
- shape: d.shape
726
- }, _define_property(_obj, _this._discrete, g[0][_this._discrete]), _define_property(_obj, opp, 0), _obj);
727
- data.push(fillerPoint);
728
- }
729
- }
730
- });
731
- }
732
- });
733
- if (this["_".concat(this._discrete, "Sort")]) {
734
- data.sort(function(a, b) {
735
- return _this["_".concat(_this._discrete, "Sort")](a.data, b.data);
736
- });
737
- } else {
738
- data.sort(function(a, b) {
739
- return a[_this._discrete] - b[_this._discrete];
740
- });
741
- }
742
- var order = this._stackOrder;
743
- if (_instanceof(order, Array)) stackKeys.sort(function(a, b) {
744
- return order.indexOf(a) - order.indexOf(b);
745
- });
746
- else if (order === d3Shape.stackOrderNone) stackKeys.sort(function(a, b) {
747
- return a.localeCompare(b);
748
- });
749
- stackData = d3Shape.stack().keys(stackKeys).offset(this._stackOffset).order(_instanceof(order, Array) ? d3Shape.stackOrderNone : order).value(function(group, key) {
750
- var d = group.filter(function(g) {
751
- return g.id === key;
752
- });
753
- return d.length ? d[0][opp] : 0;
754
- })(stackData);
755
- var discreteData = this._discrete === "x" ? xData : yData;
756
- var _obj;
757
- domains = (_obj = {}, _define_property(_obj, this._discrete, this["_".concat(this._discrete, "Time")] ? extent(discreteData) : discreteData), _define_property(_obj, opp, [
758
- min(stackData.map(function(g) {
759
- return min(g.map(function(p) {
760
- return p[0];
761
- }));
762
- })),
763
- max(stackData.map(function(g) {
764
- return max(g.map(function(p) {
765
- return p[1];
766
- }));
767
- }))
768
- ]), _obj);
769
- } else {
770
- var discrete = this._discrete || "x";
771
- if (this["_".concat(this._discrete, "Sort")]) {
772
- axisData.sort(function(a, b) {
773
- return _this["_".concat(_this._discrete, "Sort")](a.data, b.data);
774
- });
775
- } else {
776
- axisData.sort(function(a, b) {
777
- return a[discrete] - b[discrete];
778
- });
779
- }
780
- domains = {
781
- x: !xTime && this._discrete === "x" || this._xSort ? xData : extent(xData),
782
- x2: !x2Time && this._discrete === "x" || this._x2Sort ? x2Data : extent(x2Data),
783
- y: !yTime && this._discrete === "y" || this._ySort ? yData : extent(yData),
784
- y2: !y2Time && this._discrete === "y" || this._y2Sort ? y2Data : extent(y2Data)
785
- };
786
- }
787
- /**
788
- * Determins default scale type and domain for a given axis.
789
- * @param {String} axis
790
- * @private
791
- */ function domainScaleSetup(axis) {
792
- var scale = this["_".concat(axis, "Time")] ? "Time" : this._discrete === axis || this["_".concat(axis, "Sort")] ? "Point" : "Linear";
793
- var domain = this["_".concat(axis, "Domain")] ? this["_".concat(axis, "Domain")].slice() : domains[axis], domain2 = this["_".concat(axis, "2Domain")] ? this["_".concat(axis, "2Domain")].slice() : domains["".concat(axis, "2")];
794
- if (scale !== "Point") {
795
- if (domain && domain[0] === void 0) domain[0] = domains[axis][0];
796
- if (domain && domain[1] === void 0) domain[1] = domains[axis][1];
797
- if (domain2 && domain2[0] === void 0) domain2[0] = domains["".concat(axis, "2")][0];
798
- if (domain2 && domain2[1] === void 0) domain2[1] = domains["".concat(axis, "2")][1];
799
- }
800
- return [
801
- domain,
802
- scale,
803
- domain2,
804
- scale
805
- ];
806
- }
807
- var _domainScaleSetup_bind = _sliced_to_array(domainScaleSetup.bind(this)("x"), 4), xAutoDomain = _domainScaleSetup_bind[0], xScale = _domainScaleSetup_bind[1], x2AutoDomain = _domainScaleSetup_bind[2], x2Scale = _domainScaleSetup_bind[3];
808
- var _domainScaleSetup_bind1 = _sliced_to_array(domainScaleSetup.bind(this)("y"), 4), yAutoDomain = _domainScaleSetup_bind1[0], yScale = _domainScaleSetup_bind1[1], y2AutoDomain = _domainScaleSetup_bind1[2], y2Scale = _domainScaleSetup_bind1[3];
809
- var autoScale = function autoScale(axis, fallback) {
810
- var userScale = _this["_".concat(axis, "Config")].scale;
811
- if (userScale === "auto") {
812
- if (_this._discrete === axis) return fallback;
813
- var values = axisData.map(function(d) {
814
- return d[axis];
815
- });
816
- return deviation(values) / mean(values) > 3 ? "log" : "linear";
817
- }
818
- return userScale || fallback;
819
- };
820
- var yConfigScale = this._yConfigScale = autoScale("y", yScale).toLowerCase();
821
- var y2ConfigScale = this._y2ConfigScale = autoScale("y2", y2Scale).toLowerCase();
822
- var xConfigScale = this._xConfigScale = autoScale("x", xScale).toLowerCase();
823
- var x2ConfigScale = this._x2ConfigScale = autoScale("x2", x2Scale).toLowerCase();
824
- domains = {
825
- x: xAutoDomain,
826
- x2: x2AutoDomain || xAutoDomain,
827
- y: yAutoDomain,
828
- y2: y2AutoDomain || yAutoDomain
829
- };
830
- Object.keys(domains).forEach(function(axis) {
831
- if (_this["_".concat(axis, "ConfigScale")] === "log" && domains[axis].includes(0)) {
832
- if (min(domains[axis]) < 0) domains[axis][1] = max(data.map(function(d) {
833
- return d[axis];
834
- }).filter(function(d) {
835
- return ![
836
- NaN,
837
- undefined,
838
- false
839
- ].includes(d);
840
- }));
841
- else domains[axis][0] = min(axisData.map(function(d) {
842
- return d[axis];
843
- }).filter(function(d) {
844
- return ![
845
- NaN,
846
- undefined,
847
- false
848
- ].includes(d);
849
- }));
850
- }
851
- });
852
- opps.forEach(function(opp) {
853
- if (_this["_".concat(opp, "Config")].domain) {
854
- var d = _this["_".concat(opp, "Config")].domain;
855
- if (_this._discrete === "x") d.reverse();
856
- domains[opp] = d;
857
- } else if (opp && _this._baseline !== void 0) {
858
- var b = _this._baseline;
859
- if (domains[opp] && domains[opp][0] > b) domains[opp][0] = b;
860
- else if (domains[opp] && domains[opp][1] < b) domains[opp][1] = b;
861
- }
862
- });
863
- var x = scales["scale".concat(xScale)]().domain(domains.x).range(range(0, width + 1, width / (domains.x.length - 1))), x2 = scales["scale".concat(x2Scale)]().domain(domains.x2).range(range(0, width + 1, width / (domains.x2.length - 1))), y = scales["scale".concat(yScale)]().domain(domains.y.reverse()).range(range(0, height + 1, height / (domains.y.length - 1))), y2 = scales["scale".concat(y2Scale)]().domain(domains.y2.reverse()).range(range(0, height + 1, height / (domains.y2.length - 1)));
864
- var shapeData = groups(data, function(d) {
865
- return d.shape;
866
- }).sort(function(param, param1) {
867
- var _param = _sliced_to_array(param, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
868
- return _this._shapeSort(a, b);
869
- });
870
- var oppScale = this._discrete === "x" ? yScale : xScale;
871
- if (oppScale !== "Point") {
872
- var allShapeData = groups(axisData, function(d) {
873
- return d.shape;
874
- });
875
- allShapeData.forEach(function(param) {
876
- var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
877
- if ([
878
- "Bar",
879
- "Box"
880
- ].includes(key)) {
881
- discreteBuffer(_this._discrete === "x" ? x : y, data, _this._discrete);
882
- }
883
- if (_this._buffer[key]) {
884
- var res = _this._buffer[key].bind(_this)({
885
- data: values,
886
- x: x,
887
- y: y,
888
- yScale: yConfigScale,
889
- xScale: xConfigScale,
890
- config: _this._shapeConfig[key]
891
- });
892
- x = res[0];
893
- y = res[1];
894
- var res2 = _this._buffer[key].bind(_this)({
895
- data: values,
896
- x: x2,
897
- y: y2,
898
- yScale: y2ConfigScale,
899
- xScale: x2ConfigScale,
900
- x2: true,
901
- y2: true,
902
- config: _this._shapeConfig[key]
903
- });
904
- x2 = res2[0];
905
- y2 = res2[1];
906
- }
907
- });
908
- }
909
- var xDomain = x.domain();
910
- var x2Domain = x2.domain();
911
- var yDomain = y.domain();
912
- var y2Domain = y2.domain();
913
- var defaultConfig = {
914
- barConfig: {
915
- "stroke-width": 0
916
- },
917
- gridSize: 0,
918
- labels: [],
919
- title: false,
920
- tickSize: 0
921
- };
922
- var defaultX2Config = x2Exists ? {
923
- data: x2Data
924
- } : defaultConfig;
925
- var defaultY2Config = y2Exists ? {
926
- data: y2Data
927
- } : defaultConfig;
928
- var showX = this._discrete === "x" ? this._width > this._discreteCutoff && this._width > this._xCutoff : this._width > this._xCutoff;
929
- var showY = this._discrete === "y" ? this._height > this._discreteCutoff && this._height > this._yCutoff : this._height > this._yCutoff;
930
- var yC = {
931
- data: yData,
932
- locale: this._locale,
933
- rounding: this._yDomain ? "none" : "outside",
934
- scalePadding: y.padding ? y.padding() : 0
935
- };
936
- if (!showX && showY) {
937
- yC.barConfig = {
938
- stroke: "transparent"
939
- };
940
- yC.tickSize = 0;
941
- yC.shapeConfig = {
942
- labelBounds: function labelBounds(d, i) {
943
- var _d_labelBounds = d.labelBounds, width = _d_labelBounds.width, y = _d_labelBounds.y;
944
- var height = _this._height / 2;
945
- var x = i ? -height : 0;
946
- return {
947
- x: x,
948
- y: y,
949
- width: width,
950
- height: height
951
- };
952
- },
953
- labelConfig: {
954
- padding: 0,
955
- rotate: 0
956
- },
957
- labelRotation: false
958
- };
959
- }
960
- var testGroup = elem("g.d3plus-plot-test", {
961
- enter: {
962
- opacity: 0
963
- },
964
- parent: this._select
965
- });
966
- /**
967
- * Hides an axis' ticks and labels if they all exist as labels for the data to be displayed,
968
- * primarily occuring in simple BarChart visualizations where the both the x-axis ticks and
969
- * the Bar rectangles would be displaying the same text.
970
- */ // generates an Array of String labels using the current label function for Bar shapes
971
- var barConfig = configPrep.bind(this)(this._shapeConfig, "shape", "Bar");
972
- var barLabelFunction = barConfig.label !== undefined ? typeof barConfig.label === "function" ? barConfig.label : constant(barConfig.label) : this._drawLabel;
973
- var barLabels = axisData.map(function(d) {
974
- return barLabelFunction(d.data, d.i);
975
- }).filter(function(d) {
976
- return typeof d === "number" || d;
977
- }).map(String);
978
- // sets an axis' ticks to [] if the axis scale is "Point" (discrete) and every tick String
979
- // is also in the barLabels Array
980
- var x2Ticks = unique(axisData.map(function(d) {
981
- return d.x2;
982
- }));
983
- x2Ticks = x2Scale === "Point" && x2Ticks.every(function(t) {
984
- return barLabels.includes("".concat(t));
985
- }) ? [] : null;
986
- var xTicks = unique(axisData.map(function(d) {
987
- return d.x;
988
- }));
989
- xTicks = xScale === "Point" && xTicks.every(function(t) {
990
- return barLabels.includes("".concat(t));
991
- }) ? [] : null;
992
- var y2Ticks = unique(axisData.map(function(d) {
993
- return d.y2;
994
- }));
995
- y2Ticks = y2Scale === "Point" && y2Ticks.every(function(t) {
996
- return barLabels.includes("".concat(t));
997
- }) ? [] : null;
998
- var yTicks = unique(axisData.map(function(d) {
999
- return d.y;
1000
- }));
1001
- yTicks = yScale === "Point" && yTicks.every(function(t) {
1002
- return barLabels.includes("".concat(t));
1003
- }) ? [] : null;
1004
- if (showY) {
1005
- this._yTest.domain(yDomain).height(height).maxSize(width / 2).range([
1006
- undefined,
1007
- undefined
1008
- ]).select(testGroup.node()).ticks(yTicks).width(width).config(yC).config(this._yConfig).scale(yConfigScale).render();
1009
- }
1010
- var yBounds = this._yTest.outerBounds();
1011
- var yWidth = yBounds.width ? yBounds.width + this._yTest.padding() : undefined;
1012
- if (y2Exists) {
1013
- this._y2Test.domain(y2Domain).height(height).range([
1014
- undefined,
1015
- undefined
1016
- ]).select(testGroup.node()).ticks(y2Ticks).width(width).config(yC).config(defaultY2Config).config(this._y2Config).scale(y2ConfigScale).render();
1017
- }
1018
- var y2Bounds = this._y2Test.outerBounds();
1019
- var y2Width = y2Bounds.width ? y2Bounds.width + this._y2Test.padding() : undefined;
1020
- var xC = {
1021
- data: xData,
1022
- locale: this._locale,
1023
- rounding: this._xDomain ? "none" : "outside",
1024
- scalePadding: x.padding ? x.padding() : 0
1025
- };
1026
- if (!showY && showX) {
1027
- xC.barConfig = {
1028
- stroke: "transparent"
1029
- };
1030
- xC.tickSize = 0;
1031
- xC.shapeConfig = {
1032
- labelBounds: function labelBounds(d, i) {
1033
- var _d_labelBounds = d.labelBounds, height = _d_labelBounds.height, y = _d_labelBounds.y;
1034
- var width = _this._width / 2;
1035
- var x = i ? -width : 0;
1036
- return {
1037
- x: x,
1038
- y: y,
1039
- width: width,
1040
- height: height
1041
- };
1042
- },
1043
- labelConfig: {
1044
- padding: 0,
1045
- rotate: 0,
1046
- textAnchor: function textAnchor(d) {
1047
- return xTicks && d.id === xTicks[0] ? "start" : "end";
1048
- }
1049
- },
1050
- labelRotation: false
1051
- };
1052
- }
1053
- var xRangeMax = undefined;
1054
- if (showX) {
1055
- this._xTest.domain(xDomain).height(height).maxSize(height / 2).range([
1056
- undefined,
1057
- xRangeMax
1058
- ]).select(testGroup.node()).ticks(xTicks).width(width).config(xC).config(this._xConfig).scale(xConfigScale).render();
1059
- }
1060
- var largestLabel, labelWidths = [];
1061
- var showLineLabels = this._lineLabels && !y2Exists;
1062
- if (showLineLabels) {
1063
- var labelData = data.filter(function(d) {
1064
- if (d.shape !== "Line") return false;
1065
- return typeof _this._lineLabels === "function" ? _this._lineLabels(d.data, d.i) : true;
1066
- });
1067
- var lineData = groups(labelData, function(d) {
1068
- return d.id;
1069
- });
1070
- if (lineData.length) {
1071
- var userConfig = configPrep.bind(this)(this._shapeConfig, "shape", "Line");
1072
- testLineShape.config(userConfig);
1073
- var lineLabelConfig = testLineShape.labelConfig();
1074
- var fontColorAccessor = lineLabelConfig.fontColor !== undefined ? lineLabelConfig.fontColor : testTextBox.fontColor();
1075
- var fontSizeAccessor = lineLabelConfig.fontSize !== undefined ? lineLabelConfig.fontSize : testTextBox.fontSize();
1076
- var fontWeightAccessor = lineLabelConfig.fontWeight !== undefined ? lineLabelConfig.fontWeight : testTextBox.fontWeight();
1077
- var fontFamilyAccessor = lineLabelConfig.fontFamily !== undefined ? lineLabelConfig.fontFamily : testTextBox.fontFamily();
1078
- var paddingAccessor = lineLabelConfig.padding !== undefined ? lineLabelConfig.padding : testTextBox.padding();
1079
- var labelFunction = userConfig.label || this._drawLabel;
1080
- var xEstimate = function xEstimate(d) {
1081
- if (xConfigScale === "log" && d === 0) d = xDomain[0] < 0 ? _this._xTest._d3Scale.domain()[1] : _this._xTest._d3Scale.domain()[0];
1082
- return _this._xTest._getPosition.bind(_this._xTest)(d);
1083
- };
1084
- var yEstimate = function yEstimate(d) {
1085
- if (yConfigScale === "log" && d === 0) d = yDomain[0] < 0 ? _this._yTest._d3Scale.domain()[1] : _this._yTest._d3Scale.domain()[0];
1086
- return _this._yTest._getPosition.bind(_this._yTest)(d);
1087
- };
1088
- labelWidths = lineData.map(function(param) {
1089
- var _param = _sliced_to_array(param, 2), lineKey = _param[0], lineValues = _param[1];
1090
- var d = lineValues[lineValues.length - 1];
1091
- var i;
1092
- while(d.__d3plus__ && d.data){
1093
- d = d.data;
1094
- i = d.i;
1095
- }
1096
- var label = typeof labelFunction === "function" ? labelFunction(d, i) : labelFunction;
1097
- var fontColor = typeof fontColorAccessor === "function" ? fontColorAccessor(d, i) : fontColorAccessor;
1098
- var fontSize = typeof fontSizeAccessor === "function" ? fontSizeAccessor(d, i) : fontSizeAccessor;
1099
- var fontWeight = typeof fontWeightAccessor === "function" ? fontWeightAccessor(d, i) : fontWeightAccessor;
1100
- var fontFamily = typeof fontFamilyAccessor === "function" ? fontFamilyAccessor(d, i) : fontFamilyAccessor;
1101
- if (_instanceof(fontFamily, Array)) fontFamily = fontFamily.map(function(f) {
1102
- return "'".concat(f, "'");
1103
- }).join(", ");
1104
- var labelPadding = typeof paddingAccessor === "function" ? paddingAccessor(d, i) : paddingAccessor;
1105
- var labelWidth = textWidth(label, {
1106
- "font-size": fontSize,
1107
- "font-family": fontFamily,
1108
- "font-weight": fontWeight
1109
- });
1110
- var coords = lineValues.map(function(d) {
1111
- return [
1112
- xEstimate(d.x),
1113
- yEstimate(d.y)
1114
- ];
1115
- });
1116
- var myMaxX = max(lineValues.map(function(d) {
1117
- return xEstimate(d.x);
1118
- }));
1119
- var labelY = lineValues.find(function(d) {
1120
- return xEstimate(d.x) === myMaxX;
1121
- }).y;
1122
- return {
1123
- id: lineKey,
1124
- labelWidth: labelWidth + labelPadding * 2,
1125
- spaceNeeded: labelWidth + labelPadding * 4,
1126
- value: labelY,
1127
- yEstimate: yEstimate(labelY),
1128
- padding: labelPadding,
1129
- fontSize: fontSize,
1130
- fontColor: fontColor,
1131
- maxX: myMaxX,
1132
- xValue: max(lineValues, function(d) {
1133
- return d.x;
1134
- }),
1135
- coords: coords
1136
- };
1137
- }).sort(function(a, b) {
1138
- return yDomain[1] > yDomain[0] ? a.value - b.value : b.value - a.value;
1139
- }).filter(function(d, i, arr) {
1140
- var fontSize = d.fontSize, id = d.id, labelWidth = d.labelWidth, maxX = d.maxX, yEstimate = d.yEstimate;
1141
- var closeLabels = arr.filter(function(l) {
1142
- return l.id !== id && l.coords.some(function(c) {
1143
- return (c[0] > maxX || c[0] === maxX && l.maxX !== maxX) && c[0] <= maxX + labelWidth && c[1] <= yEstimate + fontSize * 0.75 && c[1] >= yEstimate - fontSize * 0.75;
1144
- });
1145
- });
1146
- return closeLabels.length === 0;
1147
- });
1148
- var maxX = max(labelWidths, function(d) {
1149
- return d.maxX;
1150
- });
1151
- largestLabel = max(labelWidths.map(function(d) {
1152
- return d.labelWidth;
1153
- }));
1154
- var spaceNeeded = maxX === this._xTest._getRange.bind(this._xTest)()[1] ? max(labelWidths.filter(function(d) {
1155
- return d.maxX === maxX;
1156
- }), function(d) {
1157
- return d.spaceNeeded;
1158
- }) : 0;
1159
- if (spaceNeeded) {
1160
- var labelSpace = min([
1161
- spaceNeeded,
1162
- width / 4
1163
- ]);
1164
- xRangeMax = width - labelSpace - this._margin.right;
1165
- }
1166
- }
1167
- }
1168
- if (showX && xRangeMax) {
1169
- this._xTest.domain(xDomain).height(height).maxSize(height / 2).range([
1170
- undefined,
1171
- xRangeMax
1172
- ]).select(testGroup.node()).ticks(xTicks).width(width).config(xC).config(this._xConfig).scale(xConfigScale).render();
1173
- }
1174
- if (x2Exists) {
1175
- this._x2Test.domain(x2Domain).height(height).range([
1176
- undefined,
1177
- xRangeMax
1178
- ]).select(testGroup.node()).ticks(x2Ticks).width(width).config(xC).tickSize(0).config(defaultX2Config).config(this._x2Config).scale(x2ConfigScale).render();
1179
- }
1180
- var xTestRange = this._xTest._getRange();
1181
- var x2TestRange = this._x2Test._getRange();
1182
- var x2Bounds = this._x2Test.outerBounds();
1183
- var x2Height = x2Exists ? x2Bounds.height + this._x2Test.padding() : 0;
1184
- var xOffsetLeft = max([
1185
- yWidth,
1186
- xTestRange[0],
1187
- x2TestRange[0]
1188
- ]);
1189
- if (showX) {
1190
- this._xTest.range([
1191
- xOffsetLeft,
1192
- undefined
1193
- ]).render();
1194
- }
1195
- var topOffset = showY ? this._yTest.shapeConfig().labelConfig.fontSize() / 2 : 0;
1196
- var xOffsetRight = max([
1197
- y2Width,
1198
- width - xTestRange[1],
1199
- width - x2TestRange[1]
1200
- ]);
1201
- var xBounds = this._xTest.outerBounds();
1202
- var xHeight = xBounds.height + (showY ? this._xTest.padding() : 0);
1203
- this._padding.left += xOffsetLeft;
1204
- this._padding.right += xOffsetRight;
1205
- this._padding.bottom += xHeight;
1206
- this._padding.top += x2Height + topOffset;
1207
- _get(_get_prototype_of(Plot.prototype), "_draw", this).call(this, callback);
1208
- var horizontalMargin = this._margin.left + this._margin.right;
1209
- var verticalMargin = this._margin.top + this._margin.bottom;
1210
- var yRange = [
1211
- x2Height,
1212
- height - (xHeight + topOffset + verticalMargin)
1213
- ];
1214
- if (showY) {
1215
- this._yTest.domain(yDomain).height(height).maxSize(width / 2).range(yRange).select(testGroup.node()).ticks(yTicks).width(width).config(yC).config(this._yConfig).scale(yConfigScale).render();
1216
- }
1217
- yBounds = this._yTest.outerBounds();
1218
- yWidth = yBounds.width ? yBounds.width + this._yTest.padding() : undefined;
1219
- xOffsetLeft = max([
1220
- yWidth,
1221
- xTestRange[0],
1222
- x2TestRange[0]
1223
- ]);
1224
- if (y2Exists) {
1225
- this._y2Test.config(yC).domain(y2Domain).gridSize(0).height(height).range(yRange).select(testGroup.node()).width(width - max([
1226
- 0,
1227
- xOffsetRight - y2Width
1228
- ])).title(false).config(this._y2Config).config(defaultY2Config).scale(y2ConfigScale).render();
1229
- }
1230
- y2Bounds = this._y2Test.outerBounds();
1231
- y2Width = y2Bounds.width ? y2Bounds.width + this._y2Test.padding() : undefined;
1232
- xOffsetRight = max([
1233
- 0,
1234
- y2Width,
1235
- width - xTestRange[1],
1236
- width - x2TestRange[1]
1237
- ]);
1238
- var xRange = [
1239
- xOffsetLeft,
1240
- width - (xOffsetRight + horizontalMargin)
1241
- ];
1242
- var rectGroup = elem("g.d3plus-plot-background", {
1243
- parent: parent,
1244
- transition: transition
1245
- });
1246
- var transform = "translate(".concat(this._margin.left, ", ").concat(this._margin.top + x2Height + topOffset, ")");
1247
- var x2Transform = "translate(".concat(this._margin.left, ", ").concat(this._margin.top + topOffset, ")");
1248
- var xGroup = elem("g.d3plus-plot-x-axis", {
1249
- parent: parent,
1250
- transition: transition,
1251
- enter: {
1252
- transform: transform
1253
- },
1254
- update: {
1255
- transform: transform,
1256
- opacity: showX ? 1 : 0
1257
- }
1258
- });
1259
- var x2Group = x2Exists && elem("g.d3plus-plot-x2-axis", {
1260
- parent: parent,
1261
- transition: transition,
1262
- enter: {
1263
- transform: x2Transform
1264
- },
1265
- update: {
1266
- transform: x2Transform
1267
- }
1268
- });
1269
- var xTrans = xOffsetLeft > yWidth ? xOffsetLeft - yWidth : 0;
1270
- var yTransform = "translate(".concat(this._margin.left + xTrans, ", ").concat(this._margin.top + topOffset, ")");
1271
- var yGroup = elem("g.d3plus-plot-y-axis", {
1272
- parent: parent,
1273
- transition: transition,
1274
- enter: {
1275
- transform: yTransform
1276
- },
1277
- update: {
1278
- transform: yTransform,
1279
- opacity: showY ? 1 : 0
1280
- }
1281
- });
1282
- var y2Transform = "translate(-".concat(this._margin.right, ", ").concat(this._margin.top + topOffset, ")");
1283
- var y2Group = y2Exists && elem("g.d3plus-plot-y2-axis", {
1284
- parent: parent,
1285
- transition: transition,
1286
- enter: {
1287
- transform: y2Transform
1288
- },
1289
- update: {
1290
- transform: y2Transform
1291
- }
1292
- });
1293
- this._xAxis.domain(xDomain).height(height - (x2Height + topOffset + verticalMargin)).maxSize(height / 2).range(xRange).select(xGroup.node()).ticks(xTicks).width(width).config(xC).config(this._xConfig).scale(xConfigScale).render();
1294
- if (x2Exists) {
1295
- this._x2Axis.domain(x2Domain).height(height - (xHeight + topOffset + verticalMargin)).range(xRange).select(x2Group.node()).ticks(x2Ticks).width(width).config(xC).config(defaultX2Config).config(this._x2Config).scale(x2ConfigScale).render();
1296
- }
1297
- this._xFunc = x = function x(d, x) {
1298
- if (x === "x2") {
1299
- if (x2ConfigScale === "log" && d === 0) d = x2Domain[0] < 0 ? _this._x2Axis._d3Scale.domain()[1] : _this._x2Axis._d3Scale.domain()[0];
1300
- return _this._x2Axis._getPosition.bind(_this._x2Axis)(d);
1301
- } else {
1302
- if (xConfigScale === "log" && d === 0) d = xDomain[0] < 0 ? _this._xAxis._d3Scale.domain()[1] : _this._xAxis._d3Scale.domain()[0];
1303
- return _this._xAxis._getPosition.bind(_this._xAxis)(d);
1304
- }
1305
- };
1306
- yRange = [
1307
- this._xAxis.outerBounds().y + x2Height,
1308
- height - (xHeight + topOffset + verticalMargin)
1309
- ];
1310
- this._yAxis.domain(yDomain).height(height).maxSize(width / 2).range(yRange).select(yGroup.node()).ticks(yTicks).width(xRange[xRange.length - 1]).config(yC).config(this._yConfig).scale(yConfigScale).render();
1311
- if (y2Exists) {
1312
- this._y2Axis.config(yC).domain(y2Exists ? y2Domain : yDomain).gridSize(0).height(height).range(yRange).select(y2Group.node()).width(width - max([
1313
- 0,
1314
- xOffsetRight - y2Width
1315
- ])).title(false).config(this._y2Config).config(defaultY2Config).scale(y2ConfigScale).render();
1316
- }
1317
- var labelPositions = {};
1318
- if (labelWidths) {
1319
- groups(labelWidths, function(d) {
1320
- return d.xValue;
1321
- }).forEach(function(param) {
1322
- var _param = _sliced_to_array(param, 2), values = _param[1];
1323
- var minFontSize = max(values.map(function(d) {
1324
- return d.fontSize;
1325
- }));
1326
- var yBuckets = range(yRange[0], yRange[1], minFontSize).reverse();
1327
- var bumpLimit = (yRange[1] - yRange[0]) / 8;
1328
- /***/ function bumpPrevious(d, i, arr) {
1329
- if (!d.defaultY) d.defaultY = this._yAxis._getPosition(d.value);
1330
- if (i) {
1331
- var prev = arr[i - 1];
1332
- var fontSize = d.fontSize, padding = d.padding;
1333
- var y = d.newY || d.defaultY;
1334
- var prevY = prev.newY || prev.defaultY;
1335
- if (y - fontSize / 2 - padding < prevY) {
1336
- var newY = yBuckets.find(function(n) {
1337
- return n < prevY;
1338
- });
1339
- var change = d.defaultY - newY;
1340
- if (change < bumpLimit) {
1341
- prev.newY = newY;
1342
- if (i) bumpPrevious(prev, i - 1, arr);
1343
- }
1344
- }
1345
- }
1346
- }
1347
- values.forEach(bumpPrevious.bind(_this));
1348
- });
1349
- labelPositions = labelWidths.reduce(function(obj, d) {
1350
- if (d.newY) obj[d.id] = d.newY;
1351
- return obj;
1352
- }, {});
1353
- }
1354
- this._yFunc = y = function y(d, y) {
1355
- if (y === "y2") {
1356
- if (y2ConfigScale === "log" && d === 0) d = y2Domain[1] < 0 ? _this._y2Axis._d3ScaleNegative.domain()[0] : _this._y2Axis._d3Scale.domain()[1];
1357
- return _this._y2Axis._getPosition.bind(_this._y2Axis)(d) - x2Height;
1358
- } else {
1359
- if (yConfigScale === "log" && d === 0) d = yDomain[1] < 0 ? _this._yAxis._d3ScaleNegative.domain()[0] : _this._yAxis._d3Scale.domain()[1];
1360
- return _this._yAxis._getPosition.bind(_this._yAxis)(d) - x2Height;
1361
- }
1362
- };
1363
- var yOffset = this._xAxis.barConfig()["stroke-width"];
1364
- if (yOffset) yOffset /= 2;
1365
- new shapes.Rect().data([
1366
- {}
1367
- ]).select(rectGroup.node()).x(xRange[0] + (xRange[1] - xRange[0]) / 2).width(xRange[1] - xRange[0]).y(this._margin.top + topOffset + yRange[0] + (yRange[1] - yRange[0]) / 2).height(yRange[1] - yRange[0]).config(this._backgroundConfig).render();
1368
- var labelConnectors = labelWidths.filter(function(d) {
1369
- return d.newY !== undefined;
1370
- });
1371
- if (labelConnectors.length) {
1372
- var connectorGroup = elem("g.d3plus-plot-connectors", {
1373
- parent: parent,
1374
- transition: transition,
1375
- enter: {
1376
- transform: transform
1377
- },
1378
- update: {
1379
- transform: transform
1380
- }
1381
- }).node();
1382
- var data1 = labelConnectors.map(function(d) {
1383
- return assign({
1384
- x: _this._xAxis._getPosition.bind(_this._xAxis)(d.xValue),
1385
- y: d.defaultY
1386
- }, d);
1387
- }).concat(labelConnectors.map(function(d) {
1388
- return assign({
1389
- x: _this._xAxis._getPosition.bind(_this._xAxis)(d.xValue) + d.padding - 1,
1390
- y: d.newY || d.defaultY
1391
- }, d);
1392
- }));
1393
- new shapes.Line().config({
1394
- data: data1,
1395
- stroke: function stroke(d) {
1396
- return d.fontColor;
1397
- },
1398
- x: function x(d) {
1399
- return d.x;
1400
- },
1401
- y: function y(d) {
1402
- return d.y;
1403
- }
1404
- }).config(this._labelConnectorConfig).select(connectorGroup).render();
1405
- }
1406
- var annotationGroupBack = elem("g.d3plus-plot-annotations", {
1407
- parent: parent,
1408
- transition: transition,
1409
- enter: {
1410
- transform: transform
1411
- },
1412
- update: {
1413
- transform: transform
1414
- }
1415
- }).node();
1416
- var shapeGroup = elem("g.d3plus-plot-shapes", {
1417
- parent: parent,
1418
- transition: transition,
1419
- enter: {
1420
- transform: transform
1421
- },
1422
- update: {
1423
- transform: transform
1424
- }
1425
- }).node();
1426
- var annotationGroupFront = elem("g.d3plus-plot-annotations-front", {
1427
- parent: parent,
1428
- transition: transition,
1429
- enter: {
1430
- transform: transform
1431
- },
1432
- update: {
1433
- transform: transform
1434
- }
1435
- }).node();
1436
- Object.keys(this._previousAnnotations).forEach(function(layer) {
1437
- var group = layer === "front" ? annotationGroupFront : annotationGroupBack;
1438
- var annotationData = _this._annotations.filter(function(d) {
1439
- return layer === "back" && !d.layer || d.layer === layer;
1440
- });
1441
- var annotationShapes = annotationData.map(function(d) {
1442
- return d.shape;
1443
- });
1444
- annotationData.forEach(function(annotation) {
1445
- new shapes[annotation.shape]().duration(_this._duration).config(annotation).config({
1446
- x: function x1(d) {
1447
- return d.x2 ? x(d.x2, "x2") : x(d.x);
1448
- },
1449
- x0: _this._discrete === "x" ? function(d) {
1450
- return d.x2 ? x(d.x2, "x2") : x(d.x);
1451
- } : x(domains.x[0]),
1452
- x1: _this._discrete === "x" ? null : function(d) {
1453
- return d.x2 ? x(d.x2, "x2") : x(d.x);
1454
- },
1455
- y: function y1(d) {
1456
- return d.y2 ? y(d.y2, "y2") : y(d.y);
1457
- },
1458
- y0: _this._discrete === "y" ? function(d) {
1459
- return d.y2 ? y(d.y2, "y2") : y(d.y);
1460
- } : y(domains.y[1]) - yOffset,
1461
- y1: _this._discrete === "y" ? null : function(d) {
1462
- return d.y2 ? y(d.y2, "y2") : y(d.y) - yOffset;
1463
- }
1464
- }).select(group).render();
1465
- });
1466
- var exitAnnotations = _this._previousAnnotations[layer].filter(function(d) {
1467
- return !annotationShapes.includes(d);
1468
- });
1469
- exitAnnotations.forEach(function(shape) {
1470
- new shapes[shape]().data([]).select(group).render();
1471
- });
1472
- _this._previousAnnotations[layer] = annotationShapes;
1473
- });
1474
- var discrete1 = this._discrete || "x";
1475
- var shapeConfig = {
1476
- discrete: this._discrete,
1477
- duration: this._duration,
1478
- label: function label(d) {
1479
- return _this._drawLabel(d.data, d.i);
1480
- },
1481
- select: shapeGroup,
1482
- x: function x1(d) {
1483
- return d.x2 !== undefined ? x(d.x2, "x2") : x(d.x);
1484
- },
1485
- x0: discrete1 === "x" ? function(d) {
1486
- return d.x2 ? x(d.x2, "x2") : x(d.x);
1487
- } : x(typeof this._baseline === "number" ? this._baseline : domains.x[0]),
1488
- x1: discrete1 === "x" ? null : function(d) {
1489
- return d.x2 ? x(d.x2, "x2") : x(d.x);
1490
- },
1491
- y: function y1(d) {
1492
- return d.y2 !== undefined ? y(d.y2, "y2") : y(d.y);
1493
- },
1494
- y0: discrete1 === "y" ? function(d) {
1495
- return d.y2 ? y(d.y2, "y2") : y(d.y);
1496
- } : y(typeof this._baseline === "number" ? this._baseline : domains.y[1]) - yOffset,
1497
- y1: discrete1 === "y" ? null : function(d) {
1498
- return d.y2 ? y(d.y2, "y2") : y(d.y) - yOffset;
1499
- }
1500
- };
1501
- var events = Object.keys(this._on);
1502
- shapeData.forEach(function(param) {
1503
- var _loop = function(e) {
1504
- s.on(globalEvents[e], function(d, i, x, event) {
1505
- return _this._on[globalEvents[e]](d.data, d.i, x, event);
1506
- });
1507
- }, _loop1 = function(e1) {
1508
- s.on(shapeEvents[e1], function(d, i, x, event) {
1509
- return _this._on[shapeEvents[e1]](d.data, d.i, x, event);
1510
- });
1511
- }, _loop2 = function(e2) {
1512
- s.on(classEvents[e2], function(d, i, x, event) {
1513
- return _this._on[classEvents[e2]](d.data, d.i, x, event);
1514
- });
1515
- };
1516
- var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
1517
- var d = {
1518
- key: key,
1519
- values: values
1520
- };
1521
- var shapeConfigInner = Object.assign({}, shapeConfig);
1522
- if (_this._stacked && [
1523
- "Area",
1524
- "Bar"
1525
- ].includes(d.key)) {
1526
- var scale = opp === "x" ? x : y;
1527
- shapeConfigInner["".concat(opp)] = shapeConfigInner["".concat(opp, "0")] = function(d) {
1528
- var dataIndex = stackKeys.indexOf(d.id), discreteIndex = discreteKeys.indexOf(d.discrete);
1529
- var scaleIndex = d[opp] < 0 ? 1 : 0;
1530
- return dataIndex >= 0 ? scale(stackData[dataIndex][discreteIndex][scaleIndex]) : scale(domains[opp][opp === "x" ? 0 : 1]);
1531
- };
1532
- shapeConfigInner["".concat(opp, "1")] = function(d) {
1533
- var dataIndex = stackKeys.indexOf(d.id), discreteIndex = discreteKeys.indexOf(d.discrete);
1534
- var scaleIndex = d[opp] < 0 ? 0 : 1;
1535
- return dataIndex >= 0 ? scale(stackData[dataIndex][discreteIndex][scaleIndex]) : scale(domains[opp][opp === "x" ? 0 : 1]);
1536
- };
1537
- }
1538
- var s = new shapes[d.key]().config(shapeConfigInner).data(d.values);
1539
- if (d.key === "Bar") {
1540
- var space;
1541
- var scale1 = _this._discrete === "x" ? x : y;
1542
- var scaleType = _this._discrete === "x" ? xScale : yScale;
1543
- var vals = _this._discrete === "x" ? xDomain : yDomain;
1544
- var _$range = _this._discrete === "x" ? xRange : yRange;
1545
- if (scaleType !== "Point" && vals.length === 2) {
1546
- var allPositions = Array.from(new Set(d.values.map(function(d) {
1547
- return scale1(d[_this._discrete]);
1548
- })));
1549
- allPositions.unshift(_$range[0] - allPositions[0] - _$range[0]);
1550
- allPositions.push(_$range[1] + _$range[1] - allPositions[allPositions.length - 1]);
1551
- space = allPositions.reduce(function(n, d, i, arr) {
1552
- if (i) {
1553
- var dist = Math.abs(d - arr[i - 1]);
1554
- if (dist < n) n = dist;
1555
- }
1556
- return n;
1557
- }, Infinity);
1558
- } else if (vals.length > 1) space = scale1(vals[1]) - scale1(vals[0]);
1559
- else space = _$range[_$range.length - 1] - _$range[0];
1560
- if (_this._groupPadding < space) space -= _this._groupPadding;
1561
- var barSize = space || 1;
1562
- var barGroups = groups(d.values, function(d) {
1563
- return d[_this._discrete];
1564
- }, function(d) {
1565
- return d.group;
1566
- });
1567
- var ids = merge(barGroups.map(function(param) {
1568
- var _param = _sliced_to_array(param, 2), innerEntries = _param[1];
1569
- return innerEntries.map(function(param) {
1570
- var _param = _sliced_to_array(param, 1), k = _param[0];
1571
- return k;
1572
- });
1573
- }));
1574
- var uniqueIds = Array.from(new Set(ids));
1575
- if (max(barGroups.map(function(param) {
1576
- var _param = _sliced_to_array(param, 2), innerEntries = _param[1];
1577
- return innerEntries.length;
1578
- })) === 1) {
1579
- s[_this._discrete](function(d, i) {
1580
- return shapeConfig[_this._discrete](d, i);
1581
- });
1582
- } else {
1583
- barSize = (barSize - _this._barPadding * uniqueIds.length - 1) / uniqueIds.length;
1584
- var offset = space / 2 - barSize / 2;
1585
- var xMod = scales.scaleLinear().domain([
1586
- 0,
1587
- uniqueIds.length - 1
1588
- ]).range([
1589
- -offset,
1590
- offset
1591
- ]);
1592
- s[_this._discrete](function(d, i) {
1593
- return shapeConfig[_this._discrete](d, i) + xMod(uniqueIds.indexOf(d.group));
1594
- });
1595
- }
1596
- s.width(barSize);
1597
- s.height(barSize);
1598
- } else if (d.key === "Line") {
1599
- s.duration(width * 1.5);
1600
- if (_this._confidence) {
1601
- var areaConfig = Object.assign({}, shapeConfig);
1602
- var discrete = _this._discrete || "x";
1603
- var key1 = discrete === "x" ? "y" : "x";
1604
- var scaleFunction = discrete === "x" ? y : x;
1605
- areaConfig["".concat(key1, "0")] = function(d) {
1606
- return scaleFunction(_this._confidence[0] ? d.lci : d[key1]);
1607
- };
1608
- areaConfig["".concat(key1, "1")] = function(d) {
1609
- return scaleFunction(_this._confidence[1] ? d.hci : d[key1]);
1610
- };
1611
- var area = new shapes.Area().config(areaConfig).data(d.values);
1612
- var confidenceConfig = Object.assign(_this._shapeConfig, _this._confidenceConfig);
1613
- area.config(assign(configPrep.bind(_this)(confidenceConfig, "shape", "Line"), configPrep.bind(_this)(confidenceConfig, "shape", "Area"))).render();
1614
- _this._shapes.push(area);
1615
- }
1616
- s.config({
1617
- discrete: shapeConfig.discrete || "x",
1618
- label: showLineLabels ? function(d, i) {
1619
- var visible = typeof _this._lineLabels === "function" ? _this._lineLabels(d.data, d.i) : true;
1620
- if (!visible) return false;
1621
- var labelData = labelWidths.find(function(l) {
1622
- return l.id === d.id;
1623
- });
1624
- if (labelData) {
1625
- var yPos = labelData.newY || labelData.defaultY;
1626
- var allLabels = labelWidths.filter(function(l) {
1627
- return l.newY === yPos;
1628
- });
1629
- if (allLabels.length > 1) return allLabels[0].id !== d.id ? false : "+".concat(formatAbbreviate(allLabels.length, _this._locale), " ").concat(_this._translate("more"));
1630
- return _this._drawLabel(d, i);
1631
- }
1632
- return false;
1633
- } : false,
1634
- labelBounds: showLineLabels ? function(d, i, s) {
1635
- var _s_points_ = _sliced_to_array(s.points[0], 2), firstX = _s_points_[0], firstY = _s_points_[1];
1636
- var _s_points_1 = _sliced_to_array(s.points[s.points.length - 1], 2), lastX = _s_points_1[0], lastY = _s_points_1[1];
1637
- var height = _this._height / 4;
1638
- var mod = labelPositions[d.id] ? lastY - labelPositions[d.id] : 0;
1639
- return {
1640
- x: lastX - firstX,
1641
- y: lastY - firstY - height / 2 - mod,
1642
- width: largestLabel,
1643
- height: height
1644
- };
1645
- } : false
1646
- });
1647
- }
1648
- var classEvents = events.filter(function(e) {
1649
- return e.includes(".".concat(d.key));
1650
- }), globalEvents = events.filter(function(e) {
1651
- return !e.includes(".");
1652
- }), shapeEvents = events.filter(function(e) {
1653
- return e.includes(".shape");
1654
- });
1655
- for(var e = 0; e < globalEvents.length; e++)_loop(e);
1656
- for(var e1 = 0; e1 < shapeEvents.length; e1++)_loop1(e1);
1657
- for(var e2 = 0; e2 < classEvents.length; e2++)_loop2(e2);
1658
- var userConfig = configPrep.bind(_this)(_this._shapeConfig, "shape", d.key);
1659
- if (_this._shapeConfig.duration === undefined) delete userConfig.duration;
1660
- s.config(userConfig).render();
1661
- _this._shapes.push(s);
1662
- if (d.key === "Line") {
1663
- var _loop3 = function(e3) {
1664
- markers.on(globalEvents[e3], function(d, i, x, event) {
1665
- return _this._on[globalEvents[e3]](d.data, d.i, x, event);
1666
- });
1667
- }, _loop4 = function(e4) {
1668
- markers.on(shapeEvents[e4], function(d, i, x, event) {
1669
- return _this._on[shapeEvents[e4]](d.data, d.i, x, event);
1670
- });
1671
- }, _loop5 = function(e5) {
1672
- markers.on(classEvents[e5], function(d, i, x, event) {
1673
- return _this._on[classEvents[e5]](d.data, d.i, x, event);
1674
- });
1675
- };
1676
- var markers = new shapes.Circle().data(_this._lineMarkers ? d.values : []).config(shapeConfig).config(_this._lineMarkerConfig).id(function(d) {
1677
- return "".concat(d.id, "_").concat(d.discrete);
1678
- });
1679
- for(var e3 = 0; e3 < globalEvents.length; e3++)_loop3(e3);
1680
- for(var e4 = 0; e4 < shapeEvents.length; e4++)_loop4(e4);
1681
- for(var e5 = 0; e5 < classEvents.length; e5++)_loop5(e5);
1682
- markers.render();
1683
- _this._shapes.push(markers);
1684
- }
1685
- });
1686
- var dataShapes = shapeData.map(function(param) {
1687
- var _param = _sliced_to_array(param, 1), key = _param[0];
1688
- return key;
1689
- });
1690
- if (dataShapes.includes("Line")) {
1691
- if (this._confidence) dataShapes.push("Area");
1692
- if (this._lineMarkers) dataShapes.push("Circle");
1693
- }
1694
- var exitShapes = this._previousShapes.filter(function(d) {
1695
- return !dataShapes.includes(d);
1696
- });
1697
- exitShapes.forEach(function(shape) {
1698
- new shapes[shape]().config(shapeConfig).data([]).render();
1699
- });
1700
- this._previousShapes = dataShapes;
1701
- return this;
1702
- }
1703
- },
1704
- {
1705
- /**
1706
- Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
1707
-
1708
- Additionally, each config object can also contain an optional "layer" key, which defines whether the annotations will be displayed in "front" or in "back" of the primary visualization shapes. This value defaults to "back" if not present.
1709
- */ key: "annotations",
1710
- value: function annotations(_) {
1711
- return arguments.length ? (this._annotations = _instanceof(_, Array) ? _ : [
1712
- _
1713
- ], this) : this._annotations;
1714
- }
1715
- },
1716
- {
1717
- /**
1718
- Determines whether the x and y axes should have their scales persist while users filter the data, the timeline being the prime example (set this to `true` to make the axes stay consistent when the timeline changes).
1719
- */ key: "axisPersist",
1720
- value: function axisPersist(_) {
1721
- return arguments.length ? (this._axisPersist = _, this) : this._axisPersist;
1722
- }
1723
- },
1724
- {
1725
- /**
1726
- A d3plus-shape configuration Object used for styling the background rectangle of the inner x/y plot (behind all of the shapes and gridlines).
1727
- */ key: "backgroundConfig",
1728
- value: function backgroundConfig(_) {
1729
- return arguments.length ? (this._backgroundConfig = assign(this._backgroundConfig, _), this) : this._backgroundConfig;
1730
- }
1731
- },
1732
- {
1733
- /**
1734
- The pixel space between each bar in a group of bars.
1735
- */ key: "barPadding",
1736
- value: function barPadding(_) {
1737
- return arguments.length ? (this._barPadding = _, this) : this._barPadding;
1738
- }
1739
- },
1740
- {
1741
- /**
1742
- The baseline for the x/y plot.
1743
- */ key: "baseline",
1744
- value: function baseline(_) {
1745
- return arguments.length ? (this._baseline = _, this) : this._baseline;
1746
- }
1747
- },
1748
- {
1749
- /**
1750
- Determines whether or not to add additional padding at the ends of x or y scales. The most commone use for this is in Scatter Plots, so that the shapes do not appear directly on the axis itself. The value provided can either be `true` or `false` to toggle the behavior for all shape types, or a keyed Object for each shape type (ie. `{Bar: false, Circle: true, Line: false}`).
1751
- */ key: "buffer",
1752
- value: function buffer(_) {
1753
- if (arguments.length) {
1754
- if (!_) this._buffer = {};
1755
- else if (_ === true) this._buffer = defaultBuffers;
1756
- else {
1757
- this._buffer = assign({}, this._buffer, _);
1758
- for(var key in this._buffer){
1759
- if (this._buffer[key] === true) this._buffer[key] = defaultBuffers[key];
1760
- }
1761
- }
1762
- return this;
1763
- }
1764
- return this._buffer;
1765
- }
1766
- },
1767
- {
1768
- /**
1769
- The confidence interval as an array of [lower, upper] bounds.
1770
-
1771
- @example <caption>Can be called with accessor functions or static keys:</caption>
1772
- var data = {id: "alpha", value: 10, lci: 9, hci: 11};
1773
- ...
1774
- // Accessor functions
1775
- .confidence([function(d) { return d.lci }, function(d) { return d.hci }])
1776
-
1777
- // Or static keys
1778
- .confidence(["lci", "hci"])
1779
- */ key: "confidence",
1780
- value: function confidence(_) {
1781
- if (arguments.length && _instanceof(_, Array)) {
1782
- this._confidence = [];
1783
- var lower = _[0];
1784
- this._confidence[0] = typeof lower === "function" || !lower ? lower : accessor(lower);
1785
- var upper = _[1];
1786
- this._confidence[1] = typeof upper === "function" || !upper ? upper : accessor(upper);
1787
- return this;
1788
- } else return this._confidence;
1789
- }
1790
- },
1791
- {
1792
- /**
1793
- Configuration object for shapes rendered as confidence intervals.
1794
- */ key: "confidenceConfig",
1795
- value: function confidenceConfig(_) {
1796
- return arguments.length ? (this._confidenceConfig = assign(this._confidenceConfig, _), this) : this._confidenceConfig;
1797
- }
1798
- },
1799
- {
1800
- /**
1801
- When the width or height of the chart is less than or equal to this pixel value, the discrete axis will not be shown. This helps produce slick sparklines. Set this value to `0` to disable the behavior entirely.
1802
- */ key: "discreteCutoff",
1803
- value: function discreteCutoff(_) {
1804
- return arguments.length ? (this._discreteCutoff = _, this) : this._discreteCutoff;
1805
- }
1806
- },
1807
- {
1808
- /**
1809
- The pixel space between groups of bars.
1810
- */ key: "groupPadding",
1811
- value: function groupPadding(_) {
1812
- return arguments.length ? (this._groupPadding = _, this) : this._groupPadding;
1813
- }
1814
- },
1815
- {
1816
- /**
1817
- The d3plus-shape config used on the Line shapes created to connect lineLabels to the end of their associated Line path.
1818
- */ key: "labelConnectorConfig",
1819
- value: function labelConnectorConfig(_) {
1820
- return arguments.length ? (this._labelConnectorConfig = assign(this._labelConnectorConfig, _), this) : this._labelConnectorConfig;
1821
- }
1822
- },
1823
- {
1824
- /**
1825
- The behavior to be used when calculating the position and size of each shape's label(s). The value passed can either be the _String_ name of the behavior to be used for all shapes, or an accessor _Function_ that will be provided each data point and will be expected to return the behavior to be used for that data point. The availability and options for this method depend on the default logic for each Shape. As an example, the values "outside" or "inside" can be set for Bar shapes, whose "auto" default will calculate the best position dynamically based on the available space.
1826
- */ key: "labelPosition",
1827
- value: function labelPosition(_) {
1828
- return arguments.length ? (this._labelPosition = typeof _ === "function" ? _ : constant(_), this) : this._labelPosition;
1829
- }
1830
- },
1831
- {
1832
- /**
1833
- Draws labels on the right side of any Line shapes that are drawn on the plot.
1834
- */ key: "lineLabels",
1835
- value: function lineLabels(_) {
1836
- return arguments.length ? (this._lineLabels = _, this) : this._lineLabels;
1837
- }
1838
- },
1839
- {
1840
- /**
1841
- Shape config for the Circle shapes drawn by the lineMarkers method.
1842
- */ key: "lineMarkerConfig",
1843
- value: function lineMarkerConfig(_) {
1844
- return arguments.length ? (this._lineMarkerConfig = assign(this._lineMarkerConfig, _), this) : this._lineMarkerConfig;
1845
- }
1846
- },
1847
- {
1848
- /**
1849
- Draws circle markers on each vertex of a Line.
1850
- */ key: "lineMarkers",
1851
- value: function lineMarkers(_) {
1852
- return arguments.length ? (this._lineMarkers = _, this) : this._lineMarkers;
1853
- }
1854
- },
1855
- {
1856
- /**
1857
- A JavaScript [sort comparator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) that receives each shape Class (ie. "Circle", "Line", etc) as it's comparator arguments. Shapes are drawn in groups based on their type, so you are defining the layering order for all shapes of said type.
1858
- */ key: "shapeSort",
1859
- value: function shapeSort(_) {
1860
- return arguments.length ? (this._shapeSort = _, this) : this._shapeSort;
1861
- }
1862
- },
1863
- {
1864
- /**
1865
- Sets the size of bubbles to the given Number, data key, or function.
1866
- */ key: "size",
1867
- value: function size(_) {
1868
- return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
1869
- }
1870
- },
1871
- {
1872
- /**
1873
- Sets the size scale maximum to the specified number.
1874
- */ key: "sizeMax",
1875
- value: function sizeMax(_) {
1876
- return arguments.length ? (this._sizeMax = _, this) : this._sizeMax;
1877
- }
1878
- },
1879
- {
1880
- /**
1881
- Sets the size scale minimum to the specified number.
1882
- */ key: "sizeMin",
1883
- value: function sizeMin(_) {
1884
- return arguments.length ? (this._sizeMin = _, this) : this._sizeMin;
1885
- }
1886
- },
1887
- {
1888
- /**
1889
- Sets the size scale to the specified string.
1890
- */ key: "sizeScale",
1891
- value: function sizeScale(_) {
1892
- return arguments.length ? (this._sizeScale = _, this) : this._sizeScale;
1893
- }
1894
- },
1895
- {
1896
- /**
1897
- If *value* is specified, toggles shape stacking. If *value* is not specified, returns the current stack value.
1898
- */ key: "stacked",
1899
- value: function stacked(_) {
1900
- return arguments.length ? (this._stacked = _, this) : this._stacked;
1901
- }
1902
- },
1903
- {
1904
- /**
1905
- Sets the stack offset. If *value* is not specified, returns the current stack offset function.
1906
- */ key: "stackOffset",
1907
- value: function stackOffset(_) {
1908
- return arguments.length ? (this._stackOffset = typeof _ === "function" ? _ : d3Shape["stackOffset".concat(_.charAt(0).toUpperCase() + _.slice(1))], this) : this._stackOffset;
1909
- }
1910
- },
1911
- {
1912
- /**
1913
- Sets the stack order. If *value* is not specified, returns the current stack order function.
1914
- */ key: "stackOrder",
1915
- value: function stackOrder(_) {
1916
- if (arguments.length) {
1917
- if (typeof _ === "string") this._stackOrder = _ === "ascending" ? stackOrderAscending : _ === "descending" ? stackOrderDescending : d3Shape["stackOrder".concat(_.charAt(0).toUpperCase() + _.slice(1))];
1918
- else this._stackOrder = _;
1919
- return this;
1920
- } else return this._stackOrder;
1921
- }
1922
- },
1923
- {
1924
- /**
1925
- Accessor function or string key for the x-axis value of each data point.
1926
- */ key: "x",
1927
- value: function x(_) {
1928
- if (arguments.length) {
1929
- if (typeof _ === "function") this._x = _;
1930
- else {
1931
- this._x = accessor(_);
1932
- this._xKey = _;
1933
- }
1934
- return this;
1935
- } else return this._x;
1936
- }
1937
- },
1938
- {
1939
- /**
1940
- Accessor function or string key for the secondary x-axis value of each data point.
1941
- */ key: "x2",
1942
- value: function x2(_) {
1943
- if (arguments.length) {
1944
- if (typeof _ === "function") this._x2 = _;
1945
- else {
1946
- this._x2 = accessor(_);
1947
- this._x2Key = _;
1948
- }
1949
- return this;
1950
- } else return this._x2;
1951
- }
1952
- },
1953
- {
1954
- /**
1955
- A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the x-axis. Includes additional functionality where passing "auto" as the value for the [scale](http://d3plus.org/docs/#Axis.scale) method will determine if the scale should be "linear" or "log" based on the provided data.
1956
- */ key: "xConfig",
1957
- value: function xConfig(_) {
1958
- return arguments.length ? (this._xConfig = assign(this._xConfig, _), this) : this._xConfig;
1959
- }
1960
- },
1961
- {
1962
- /**
1963
- When the width of the chart is less than or equal to this pixel value, and the x-axis is not the discrete axis, it will not be shown. This helps produce slick sparklines. Set this value to `0` to disable the behavior entirely.
1964
- */ key: "xCutoff",
1965
- value: function xCutoff(_) {
1966
- return arguments.length ? (this._xCutoff = _, this) : this._xCutoff;
1967
- }
1968
- },
1969
- {
1970
- /**
1971
- A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the secondary x-axis. Includes additional functionality where passing "auto" as the value for the [scale](http://d3plus.org/docs/#Axis.scale) method will determine if the scale should be "linear" or "log" based on the provided data.
1972
- */ key: "x2Config",
1973
- value: function x2Config(_) {
1974
- return arguments.length ? (this._x2Config = assign(this._x2Config, _), this) : this._x2Config;
1975
- }
1976
- },
1977
- {
1978
- /**
1979
- The x domain as an array. If either value is undefined, it will be calculated from the data.
1980
- */ key: "xDomain",
1981
- value: function xDomain(_) {
1982
- return arguments.length ? (this._xDomain = _, this) : this._xDomain;
1983
- }
1984
- },
1985
- {
1986
- /**
1987
- The x2 domain as an array. If either value is undefined, it will be calculated from the data.
1988
- */ key: "x2Domain",
1989
- value: function x2Domain(_) {
1990
- return arguments.length ? (this._x2Domain = _, this) : this._x2Domain;
1991
- }
1992
- },
1993
- {
1994
- /**
1995
- Defines a custom sorting comparitor function to be used for discrete x axes.
1996
- */ key: "xSort",
1997
- value: function xSort(_) {
1998
- return arguments.length ? (this._xSort = _, this) : this._xSort;
1999
- }
2000
- },
2001
- {
2002
- /**
2003
- Defines a custom sorting comparitor function to be used for discrete x2 axes.
2004
- */ key: "x2Sort",
2005
- value: function x2Sort(_) {
2006
- return arguments.length ? (this._x2Sort = _, this) : this._x2Sort;
2007
- }
2008
- },
2009
- {
2010
- /**
2011
- Accessor function or string key for the y-axis value of each data point.
2012
- */ key: "y",
2013
- value: function y(_) {
2014
- if (arguments.length) {
2015
- if (typeof _ === "function") this._y = _;
2016
- else {
2017
- this._y = accessor(_);
2018
- this._yKey = _;
2019
- }
2020
- return this;
2021
- } else return this._y;
2022
- }
2023
- },
2024
- {
2025
- /**
2026
- Accessor function or string key for the secondary y-axis value of each data point.
2027
- */ key: "y2",
2028
- value: function y2(_) {
2029
- if (arguments.length) {
2030
- if (typeof _ === "function") this._y2 = _;
2031
- else {
2032
- this._y2 = accessor(_);
2033
- this._y2Key = _;
2034
- }
2035
- return this;
2036
- } else return this._y2;
2037
- }
2038
- },
2039
- {
2040
- /**
2041
- A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the y-axis. Includes additional functionality where passing "auto" as the value for the [scale](http://d3plus.org/docs/#Axis.scale) method will determine if the scale should be "linear" or "log" based on the provided data.
2042
-
2043
- *Note:* If a "domain" array is passed to the y-axis config, it will be reversed.
2044
- */ key: "yConfig",
2045
- value: function yConfig(_) {
2046
- if (arguments.length) {
2047
- if (_.domain) _.domain = _.domain.slice().reverse();
2048
- this._yConfig = assign(this._yConfig, _);
2049
- return this;
2050
- }
2051
- return this._yConfig;
2052
- }
2053
- },
2054
- {
2055
- /**
2056
- When the height of the chart is less than or equal to this pixel value, and the y-axis is not the discrete axis, it will not be shown. This helps produce slick sparklines. Set this value to `0` to disable the behavior entirely.
2057
- */ key: "yCutoff",
2058
- value: function yCutoff(_) {
2059
- return arguments.length ? (this._yCutoff = _, this) : this._yCutoff;
2060
- }
2061
- },
2062
- {
2063
- /**
2064
- A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the secondary y-axis. Includes additional functionality where passing "auto" as the value for the [scale](http://d3plus.org/docs/#Axis.scale) method will determine if the scale should be "linear" or "log" based on the provided data.
2065
- */ key: "y2Config",
2066
- value: function y2Config(_) {
2067
- if (arguments.length) {
2068
- if (_.domain) _.domain = _.domain.slice().reverse();
2069
- this._y2Config = assign(this._y2Config, _);
2070
- return this;
2071
- }
2072
- return this._y2Config;
2073
- }
2074
- },
2075
- {
2076
- /**
2077
- The y domain as an array. If either value is undefined, it will be calculated from the data.
2078
- */ key: "yDomain",
2079
- value: function yDomain(_) {
2080
- return arguments.length ? (this._yDomain = _, this) : this._yDomain;
2081
- }
2082
- },
2083
- {
2084
- /**
2085
- The y2 domain as an array. If either value is undefined, it will be calculated from the data.
2086
- */ key: "y2Domain",
2087
- value: function y2Domain(_) {
2088
- return arguments.length ? (this._y2Domain = _, this) : this._y2Domain;
2089
- }
2090
- },
2091
- {
2092
- /**
2093
- Defines a custom sorting comparitor function to be used for discrete y axes.
2094
- */ key: "ySort",
2095
- value: function ySort(_) {
2096
- return arguments.length ? (this._ySort = _, this) : this._ySort;
2097
- }
2098
- },
2099
- {
2100
- /**
2101
- Defines a custom sorting comparitor function to be used for discrete y2 axes.
2102
- */ key: "y2Sort",
2103
- value: function y2Sort(_) {
2104
- return arguments.length ? (this._y2Sort = _, this) : this._y2Sort;
2105
- }
2106
- }
2107
- ]);
2108
- return Plot;
2109
- }(Viz);
2110
- /**
2111
- Creates an x/y plot based on an array of data.
2112
- */ export { Plot as default };
2113
-
2114
- //# sourceMappingURL=Plot.js.map