@d3plus/core 4.3.0 → 4.5.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 (197) hide show
  1. package/README.md +1820 -714
  2. package/es/index.js +1 -1
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +7 -1
  5. package/es/internal.js.map +1 -1
  6. package/es/src/charts/AreaPlot/index.js +1 -2
  7. package/es/src/charts/AreaPlot/index.js.map +1 -1
  8. package/es/src/charts/BarChart/index.js +1 -2
  9. package/es/src/charts/BarChart/index.js.map +1 -1
  10. package/es/src/charts/BoxWhisker/index.js +1 -2
  11. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  12. package/es/src/charts/BumpChart/index.js +1 -2
  13. package/es/src/charts/BumpChart/index.js.map +1 -1
  14. package/es/src/charts/Chord/applyLayout.js +205 -0
  15. package/es/src/charts/Chord/applyLayout.js.map +1 -0
  16. package/es/src/charts/Chord/emit.js +168 -0
  17. package/es/src/charts/Chord/emit.js.map +1 -0
  18. package/es/src/charts/Chord/index.js +234 -0
  19. package/es/src/charts/Chord/index.js.map +1 -0
  20. package/es/src/charts/Geomap/basemapTheme.js +78 -0
  21. package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
  22. package/es/src/charts/Geomap/emit.js +18 -9
  23. package/es/src/charts/Geomap/emit.js.map +1 -1
  24. package/es/src/charts/Geomap/index.js +69 -104
  25. package/es/src/charts/Geomap/index.js.map +1 -1
  26. package/es/src/charts/LinePlot/index.js +1 -2
  27. package/es/src/charts/LinePlot/index.js.map +1 -1
  28. package/es/src/charts/Matrix/emit.js +6 -0
  29. package/es/src/charts/Matrix/emit.js.map +1 -1
  30. package/es/src/charts/Matrix/index.js +1 -2
  31. package/es/src/charts/Matrix/index.js.map +1 -1
  32. package/es/src/charts/Network/emit.js +58 -24
  33. package/es/src/charts/Network/emit.js.map +1 -1
  34. package/es/src/charts/Network/index.js +34 -54
  35. package/es/src/charts/Network/index.js.map +1 -1
  36. package/es/src/charts/Pack/emit.js +3 -0
  37. package/es/src/charts/Pack/emit.js.map +1 -1
  38. package/es/src/charts/Pack/index.js +1 -2
  39. package/es/src/charts/Pack/index.js.map +1 -1
  40. package/es/src/charts/Pie/emit.js +6 -2
  41. package/es/src/charts/Pie/emit.js.map +1 -1
  42. package/es/src/charts/Pie/index.js +1 -2
  43. package/es/src/charts/Pie/index.js.map +1 -1
  44. package/es/src/charts/Plot/index.js +26 -6
  45. package/es/src/charts/Plot/index.js.map +1 -1
  46. package/es/src/charts/Plot/pipeline.js +1 -2
  47. package/es/src/charts/Plot/pipeline.js.map +1 -1
  48. package/es/src/charts/Plot/plotZoom.js +278 -0
  49. package/es/src/charts/Plot/plotZoom.js.map +1 -0
  50. package/es/src/charts/Priestley/emit.js +4 -0
  51. package/es/src/charts/Priestley/emit.js.map +1 -1
  52. package/es/src/charts/Priestley/index.js +1 -2
  53. package/es/src/charts/Priestley/index.js.map +1 -1
  54. package/es/src/charts/Radar/emit.js +4 -1
  55. package/es/src/charts/Radar/emit.js.map +1 -1
  56. package/es/src/charts/Radar/index.js +1 -2
  57. package/es/src/charts/Radar/index.js.map +1 -1
  58. package/es/src/charts/RadialMatrix/emit.js +6 -0
  59. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  60. package/es/src/charts/RadialMatrix/index.js +1 -2
  61. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  62. package/es/src/charts/Rings/emit.js +74 -8
  63. package/es/src/charts/Rings/emit.js.map +1 -1
  64. package/es/src/charts/Rings/index.js +11 -3
  65. package/es/src/charts/Rings/index.js.map +1 -1
  66. package/es/src/charts/Sankey/emit.js +55 -11
  67. package/es/src/charts/Sankey/emit.js.map +1 -1
  68. package/es/src/charts/Sankey/index.js +8 -2
  69. package/es/src/charts/Sankey/index.js.map +1 -1
  70. package/es/src/charts/StackedArea/index.js +1 -2
  71. package/es/src/charts/StackedArea/index.js.map +1 -1
  72. package/es/src/charts/Tree/emit.js +8 -2
  73. package/es/src/charts/Tree/emit.js.map +1 -1
  74. package/es/src/charts/Tree/index.js +1 -2
  75. package/es/src/charts/Tree/index.js.map +1 -1
  76. package/es/src/charts/Treemap/index.js +1 -2
  77. package/es/src/charts/Treemap/index.js.map +1 -1
  78. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  79. package/es/src/charts/drawSteps/backControl.js +70 -0
  80. package/es/src/charts/drawSteps/backControl.js.map +1 -0
  81. package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
  82. package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
  83. package/es/src/charts/drawSteps/minimap.js +370 -0
  84. package/es/src/charts/drawSteps/minimap.js.map +1 -0
  85. package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
  86. package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
  87. package/es/src/charts/drawSteps/searchControls.js +358 -0
  88. package/es/src/charts/drawSteps/searchControls.js.map +1 -0
  89. package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
  90. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
  91. package/es/src/charts/drawSteps/tableView.js +173 -0
  92. package/es/src/charts/drawSteps/tableView.js.map +1 -0
  93. package/es/src/charts/drawSteps/tableViewControl.js +39 -0
  94. package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
  95. package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
  96. package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
  97. package/es/src/charts/drawSteps/topLeftControls.js +73 -0
  98. package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
  99. package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
  100. package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
  101. package/es/src/charts/drawSteps/zoomControls.js +314 -175
  102. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  103. package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
  104. package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
  105. package/es/src/charts/features/attributionFeature.js +137 -0
  106. package/es/src/charts/features/attributionFeature.js.map +1 -0
  107. package/es/src/charts/features/axes.js +20 -8
  108. package/es/src/charts/features/axes.js.map +1 -1
  109. package/es/src/charts/features/chartGeometry.js +16 -2
  110. package/es/src/charts/features/chartGeometry.js.map +1 -1
  111. package/es/src/charts/features/edgeArrows.js +155 -0
  112. package/es/src/charts/features/edgeArrows.js.map +1 -0
  113. package/es/src/charts/features/emitHelpers.js +8 -0
  114. package/es/src/charts/features/emitHelpers.js.map +1 -1
  115. package/es/src/charts/features/ensureZoomDom.js +63 -12
  116. package/es/src/charts/features/ensureZoomDom.js.map +1 -1
  117. package/es/src/charts/features/features.js +83 -110
  118. package/es/src/charts/features/features.js.map +1 -1
  119. package/es/src/charts/features/featuresLegend.js +45 -17
  120. package/es/src/charts/features/featuresLegend.js.map +1 -1
  121. package/es/src/charts/features/plotPaint.js +32 -7
  122. package/es/src/charts/features/plotPaint.js.map +1 -1
  123. package/es/src/charts/features/zoomExtent.js +185 -0
  124. package/es/src/charts/features/zoomExtent.js.map +1 -0
  125. package/es/src/charts/helpers/tileAttributions.js +26 -0
  126. package/es/src/charts/helpers/tileAttributions.js.map +1 -1
  127. package/es/src/charts/index.js +1 -0
  128. package/es/src/charts/index.js.map +1 -1
  129. package/es/src/charts/pipeline/runVizPipeline.js +33 -14
  130. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  131. package/es/src/charts/pipeline/vizDrawPure.js +32 -6
  132. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  133. package/es/src/charts/viz/Viz.js +39 -51
  134. package/es/src/charts/viz/Viz.js.map +1 -1
  135. package/es/src/charts/viz/VizBase.js +157 -4
  136. package/es/src/charts/viz/VizBase.js.map +1 -1
  137. package/es/src/charts/viz/VizBaseConfig.js +32 -2
  138. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  139. package/es/src/charts/viz/vizDefaults.js +243 -50
  140. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  141. package/es/src/charts/viz/vizTypes.js.map +1 -1
  142. package/es/src/components/Axis/Axis.js +10 -1
  143. package/es/src/components/Axis/Axis.js.map +1 -1
  144. package/es/src/components/Axis/axisLayoutLabels.js +2 -1
  145. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  146. package/es/src/components/Axis/axisRender.js +5 -1
  147. package/es/src/components/Axis/axisRender.js.map +1 -1
  148. package/es/src/components/Legend/legendConfig.js +86 -20
  149. package/es/src/components/Legend/legendConfig.js.map +1 -1
  150. package/es/src/utils/D3plusConfig.js.map +1 -1
  151. package/package.json +11 -10
  152. package/types/index.d.ts +1 -1
  153. package/types/internal.d.ts +8 -1
  154. package/types/src/charts/Chord/applyLayout.d.ts +43 -0
  155. package/types/src/charts/Chord/emit.d.ts +10 -0
  156. package/types/src/charts/Chord/index.d.ts +19 -0
  157. package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
  158. package/types/src/charts/Plot/index.d.ts +12 -3
  159. package/types/src/charts/Plot/plotZoom.d.ts +65 -0
  160. package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
  161. package/types/src/charts/drawSteps/backControl.d.ts +29 -0
  162. package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
  163. package/types/src/charts/drawSteps/minimap.d.ts +19 -0
  164. package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
  165. package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
  166. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
  167. package/types/src/charts/drawSteps/tableView.d.ts +23 -0
  168. package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
  169. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
  170. package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
  171. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
  172. package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
  173. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
  174. package/types/src/charts/features/attributionFeature.d.ts +21 -0
  175. package/types/src/charts/features/axes.d.ts +1 -1
  176. package/types/src/charts/features/chartGeometry.d.ts +9 -3
  177. package/types/src/charts/features/edgeArrows.d.ts +92 -0
  178. package/types/src/charts/features/emitHelpers.d.ts +11 -0
  179. package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
  180. package/types/src/charts/features/features.d.ts +32 -17
  181. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  182. package/types/src/charts/features/plotPaint.d.ts +15 -2
  183. package/types/src/charts/features/zoomExtent.d.ts +25 -0
  184. package/types/src/charts/index.d.ts +1 -0
  185. package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
  186. package/types/src/charts/viz/VizBase.d.ts +86 -4
  187. package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
  188. package/types/src/charts/viz/vizDefaults.d.ts +155 -0
  189. package/types/src/charts/viz/vizTypes.d.ts +57 -1
  190. package/types/src/components/Axis/Axis.d.ts +2 -0
  191. package/types/src/utils/D3plusConfig.d.ts +102 -8
  192. package/umd/d3plus-core.full.js +39613 -35374
  193. package/umd/d3plus-core.full.js.map +1 -1
  194. package/umd/d3plus-core.full.min.js +5747 -4361
  195. package/umd/d3plus-core.js +13132 -9289
  196. package/umd/d3plus-core.js.map +1 -1
  197. package/umd/d3plus-core.min.js +3658 -2302
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/features/attributionFeature.ts"],"sourcesContent":["/**\n The tile/data credit, an HTML overlay in the chart area's bottom-right\n corner. It sits outside the SVG plane, so rather than encode it into the\n scene graph this feature creates it imperatively from inside `layout()`\n (funneled through `runLayout` like the other features); it claims zero\n margin and emits no panel.\n\n A credit that would take up more than half the chart's width collapses to\n an ⓘ badge that expands on hover, focus, or click — the compact\n attribution modern web maps use — so a long required credit (Esri's\n basemap credit, for one) doesn't lay a banner across a small map.\n\n The badge is an inline SVG by default; `attributionIcon` overrides it with\n raw HTML or a mount function (a live component escape hatch — see its doc\n and `zoomControlsMarkup.ts`'s matching `zoomControlIcons`, which this\n mirrors).\n\n @module\n*/\n\nimport {select} from \"d3-selection\";\n\nimport {stylize} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\n\nimport type {FeatureModule} from \"./features.js\";\nimport {chartBounds} from \"./chartGeometry.js\";\nimport {attributionStyleDarkDefault, attributionStyleDefault} from \"../viz/vizDefaults.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/** An \"i\" in a circle, drawn like the zoom-control icons (see `zoomControlsMarkup.ts`). */\nconst INFO_ICON =\n '<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" style=\"width:12px;height:12px;display:block\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"11\" x2=\"12\" y2=\"17\"/><line x1=\"12\" y1=\"7\" x2=\"12\" y2=\"7.01\"/></svg>';\n\n/** Markup for a mount-function icon — see `zoomControlsMarkup.ts`'s `iconSlot`. */\nconst CUSTOM_ICON_SLOT =\n '<span class=\"d3plus-attribution-icon\" style=\"display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0\"></span>';\n\n/** The toggle button's glyph markup: a custom override, or the built-in \"i\". */\nfunction toggleIcon(viz: VizInstance): string {\n const icon = viz.schema.attributionIcon;\n if (typeof icon === \"string\") return icon;\n if (typeof icon === \"function\") return CUSTOM_ICON_SLOT;\n return INFO_ICON;\n}\n\n/**\n Mounts a custom `attributionIcon` mount function into the toggle's\n reserved slot, running any previous mount's cleanup first. Called only\n when the credit's html was JUST rewritten (see the `__d3plusHTML` diff in\n `layout()` below) — i.e. once per fresh slot element, not on every draw.\n*/\nfunction mountCustomAttributionIcon(viz: VizInstance, node: HTMLElement): void {\n const icon = viz.schema.attributionIcon;\n if (typeof icon !== \"function\") return;\n const slot = node.querySelector<HTMLElement>(\".d3plus-attribution-icon\");\n if (!slot) return;\n viz._attributionIconCleanup?.();\n viz._attributionIconCleanup = icon(slot) || undefined;\n}\n\n/** The credit wider than this share of the chart area collapses to a badge. */\nconst COMPACT_SHARE = 0.5;\n\n/** Shows or hides a compact credit's text. */\nfunction setExpanded(node: HTMLElement, open: boolean): void {\n const text = node.querySelector<HTMLElement>(\".d3plus-attribution-text\");\n const toggle = node.querySelector<HTMLElement>(\".d3plus-attribution-toggle\");\n if (text) text.style.display = open ? \"\" : \"none\";\n if (toggle) toggle.setAttribute(\"aria-expanded\", String(open));\n node.style.borderRadius = open ? \"3px 0 0 0\" : \"3px 0 0 0\";\n node.style.padding = open ? \"4px 6px\" : \"2px\";\n}\n\nexport const attributionFeature: FeatureModule = {\n name: \"attribution\",\n configFields: [\"attribution\", \"attributionIcon\", \"attributionStyle\"],\n layout: ({viz}) => {\n let attr: D3Selection = select(viz._select.node().parentNode)\n .selectAll(\"div.d3plus-attribution\")\n .data(viz.schema.attribution ? [0] : []) as unknown as D3Selection;\n\n const attrEnter = attr\n .enter()\n .append(\"div\")\n .attr(\"class\", \"d3plus-attribution\");\n\n attr.exit().remove();\n\n const style =\n viz.schema.attributionStyle === attributionStyleDefault && viz._basemapDark\n ? attributionStyleDarkDefault\n : viz.schema.attributionStyle;\n\n attr = attr\n .merge(attrEnter as never)\n .style(\"position\", \"absolute\")\n .style(\"right\", `${viz._margin.right}px`)\n .style(\"bottom\", `${viz._margin.bottom}px`)\n .call(stylize as never, style);\n\n // Rewrite the markup — and remount a custom icon — only when it actually\n // changed (the credit text, locale, theme, or icon override), the same\n // `__d3plusHTML`-diff idiom `@d3plus/render`'s overlay host uses. `.html()`\n // runs unconditionally on every draw otherwise, which would tear down and\n // rebuild a mounted `attributionIcon` (a React root, say) on every redraw\n // instead of only when its content is due to change.\n const html =\n `<span class=\"d3plus-attribution-text\">${viz.schema.attribution}</span>` +\n `<button type=\"button\" class=\"d3plus-attribution-toggle\" aria-label=\"${viz.schema.translate(\"Attribution\")}\" aria-expanded=\"true\">${toggleIcon(viz)}</button>`;\n const rewriteNode = attr.node() as (HTMLElement & {__d3plusHTML?: string}) | null;\n if (rewriteNode && rewriteNode.__d3plusHTML !== html) {\n rewriteNode.innerHTML = html;\n rewriteNode.__d3plusHTML = html;\n rewriteNode\n .querySelectorAll<HTMLElement>(\"a\")\n .forEach(a => {\n a.style.color = \"inherit\";\n a.style.textDecoration = \"none\";\n });\n const toggleEl = rewriteNode.querySelector<HTMLElement>(\".d3plus-attribution-toggle\");\n if (toggleEl) {\n toggleEl.style.border = \"0\";\n toggleEl.style.background = \"transparent\";\n toggleEl.style.color = \"inherit\";\n toggleEl.style.padding = \"0\";\n toggleEl.style.flexShrink = \"0\";\n }\n mountCustomAttributionIcon(viz, rewriteNode);\n }\n\n const node = attr.node() as HTMLElement | null;\n if (!node) return {panel: null, margin: {}};\n const {width} = chartBounds(viz);\n node.style.maxWidth = `${Math.min(280, width)}px`;\n\n // Measure the credit on one line to decide whether it collapses.\n const text = node.querySelector<HTMLElement>(\".d3plus-attribution-text\")!;\n text.style.whiteSpace = \"nowrap\";\n const compact = text.getBoundingClientRect().width > width * COMPACT_SHARE;\n text.style.whiteSpace = \"\";\n const toggle = select(node).select(\".d3plus-attribution-toggle\").style(\"display\", compact ? \"\" : \"none\");\n\n if (!compact) {\n select(node).on(\".compact\", null);\n setExpanded(node, true);\n return {panel: null, margin: {}};\n }\n\n // Hover or focus previews the credit; a click pins it open (or closed).\n const show = () => setExpanded(node, Boolean(viz._attributionPinned || node.matches(\":hover, :focus-within\")));\n select(node)\n .on(\"mouseenter.compact focusin.compact\", () => setExpanded(node, true))\n .on(\"mouseleave.compact focusout.compact\", () => window.setTimeout(show, 0));\n toggle.on(\"click.compact\", () => {\n viz._attributionPinned = !viz._attributionPinned;\n setExpanded(node, viz._attributionPinned);\n });\n setExpanded(node, Boolean(viz._attributionPinned));\n\n return {panel: null, margin: {}};\n },\n};\n"],"names":["select","stylize","chartBounds","attributionStyleDarkDefault","attributionStyleDefault","INFO_ICON","CUSTOM_ICON_SLOT","toggleIcon","viz","icon","schema","attributionIcon","mountCustomAttributionIcon","node","slot","querySelector","_attributionIconCleanup","undefined","COMPACT_SHARE","setExpanded","open","text","toggle","style","display","setAttribute","String","borderRadius","padding","attributionFeature","name","configFields","layout","attr","_select","parentNode","selectAll","data","attribution","attrEnter","enter","append","exit","remove","attributionStyle","_basemapDark","merge","_margin","right","bottom","call","html","translate","rewriteNode","__d3plusHTML","innerHTML","querySelectorAll","forEach","a","color","textDecoration","toggleEl","border","background","flexShrink","panel","margin","width","maxWidth","Math","min","whiteSpace","compact","getBoundingClientRect","on","show","Boolean","_attributionPinned","matches","window","setTimeout"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAAQA,MAAM,QAAO,eAAe;AAEpC,SAAQC,OAAO,QAAO,cAAc;AAIpC,SAAQC,WAAW,QAAO,qBAAqB;AAC/C,SAAQC,2BAA2B,EAAEC,uBAAuB,QAAO,wBAAwB;AAG3F,yFAAyF,GACzF,IAAMC,YACJ;AAEF,iFAAiF,GACjF,IAAMC,mBACJ;AAEF,8EAA8E,GAC9E,SAASC,WAAWC,GAAgB;IAClC,IAAMC,OAAOD,IAAIE,MAAM,CAACC,eAAe;IACvC,IAAI,OAAOF,SAAS,UAAU,OAAOA;IACrC,IAAI,OAAOA,SAAS,YAAY,OAAOH;IACvC,OAAOD;AACT;AAEA;;;;;AAKA,GACA,SAASO,2BAA2BJ,GAAgB,EAAEK,IAAiB;QAKrEL;IAJA,IAAMC,OAAOD,IAAIE,MAAM,CAACC,eAAe;IACvC,IAAI,OAAOF,SAAS,YAAY;IAChC,IAAMK,OAAOD,KAAKE,aAAa,CAAc;IAC7C,IAAI,CAACD,MAAM;KACXN,+BAAAA,IAAIQ,uBAAuB,cAA3BR,mDAAAA,kCAAAA;IACAA,IAAIQ,uBAAuB,GAAGP,KAAKK,SAASG;AAC9C;AAEA,6EAA6E,GAC7E,IAAMC,gBAAgB;AAEtB,4CAA4C,GAC5C,SA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Oa,MAAMb,MAAM,CAAC,8BAA8BuB,KAAK,CAAC,WAAWiD,UAAU,KAAK;QAEjG,IAAI,CAACA,SAAS;YACZxE,OAAOa,MAAM6D,EAAE,CAAC,YAAY;YAC5BvD,YAAYN,MAAM;YAClB,OAAO;gBAACoD,OAAO;gBAAMC,QAAQ,CAAC;YAAC;QACjC;QAEA,wEAAwE;QACxE,IAAMS,OAAO;mBAAMxD,YAAYN,MAAM+D,QAAQpE,IAAIqE,kBAAkB,IAAIhE,KAAKiE,OAAO,CAAC;;QACpF9E,OAAOa,MACJ6D,EAAE,CAAC,sCAAsC;mBAAMvD,YAAYN,MAAM;WACjE6D,EAAE,CAAC,uCAAuC;mBAAMK,OAAOC,UAAU,CAACL,MAAM;;QAC3ErD,OAAOoD,EAAE,CAAC,iBAAiB;YACzBlE,IAAIqE,kBAAkB,GAAG,CAACrE,IAAIqE,kBAAkB;YAChD1D,YAAYN,MAAML,IAAIqE,kBAAkB;QAC1C;QACA1D,YAAYN,MAAM+D,QAAQpE,IAAIqE,kBAAkB;QAEhD,OAAO;YAACZ,OAAO;YAAMC,QAAQ,CAAC;QAAC;IACjC;AACF,EAAE"}
@@ -303,13 +303,15 @@ import { bumpLineLabels } from "./lineLabels.js";
303
303
  Render the production x/x2 axes against `xRange`, queue their scenes, and
304
304
  build the `viz._xFunc` position accessor.
305
305
  */ function renderXAxes(viz, pCtx, xRange, axisRelativeTransform, axisSceneQueue) {
306
+ var _ref;
307
+ var _pCtx_zoomAxes;
306
308
  var xDomain = pCtx.xDomain, x2Domain = pCtx.x2Domain, xConfigScale = pCtx.xConfigScale, x2ConfigScale = pCtx.x2ConfigScale;
307
309
  var defaultX2Config = pCtx.defaultX2Config, showX = pCtx.showX, x2Exists = pCtx.x2Exists, xC = pCtx.xC;
308
310
  var xTicks = pCtx.xTicks, x2Ticks = pCtx.x2Ticks, x2Height = pCtx.x2Height, topOffset = pCtx.topOffset, height = pCtx.height, width = pCtx.width, verticalMargin = pCtx.verticalMargin;
309
311
  // Plot sets these before the axis pass runs.
310
312
  var xAxis = viz._xAxis;
311
313
  var x2Axis = viz._x2Axis;
312
- xAxis.renderMode("compute").select(null).domain(xDomain).height(height - (x2Height + topOffset + verticalMargin)).maxSize(height / 2).range(xRange).ticks(xTicks).width(width).config(xC).config(viz._xConfig).scale(xConfigScale).render();
314
+ xAxis.renderMode("compute").select(null).domain(xDomain).height(height - (x2Height + topOffset + verticalMargin)).maxSize(height / 2).range(xRange).ticks(xTicks).width(width).config(xC).config(viz._xConfig).config((_ref = (_pCtx_zoomAxes = pCtx.zoomAxes) === null || _pCtx_zoomAxes === void 0 ? void 0 : _pCtx_zoomAxes.x) !== null && _ref !== void 0 ? _ref : {}).scale(xConfigScale).render();
313
315
  if (showX) {
314
316
  axisSceneQueue.push({
315
317
  key: "plot-x-axis",
@@ -318,7 +320,9 @@ import { bumpLineLabels } from "./lineLabels.js";
318
320
  });
319
321
  }
320
322
  if (x2Exists) {
321
- x2Axis.renderMode("compute").select(null).domain(x2Domain).height(height - (pCtx.xHeight + topOffset + verticalMargin)).range(xRange).ticks(x2Ticks).width(width).config(xC).config(defaultX2Config).config(viz._x2Config).scale(x2ConfigScale).render();
323
+ var _ref1;
324
+ var _pCtx_zoomAxes1;
325
+ x2Axis.renderMode("compute").select(null).domain(x2Domain).height(height - (pCtx.xHeight + topOffset + verticalMargin)).range(xRange).ticks(x2Ticks).width(width).config(xC).config(defaultX2Config).config(viz._x2Config).config((_ref1 = (_pCtx_zoomAxes1 = pCtx.zoomAxes) === null || _pCtx_zoomAxes1 === void 0 ? void 0 : _pCtx_zoomAxes1.x2) !== null && _ref1 !== void 0 ? _ref1 : {}).scale(x2ConfigScale).render();
322
326
  axisSceneQueue.push({
323
327
  key: "plot-x2-axis",
324
328
  transform: axisRelativeTransform("x2"),
@@ -341,13 +345,15 @@ import { bumpLineLabels } from "./lineLabels.js";
341
345
  Render the production y/y2 axes against `yRange`, queue their scenes, and
342
346
  build the `viz._yFunc` position accessor.
343
347
  */ function renderYAxes(viz, pCtx, xRange, yRange, xOffsetRight, y2Width, axisRelativeTransform, axisSceneQueue) {
348
+ var _ref;
349
+ var _pCtx_zoomAxes;
344
350
  var yDomain = pCtx.yDomain, y2Domain = pCtx.y2Domain, yConfigScale = pCtx.yConfigScale, y2ConfigScale = pCtx.y2ConfigScale;
345
351
  var defaultY2Config = pCtx.defaultY2Config, showY = pCtx.showY, y2Exists = pCtx.y2Exists, yC = pCtx.yC;
346
352
  var yTicks = pCtx.yTicks, x2Height = pCtx.x2Height, height = pCtx.height, width = pCtx.width;
347
353
  // Plot sets these before the axis pass runs.
348
354
  var yAxis = viz._yAxis;
349
355
  var y2Axis = viz._y2Axis;
350
- yAxis.renderMode("compute").select(null).domain(yDomain).height(height).maxSize(width / 2).range(yRange).ticks(yTicks).width(xRange[xRange.length - 1]).config(yC).config(viz._yConfig).scale(yConfigScale).render();
356
+ yAxis.renderMode("compute").select(null).domain(yDomain).height(height).maxSize(width / 2).range(yRange).ticks(yTicks).width(xRange[xRange.length - 1]).config(yC).config(viz._yConfig).config((_ref = (_pCtx_zoomAxes = pCtx.zoomAxes) === null || _pCtx_zoomAxes === void 0 ? void 0 : _pCtx_zoomAxes.y) !== null && _ref !== void 0 ? _ref : {}).scale(yConfigScale).render();
351
357
  if (showY) {
352
358
  axisSceneQueue.push({
353
359
  key: "plot-y-axis",
@@ -356,10 +362,12 @@ import { bumpLineLabels } from "./lineLabels.js";
356
362
  });
357
363
  }
358
364
  if (y2Exists) {
365
+ var _ref1;
366
+ var _pCtx_zoomAxes1;
359
367
  y2Axis.renderMode("compute").select(null).config(yC).domain(y2Exists ? y2Domain : yDomain).gridSize(0).height(height).range(yRange).width(width - max([
360
368
  0,
361
369
  xOffsetRight - y2Width
362
- ])).title(false).config(viz._y2Config).config(defaultY2Config).scale(y2ConfigScale).render();
370
+ ])).title(false).config(viz._y2Config).config(defaultY2Config).config((_ref1 = (_pCtx_zoomAxes1 = pCtx.zoomAxes) === null || _pCtx_zoomAxes1 === void 0 ? void 0 : _pCtx_zoomAxes1.y2) !== null && _ref1 !== void 0 ? _ref1 : {}).scale(y2ConfigScale).render();
363
371
  axisSceneQueue.push({
364
372
  key: "plot-y2-axis",
365
373
  transform: axisRelativeTransform("y2"),
@@ -386,7 +394,8 @@ import { bumpLineLabels } from "./lineLabels.js";
386
394
  `xRange`/`yRange` + offsets, sets `viz._xFunc` / `viz._yFunc` accessors,
387
395
  bumps the line labels, and queues axis scenes for the emit phase.
388
396
  Returns everything `plotEmit` needs to consume.
389
- */ export function renderAxes(viz, pCtx) {
397
+ */ export function renderAxes(viz, pCtx, frozen) {
398
+ var _ref, _ref1;
390
399
  var x = pCtx.x, y = pCtx.y;
391
400
  var labelWidths = pCtx.labelWidths;
392
401
  var xHeight = pCtx.xHeight, x2Height = pCtx.x2Height, topOffset = pCtx.topOffset, height = pCtx.height, horizontalMargin = pCtx.horizontalMargin, verticalMargin = pCtx.verticalMargin;
@@ -394,8 +403,11 @@ import { bumpLineLabels } from "./lineLabels.js";
394
403
  x2Height,
395
404
  height - (xHeight + topOffset + verticalMargin)
396
405
  ];
397
- var _solveFinalYAxes = solveFinalYAxes(viz, pCtx, yRange), yBounds = _solveFinalYAxes.yBounds, yWidth = _solveFinalYAxes.yWidth, y2Bounds = _solveFinalYAxes.y2Bounds, y2Width = _solveFinalYAxes.y2Width, xOffsetLeft = _solveFinalYAxes.xOffsetLeft, xOffsetRight = _solveFinalYAxes.xOffsetRight;
398
- var xRange = [
406
+ // A `frozen` layout (a zoom repaint) keeps the previous draw's axis sizes
407
+ // and plot rect, so changing tick labels can't make the plot area jump
408
+ // mid-gesture; the axes still re-render their ticks for the new domains.
409
+ var _ref2 = frozen || solveFinalYAxes(viz, pCtx, yRange), yBounds = _ref2.yBounds, yWidth = _ref2.yWidth, y2Bounds = _ref2.y2Bounds, y2Width = _ref2.y2Width, xOffsetLeft = _ref2.xOffsetLeft, xOffsetRight = _ref2.xOffsetRight;
410
+ var xRange = (_ref = frozen === null || frozen === void 0 ? void 0 : frozen.xRange) !== null && _ref !== void 0 ? _ref : [
399
411
  xOffsetLeft,
400
412
  pCtx.width - (xOffsetRight + horizontalMargin)
401
413
  ];
@@ -404,7 +416,7 @@ import { bumpLineLabels } from "./lineLabels.js";
404
416
  // axes render above shapes.
405
417
  var axisSceneQueue = [];
406
418
  x = renderXAxes(viz, pCtx, xRange, axisRelativeTransform, axisSceneQueue);
407
- yRange = [
419
+ yRange = (_ref1 = frozen === null || frozen === void 0 ? void 0 : frozen.yRange) !== null && _ref1 !== void 0 ? _ref1 : [
408
420
  viz._xAxis.outerBounds().y + x2Height,
409
421
  height - (xHeight + topOffset + verticalMargin)
410
422
  ];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/axes.ts"],"sourcesContent":["/**\n The Plot-family axes module: the production-axis render + joint range\n solve, factored out of the Plot paint phase so any viz that lays out\n against d3plus `Axis` instances can reuse it.\n\n Plot's four axes (`x`/`x2`/`y`/`y2`) are NOT four independent margin\n claims — they are a single coupled solve. The y-axis label width sets\n where the x range starts (`xOffsetLeft = max([yWidth, …])`); the\n x2-axis height shifts the y range's top and the whole chart transform;\n the x range start in turn moves where the y axis sits (`xTrans`). So\n this module owns the joint solve internally and reports one unit, rather\n than exposing four separable features.\n\n The module exposes the joint solve as two halves:\n\n - `measureAxes` — the MEASURE half: throwaway test axes measure label\n widths/heights, the coupled offsets are solved\n (`xOffsetLeft = max([yWidth, …])`, `x2Height`, `topOffset`,\n `xHeight`), and the four-side claim is written to `viz._padding.*`\n and returned. Runs BEFORE the base `Viz` draw finalizes margins.\n The line-label width measure interleaves mid-solve via an injected\n callback (it is Plot-pipeline-specific, so the axes module doesn't\n own it).\n - `renderAxes` — the EMIT half: runs AFTER margins are finalized,\n rendering the production axes\n (`viz._xAxis`/`_yAxis`/`_x2Axis`/`_y2Axis`) in compute mode against\n the final ranges, setting `viz._xFunc`/`_yFunc` (with their\n log-scale zero handling), and queueing the axis scene nodes for the\n caller to drain after the shape loop (so axes layer above shapes).\n\n Both halves degrade to a single axis (or any subset) through the\n `showX`/`showY`/`x2Exists`/`y2Exists` guards: a consumer that wants only\n an x-axis passes the other sides' flags as `false`, and the `max([…])`\n offsets collapse accordingly.\n\n @module\n*/\n\nimport {max} from \"d3-array\";\n\nimport type Axis from \"../../components/Axis/Axis.js\";\n\nimport {bumpLineLabels} from \"./lineLabels.js\";\nimport type {LabelWidth, PlotMeasureResult, PlotPaintContext} from \"./plotPaint.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/** A measured axis's outer bounding box. */\ntype AxisBounds = {width: number; height: number; x: number; y: number};\n\n/** A queued production-axis scene, drained after the shape loop. */\ntype AxisScene = {key: string; transform: {x: number; y: number}; axis: Axis};\n\n/** The y/y2 bounds + claimed widths a y-axis measure pass produces. */\ntype YAxisMeasure = {yBounds: AxisBounds; yWidth: number | undefined; y2Bounds: AxisBounds; y2Width: number | undefined};\n\n/** A position accessor: maps a datum to a pixel coordinate on its axis. */\ntype PositionAccessor = (d: unknown, which?: string) => number;\n\n/** Derives an axis's transform relative to `_chartTransform`. */\ntype RelativeTransform = (which: \"x\" | \"x2\" | \"y\" | \"y2\") => {x: number; y: number};\n\n/**\n The line-label measurement the joint solve interleaves between the first\n and second x-axis measure passes. Plot supplies this via a callback that\n runs the `measurePlotLineLabels` pipeline stage; a consumer with no line\n labels returns empty widths and an undefined `xRangeMax`.\n*/\nexport interface LineLabelMeasurement {\n labelWidths: LabelWidth[];\n largestLabel: number | undefined;\n xRangeMax: number | undefined;\n}\n\n/**\n The stable per-draw inputs the joint margin solve reads — exactly the\n values the Plot pipeline stages (`computePlotScales`,\n `preparePlotAxisLayout`) already produce. The four `*Test` axes are\n throwaway instances the caller allocates per draw; `measureAxes`\n configures and measures them, then the caller discards them.\n*/\nexport interface AxisMeasureInputs {\n xTest: Axis;\n yTest: Axis;\n x2Test: Axis;\n y2Test: Axis;\n xDomain: number[];\n x2Domain: number[];\n yDomain: number[];\n y2Domain: number[];\n xTicks: unknown[] | null;\n x2Ticks: unknown[] | null;\n yTicks: unknown[] | null;\n y2Ticks: unknown[] | null;\n xConfigScale: string;\n x2ConfigScale: string;\n yConfigScale: string;\n y2ConfigScale: string;\n defaultX2Config: Record<string, unknown>;\n defaultY2Config: Record<string, unknown>;\n yC: Record<string, unknown>;\n showX: boolean;\n showY: boolean;\n x2Exists: boolean;\n y2Exists: boolean;\n height: number;\n width: number;\n xData: unknown[];\n /** `x.padding()` when the x scale is banded, else 0 — feeds the x config. */\n xScalePadding: number;\n}\n\n/** The four-side margin claim + offsets the joint solve produces. */\nexport interface AxisMeasureResult {\n yBounds: AxisBounds;\n y2Bounds: AxisBounds;\n yWidth: number | undefined;\n y2Width: number | undefined;\n xC: Record<string, unknown>;\n xRangeMax: number | undefined;\n labelWidths: LabelWidth[];\n largestLabel: number | undefined;\n xTestRange: number[];\n x2TestRange: number[];\n x2Height: number;\n xOffsetLeft: number;\n xOffsetRight: number;\n topOffset: number;\n xHeight: number;\n}\n\n/** Measure the y/y2 test axes and report their bounds + claimed widths. */\nfunction measureYTestAxes(viz: Viz, inputs: AxisMeasureInputs): YAxisMeasure {\n const {\n yTest, y2Test, yDomain, y2Domain, yTicks, y2Ticks,\n yConfigScale, y2ConfigScale, defaultY2Config, yC,\n showY, y2Exists, height, width,\n } = inputs;\n\n if (showY) {\n yTest\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range([undefined, undefined])\n .ticks(yTicks)\n .width(width)\n .config(yC)\n .config(viz._yConfig)\n .scale(yConfigScale)\n .measure();\n }\n\n const yBounds = yTest.outerBounds() as AxisBounds;\n const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;\n\n if (y2Exists) {\n y2Test\n .domain(y2Domain)\n .height(height)\n .range([undefined, undefined])\n .ticks(y2Ticks)\n .width(width)\n .config(yC)\n .config(defaultY2Config)\n .config(viz._y2Config)\n .scale(y2ConfigScale)\n .measure();\n }\n\n const y2Bounds = y2Test.outerBounds() as AxisBounds;\n const y2Width = y2Bounds.width ? y2Bounds.width + y2Test.padding() : undefined;\n\n return {yBounds, yWidth, y2Bounds, y2Width};\n}\n\n/** Build the shared x-axis config object, including the no-y-axis variant. */\nfunction buildXConfig(viz: Viz, inputs: AxisMeasureInputs): Record<string, unknown> {\n const {xTicks, showX, showY, xData, xScalePadding} = inputs;\n\n const xC: Record<string, unknown> = {\n data: xData,\n locale: viz.schema.locale,\n rounding: viz.schema.xDomain ? \"none\" : \"outside\",\n scalePadding: xScalePadding,\n };\n if (!showY && showX) {\n xC.barConfig = {stroke: \"transparent\"};\n xC.tickSize = 0;\n xC.shapeConfig = {\n labelBounds: (d: {labelBounds: {height: number; y: number}}, i: number) => {\n const {height, y} = d.labelBounds;\n const width = viz.schema.width / 2;\n const x = i ? -width : 0;\n return {x, y, width, height};\n },\n labelConfig: {\n padding: 0,\n rotate: 0,\n textAnchor: (d: {id: unknown}) =>\n xTicks && d.id === xTicks[0] ? \"start\" : \"end\",\n },\n labelRotation: false,\n };\n }\n\n return xC;\n}\n\n/**\n Measure the x/x2 test axes and solve the coupled four-side offsets,\n interleaving the line-label measure between the two x-axis passes.\n*/\nfunction measureXTestAxes(\n viz: Viz,\n inputs: AxisMeasureInputs,\n xC: Record<string, unknown>,\n yWidth: number | undefined,\n y2Width: number | undefined,\n measureLineLabels: () => LineLabelMeasurement,\n): Omit<AxisMeasureResult, \"yBounds\" | \"y2Bounds\" | \"yWidth\" | \"y2Width\" | \"xC\"> {\n const {\n xTest, x2Test, yTest, xDomain, x2Domain, xTicks, x2Ticks,\n xConfigScale, x2ConfigScale, defaultX2Config,\n showX, showY, x2Exists, height, width,\n } = inputs;\n\n let xRangeMax: number | undefined = undefined;\n\n if (showX) {\n xTest\n .domain(xDomain)\n .height(height)\n .maxSize(height / 2)\n .range([undefined, xRangeMax])\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .scale(xConfigScale)\n .measure();\n }\n\n const {labelWidths, largestLabel, xRangeMax: measuredXRangeMax} =\n measureLineLabels();\n if (measuredXRangeMax !== undefined) xRangeMax = measuredXRangeMax;\n\n if (showX && xRangeMax) {\n xTest\n .domain(xDomain)\n .height(height)\n .maxSize(height / 2)\n .range([undefined, xRangeMax])\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .scale(xConfigScale)\n .measure();\n }\n\n if (x2Exists) {\n x2Test\n .domain(x2Domain)\n .height(height)\n .range([undefined, xRangeMax])\n .ticks(x2Ticks)\n .width(width)\n .config(xC)\n .tickSize(0)\n .config(defaultX2Config)\n .config(viz._x2Config)\n .scale(x2ConfigScale)\n .measure();\n }\n\n const xTestRange = xTest._getRange() as number[];\n const x2TestRange = x2Test._getRange() as number[];\n\n const x2Bounds = x2Test.outerBounds() as AxisBounds;\n const x2Height = x2Exists ? x2Bounds.height + x2Test.padding() : 0;\n\n const xOffsetLeft = max([yWidth, xTestRange[0], x2TestRange[0]] as number[])!;\n\n if (showX) {\n xTest.range([xOffsetLeft, undefined]).measure();\n }\n\n const topOffset = showY\n ? (\n yTest.shapeConfig().labelConfig as {fontSize: () => number}\n ).fontSize() / 2\n : 0;\n\n const xOffsetRight = max([\n y2Width,\n width - xTestRange[1],\n width - x2TestRange[1],\n ] as number[])!;\n const xBounds = xTest.outerBounds() as AxisBounds;\n const xHeight = xBounds.height + (showY ? xTest.padding() : 0);\n\n return {\n xRangeMax,\n labelWidths,\n largestLabel,\n xTestRange,\n x2TestRange,\n x2Height,\n xOffsetLeft,\n xOffsetRight,\n topOffset,\n xHeight,\n };\n}\n\n/**\n MEASURE half of the joint axis solve. Configures + measures the four\n throwaway test axes, solves the coupled offsets, writes the resulting\n four-side claim to `viz._padding.*`, and returns the offsets + the\n measured bounds + the line-label measurement for the paint phase.\n\n `measureLineLabels` is invoked once, after the first x-axis measure and\n before the re-measure, so its `xRangeMax` can re-bound the x range.\n*/\nexport function measureAxes(\n viz: Viz,\n inputs: AxisMeasureInputs,\n measureLineLabels: () => LineLabelMeasurement,\n): AxisMeasureResult {\n const {yBounds, yWidth, y2Bounds, y2Width} = measureYTestAxes(viz, inputs);\n\n const xC = buildXConfig(viz, inputs);\n\n const xResult = measureXTestAxes(viz, inputs, xC, yWidth, y2Width, measureLineLabels);\n\n viz._padding.left += xResult.xOffsetLeft;\n viz._padding.right += xResult.xOffsetRight;\n viz._padding.bottom += xResult.xHeight;\n viz._padding.top += xResult.x2Height + xResult.topOffset;\n\n return {yBounds, y2Bounds, yWidth, y2Width, xC, ...xResult};\n}\n\n/**\n Re-measure the y/y2 axes against `yRange` and resolve the final left/right\n offsets they claim.\n*/\nfunction solveFinalYAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n yRange: number[],\n): YAxisMeasure & {xOffsetLeft: number; xOffsetRight: number} {\n const {yDomain, y2Domain, yConfigScale, y2ConfigScale} = pCtx;\n const {defaultY2Config, showY, y2Exists, yC} = pCtx;\n const {yTicks, x2TestRange, xTestRange, height, width} = pCtx;\n const {yTest, y2Test} = pCtx;\n let {xOffsetRight} = pCtx;\n\n if (showY) {\n yTest\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range(yRange)\n .ticks(yTicks)\n .width(width)\n .config(yC)\n .config(viz._yConfig)\n .scale(yConfigScale)\n .measure();\n }\n\n const yBounds = yTest.outerBounds() as AxisBounds;\n const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;\n const xOffsetLeft = max([yWidth, xTestRange[0], x2TestRange[0]] as number[])!;\n\n if (y2Exists) {\n y2Test\n .config(yC)\n .domain(y2Domain)\n .gridSize(0)\n .height(height)\n .range(yRange)\n .width(width - max([0, xOffsetRight - (pCtx.y2Width as number)])!)\n .title(false)\n .config(viz._y2Config)\n .config(defaultY2Config)\n .scale(y2ConfigScale)\n .measure();\n }\n\n const y2Bounds = y2Test.outerBounds() as AxisBounds;\n const y2Width = y2Bounds.width\n ? y2Bounds.width + y2Test.padding()\n : undefined;\n xOffsetRight = max([\n 0,\n y2Width,\n width - xTestRange[1],\n width - x2TestRange[1],\n ] as number[])!;\n\n return {yBounds, yWidth, y2Bounds, y2Width, xOffsetLeft, xOffsetRight};\n}\n\n/**\n Set `viz._chartTransform` and derive the per-axis relative transform\n helper used when absorbing axis scenes into `_chartScene`.\n*/\nfunction setupAxisTransforms(\n viz: Viz,\n pCtx: PlotPaintContext,\n xOffsetLeft: number,\n yWidth: number | undefined,\n): RelativeTransform {\n const {x2Height, topOffset} = pCtx;\n\n // The shape-group offset. `_chartScene` is wrapped with this transform,\n // so nodes absorbed into it (the background Rect, axes) pass their coords\n // RELATIVE to this origin.\n const chartTransform = {\n x: viz._margin.left,\n y: viz._margin.top + x2Height + topOffset,\n };\n viz._chartTransform = chartTransform;\n\n // Each axis's absolute transform. Stored so we can derive the axis's\n // transform RELATIVE to `_chartTransform` when absorbing axis scenes into\n // `_chartScene` (the chart-cells group already applies `_chartTransform`).\n // Axes are scene-only: `renderMode(\"compute\")` renders into a detached svg\n // and `axis.toScene()` produces the visible output.\n const yW = yWidth as number;\n const xTrans = xOffsetLeft > yW ? xOffsetLeft - yW : 0;\n const axisAbsoluteTransforms = {\n x: {x: viz._margin.left, y: viz._margin.top + x2Height + topOffset},\n x2: {x: viz._margin.left, y: viz._margin.top + topOffset},\n y: {x: viz._margin.left + xTrans, y: viz._margin.top + topOffset},\n y2: {x: -viz._margin.right, y: viz._margin.top + topOffset},\n };\n return (which: \"x\" | \"x2\" | \"y\" | \"y2\") => ({\n x: axisAbsoluteTransforms[which].x - chartTransform.x,\n y: axisAbsoluteTransforms[which].y - chartTransform.y,\n });\n}\n\n/**\n Render the production x/x2 axes against `xRange`, queue their scenes, and\n build the `viz._xFunc` position accessor.\n*/\nfunction renderXAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n xRange: number[],\n axisRelativeTransform: RelativeTransform,\n axisSceneQueue: AxisScene[],\n): PositionAccessor {\n const {xDomain, x2Domain, xConfigScale, x2ConfigScale} = pCtx;\n const {defaultX2Config, showX, x2Exists, xC} = pCtx;\n const {xTicks, x2Ticks, x2Height, topOffset, height, width, verticalMargin} = pCtx;\n\n // Plot sets these before the axis pass runs.\n const xAxis = viz._xAxis!;\n const x2Axis = viz._x2Axis!;\n\n xAxis\n .renderMode(\"compute\")\n .select(null)\n .domain(xDomain)\n .height(height - (x2Height + topOffset + verticalMargin))\n .maxSize(height / 2)\n .range(xRange)\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .scale(xConfigScale)\n .render();\n if (showX) {\n axisSceneQueue.push({\n key: \"plot-x-axis\",\n transform: axisRelativeTransform(\"x\"),\n axis: xAxis,\n });\n }\n\n if (x2Exists) {\n x2Axis\n .renderMode(\"compute\")\n .select(null)\n .domain(x2Domain)\n .height(height - (pCtx.xHeight + topOffset + verticalMargin))\n .range(xRange)\n .ticks(x2Ticks)\n .width(width)\n .config(xC)\n .config(defaultX2Config)\n .config(viz._x2Config)\n .scale(x2ConfigScale)\n .render();\n axisSceneQueue.push({\n key: \"plot-x2-axis\",\n transform: axisRelativeTransform(\"x2\"),\n axis: x2Axis,\n });\n }\n\n const x = (d: unknown, x?: string): number => {\n if (x === \"x2\") {\n if (x2ConfigScale === \"log\" && d === 0)\n d =\n x2Domain[0] < 0\n ? x2Axis._d3Scale!.domain()[1]\n : x2Axis._d3Scale!.domain()[0];\n return x2Axis._getPosition.bind(x2Axis)(d);\n } else {\n if (xConfigScale === \"log\" && d === 0)\n d =\n xDomain[0] < 0\n ? xAxis._d3Scale!.domain()[1]\n : xAxis._d3Scale!.domain()[0];\n return xAxis._getPosition.bind(xAxis)(d);\n }\n };\n viz._xFunc = x;\n return x;\n}\n\n/**\n Render the production y/y2 axes against `yRange`, queue their scenes, and\n build the `viz._yFunc` position accessor.\n*/\nfunction renderYAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n xRange: number[],\n yRange: number[],\n xOffsetRight: number,\n y2Width: number | undefined,\n axisRelativeTransform: RelativeTransform,\n axisSceneQueue: AxisScene[],\n): PositionAccessor {\n const {yDomain, y2Domain, yConfigScale, y2ConfigScale} = pCtx;\n const {defaultY2Config, showY, y2Exists, yC} = pCtx;\n const {yTicks, x2Height, height, width} = pCtx;\n\n // Plot sets these before the axis pass runs.\n const yAxis = viz._yAxis!;\n const y2Axis = viz._y2Axis!;\n\n yAxis\n .renderMode(\"compute\")\n .select(null)\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range(yRange)\n .ticks(yTicks)\n .width(xRange[xRange.length - 1])\n .config(yC)\n .config(viz._yConfig)\n .scale(yConfigScale)\n .render();\n if (showY) {\n axisSceneQueue.push({\n key: \"plot-y-axis\",\n transform: axisRelativeTransform(\"y\"),\n axis: yAxis,\n });\n }\n\n if (y2Exists) {\n y2Axis\n .renderMode(\"compute\")\n .select(null)\n .config(yC)\n .domain(y2Exists ? y2Domain : yDomain)\n .gridSize(0)\n .height(height)\n .range(yRange)\n .width(width - max([0, xOffsetRight - (y2Width as number)])!)\n .title(false)\n .config(viz._y2Config)\n .config(defaultY2Config)\n .scale(y2ConfigScale)\n .render();\n axisSceneQueue.push({\n key: \"plot-y2-axis\",\n transform: axisRelativeTransform(\"y2\"),\n axis: y2Axis,\n });\n }\n\n const y = (d: unknown, y?: string): number => {\n if (y === \"y2\") {\n if (y2ConfigScale === \"log\" && d === 0)\n d =\n y2Domain[1] < 0\n ? y2Axis._d3ScaleNegative!.domain()[0]\n : y2Axis._d3Scale!.domain()[1];\n return y2Axis._getPosition.bind(y2Axis)(d) - x2Height;\n } else {\n if (yConfigScale === \"log\" && d === 0)\n d =\n yDomain[1] < 0\n ? yAxis._d3ScaleNegative!.domain()[0]\n : yAxis._d3Scale!.domain()[1];\n return yAxis._getPosition.bind(yAxis)(d) - x2Height;\n }\n };\n viz._yFunc = y;\n return y;\n}\n\n/**\n Render the production axes and solve the final ranges/offsets.\n\n Reads `pCtx`, runs each production-mode axis through\n `renderMode(\"compute\").select(null).render()`, computes the final\n `xRange`/`yRange` + offsets, sets `viz._xFunc` / `viz._yFunc` accessors,\n bumps the line labels, and queues axis scenes for the emit phase.\n Returns everything `plotEmit` needs to consume.\n*/\nexport function renderAxes(viz: Viz, pCtx: PlotPaintContext): PlotMeasureResult {\n let {x, y} = pCtx;\n const {labelWidths} = pCtx;\n const {xHeight, x2Height, topOffset, height, horizontalMargin, verticalMargin} = pCtx;\n\n let yRange = [x2Height, height - (xHeight + topOffset + verticalMargin)];\n\n const {yBounds, yWidth, y2Bounds, y2Width, xOffsetLeft, xOffsetRight} =\n solveFinalYAxes(viz, pCtx, yRange);\n\n const xRange = [xOffsetLeft, pCtx.width - (xOffsetRight + horizontalMargin)];\n\n const axisRelativeTransform = setupAxisTransforms(viz, pCtx, xOffsetLeft, yWidth);\n\n // Queued axis scenes — pushed onto `_chartScene` AFTER the shape loop so\n // axes render above shapes.\n const axisSceneQueue: AxisScene[] = [];\n\n x = renderXAxes(viz, pCtx, xRange, axisRelativeTransform, axisSceneQueue);\n\n yRange = [\n viz._xAxis!.outerBounds().y + x2Height,\n height - (xHeight + topOffset + verticalMargin),\n ];\n\n y = renderYAxes(\n viz, pCtx, xRange, yRange, xOffsetRight, y2Width,\n axisRelativeTransform, axisSceneQueue,\n );\n\n const labelPositions = bumpLineLabels(viz, labelWidths, yRange);\n\n let yOffset = viz._xAxis!.barConfig()[\"stroke-width\"] as number;\n if (yOffset) yOffset /= 2;\n\n return {\n x,\n y,\n xRange,\n yRange,\n xOffsetLeft: xOffsetLeft as number,\n xOffsetRight: xOffsetRight as number,\n yWidth,\n y2Width,\n yBounds,\n y2Bounds,\n axisSceneQueue,\n yOffset: yOffset || 0,\n labelPositions: labelPositions as Record<string, number>,\n };\n}\n"],"names":["max","bumpLineLabels","measureYTestAxes","viz","inputs","yTest","y2Test","yDomain","y2Domain","yTicks","y2Ticks","yConfigScale","y2ConfigScale","defaultY2Config","yC","showY","y2Exists","height","width","domain","maxSize","range","undefined","ticks","config","_yConfig","scale","measure","yBounds","outerBounds","yWidth","padding","_y2Config","y2Bounds","y2Width","buildXConfig","xTicks","showX","xData","xScalePadding","xC","data","locale","schema","rounding","xDomain","scalePadding","barConfig","stroke","tickSize","shapeConfig","labelBounds","d","i","y","x","labelConfig","rotate","textAnchor","id","labelRotation","measureXTestAxes","measureLineLabels","xTest","x2Test","x2Domain","x2Ticks","xConfigScale","x2ConfigScale","defaultX2Config","x2Exists","xRangeMax","_xConfig","labelWidths","largestLabel","measuredXRangeMax","_x2Config","xTestRange","_getRange","x2TestRange","x2Bounds","x2Height","xOffsetLeft","topOffset","fontSize","xOffsetRight","xBounds","xHeight","measureAxes","xResult","_padding","left","right","bottom","top","solveFinalYAxes","pCtx","yRange","gridSize","title","setupAxisTransforms","chartTransform","_margin","_chartTransform","yW","xTrans","axisAbsoluteTransforms","x2","y2","which","renderXAxes","xRange","axisRelativeTransform","axisSceneQueue","verticalMargin","xAxis","_xAxis","x2Axis","_x2Axis","renderMode","select","render","push","key","transform","axis","_d3Scale","_getPosition","bind","_xFunc","renderYAxes","yAxis","_yAxis","y2Axis","_y2Axis","length","_d3ScaleNegative","_yFunc","renderAxes","horizontalMargin","labelPositions","yOffset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,GAEA,SAAQA,GAAG,QAAO,WAAW;AAI7B,SAAQC,cAAc,QAAO,kBAAkB;AAwF/C,yEAAyE,GACzE,SAASC,iBAAiBC,GAAQ,EAAEC,MAAyB;IAC3D,IACEC,QAGED,OAHFC,OAAOC,SAGLF,OAHKE,QAAQC,UAGbH,OAHaG,SAASC,WAGtBJ,OAHsBI,UAAUC,SAGhCL,OAHgCK,QAAQC,UAGxCN,OAHwCM,SAC1CC,eAEEP,OAFFO,cAAcC,gBAEZR,OAFYQ,eAAeC,kBAE3BT,OAF2BS,iBAAiBC,KAE5CV,OAF4CU,IAC9CC,QACEX,OADFW,OAAOC,WACLZ,OADKY,UAAUC,SACfb,OADea,QAAQC,QACvBd,OADuB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AAS;QAAC7B;QAAac,KAAK9E,KAAK,GAAImE,CAAAA,eAAesD,gBAAe;KAAG;IAE5E,IAAM3B,wBAAwBZ,oBAAoBjG,KAAK6F,MAAMd,aAAapD;IAE1E,yEAAyE;IACzE,4BAA4B;IAC5B,IAAMmF,iBAA8B,EAAE;IAEtC1D,IAAIuD,YAAY3G,KAAK6F,MAAMe,QAAQC,uBAAuBC;IAE1DhB,SAAS;QACP9F,IAAIiH,MAAM,CAAEvF,WAAW,GAAGyB,CAAC,GAAG2B;QAC9BhE,SAAUsE,CAAAA,UAAUJ,YAAY+B,cAAa;KAC9C;IAED5D,IAAI4E,YACF/H,KAAK6F,MAAMe,QAAQd,QAAQZ,cAAcnD,SACzC8E,uBAAuBC;IAGzB,IAAM2B,iBAAiB3I,eAAeE,KAAKsE,aAAawB;IAExD,IAAI4C,UAAU1I,IAAIiH,MAAM,CAAErE,SAAS,EAAE,CAAC,eAAe;IACrD,IAAI8F,SAASA,WAAW;IAExB,OAAO;QACLtF,GAAAA;QACAD,GAAAA;QACAyD,QAAAA;QACAd,QAAAA;QACAf,aAAaA;QACbG,cAAcA;QACdvD,QAAAA;QACAI,SAAAA;QACAN,SAAAA;QACAK,UAAAA;QACAgF,gBAAAA;QACA4B,SAASA,WAAW;QACpBD,gBAAgBA;IAClB;AACJ"}
1
+ {"version":3,"sources":["../../../../src/charts/features/axes.ts"],"sourcesContent":["/**\n The Plot-family axes module: the production-axis render + joint range\n solve, factored out of the Plot paint phase so any viz that lays out\n against d3plus `Axis` instances can reuse it.\n\n Plot's four axes (`x`/`x2`/`y`/`y2`) are NOT four independent margin\n claims — they are a single coupled solve. The y-axis label width sets\n where the x range starts (`xOffsetLeft = max([yWidth, …])`); the\n x2-axis height shifts the y range's top and the whole chart transform;\n the x range start in turn moves where the y axis sits (`xTrans`). So\n this module owns the joint solve internally and reports one unit, rather\n than exposing four separable features.\n\n The module exposes the joint solve as two halves:\n\n - `measureAxes` — the MEASURE half: throwaway test axes measure label\n widths/heights, the coupled offsets are solved\n (`xOffsetLeft = max([yWidth, …])`, `x2Height`, `topOffset`,\n `xHeight`), and the four-side claim is written to `viz._padding.*`\n and returned. Runs BEFORE the base `Viz` draw finalizes margins.\n The line-label width measure interleaves mid-solve via an injected\n callback (it is Plot-pipeline-specific, so the axes module doesn't\n own it).\n - `renderAxes` — the EMIT half: runs AFTER margins are finalized,\n rendering the production axes\n (`viz._xAxis`/`_yAxis`/`_x2Axis`/`_y2Axis`) in compute mode against\n the final ranges, setting `viz._xFunc`/`_yFunc` (with their\n log-scale zero handling), and queueing the axis scene nodes for the\n caller to drain after the shape loop (so axes layer above shapes).\n\n Both halves degrade to a single axis (or any subset) through the\n `showX`/`showY`/`x2Exists`/`y2Exists` guards: a consumer that wants only\n an x-axis passes the other sides' flags as `false`, and the `max([…])`\n offsets collapse accordingly.\n\n @module\n*/\n\nimport {max} from \"d3-array\";\n\nimport type Axis from \"../../components/Axis/Axis.js\";\n\nimport {bumpLineLabels} from \"./lineLabels.js\";\nimport type {LabelWidth, PlotMeasureResult, PlotPaintContext} from \"./plotPaint.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/** A measured axis's outer bounding box. */\ntype AxisBounds = {width: number; height: number; x: number; y: number};\n\n/** A queued production-axis scene, drained after the shape loop. */\ntype AxisScene = {key: string; transform: {x: number; y: number}; axis: Axis};\n\n/** The y/y2 bounds + claimed widths a y-axis measure pass produces. */\ntype YAxisMeasure = {yBounds: AxisBounds; yWidth: number | undefined; y2Bounds: AxisBounds; y2Width: number | undefined};\n\n/** A position accessor: maps a datum to a pixel coordinate on its axis. */\ntype PositionAccessor = (d: unknown, which?: string) => number;\n\n/** Derives an axis's transform relative to `_chartTransform`. */\ntype RelativeTransform = (which: \"x\" | \"x2\" | \"y\" | \"y2\") => {x: number; y: number};\n\n/**\n The line-label measurement the joint solve interleaves between the first\n and second x-axis measure passes. Plot supplies this via a callback that\n runs the `measurePlotLineLabels` pipeline stage; a consumer with no line\n labels returns empty widths and an undefined `xRangeMax`.\n*/\nexport interface LineLabelMeasurement {\n labelWidths: LabelWidth[];\n largestLabel: number | undefined;\n xRangeMax: number | undefined;\n}\n\n/**\n The stable per-draw inputs the joint margin solve reads — exactly the\n values the Plot pipeline stages (`computePlotScales`,\n `preparePlotAxisLayout`) already produce. The four `*Test` axes are\n throwaway instances the caller allocates per draw; `measureAxes`\n configures and measures them, then the caller discards them.\n*/\nexport interface AxisMeasureInputs {\n xTest: Axis;\n yTest: Axis;\n x2Test: Axis;\n y2Test: Axis;\n xDomain: number[];\n x2Domain: number[];\n yDomain: number[];\n y2Domain: number[];\n xTicks: unknown[] | null;\n x2Ticks: unknown[] | null;\n yTicks: unknown[] | null;\n y2Ticks: unknown[] | null;\n xConfigScale: string;\n x2ConfigScale: string;\n yConfigScale: string;\n y2ConfigScale: string;\n defaultX2Config: Record<string, unknown>;\n defaultY2Config: Record<string, unknown>;\n yC: Record<string, unknown>;\n showX: boolean;\n showY: boolean;\n x2Exists: boolean;\n y2Exists: boolean;\n height: number;\n width: number;\n xData: unknown[];\n /** `x.padding()` when the x scale is banded, else 0 — feeds the x config. */\n xScalePadding: number;\n}\n\n/** The four-side margin claim + offsets the joint solve produces. */\nexport interface AxisMeasureResult {\n yBounds: AxisBounds;\n y2Bounds: AxisBounds;\n yWidth: number | undefined;\n y2Width: number | undefined;\n xC: Record<string, unknown>;\n xRangeMax: number | undefined;\n labelWidths: LabelWidth[];\n largestLabel: number | undefined;\n xTestRange: number[];\n x2TestRange: number[];\n x2Height: number;\n xOffsetLeft: number;\n xOffsetRight: number;\n topOffset: number;\n xHeight: number;\n}\n\n/** Measure the y/y2 test axes and report their bounds + claimed widths. */\nfunction measureYTestAxes(viz: Viz, inputs: AxisMeasureInputs): YAxisMeasure {\n const {\n yTest, y2Test, yDomain, y2Domain, yTicks, y2Ticks,\n yConfigScale, y2ConfigScale, defaultY2Config, yC,\n showY, y2Exists, height, width,\n } = inputs;\n\n if (showY) {\n yTest\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range([undefined, undefined])\n .ticks(yTicks)\n .width(width)\n .config(yC)\n .config(viz._yConfig)\n .scale(yConfigScale)\n .measure();\n }\n\n const yBounds = yTest.outerBounds() as AxisBounds;\n const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;\n\n if (y2Exists) {\n y2Test\n .domain(y2Domain)\n .height(height)\n .range([undefined, undefined])\n .ticks(y2Ticks)\n .width(width)\n .config(yC)\n .config(defaultY2Config)\n .config(viz._y2Config)\n .scale(y2ConfigScale)\n .measure();\n }\n\n const y2Bounds = y2Test.outerBounds() as AxisBounds;\n const y2Width = y2Bounds.width ? y2Bounds.width + y2Test.padding() : undefined;\n\n return {yBounds, yWidth, y2Bounds, y2Width};\n}\n\n/** Build the shared x-axis config object, including the no-y-axis variant. */\nfunction buildXConfig(viz: Viz, inputs: AxisMeasureInputs): Record<string, unknown> {\n const {xTicks, showX, showY, xData, xScalePadding} = inputs;\n\n const xC: Record<string, unknown> = {\n data: xData,\n locale: viz.schema.locale,\n rounding: viz.schema.xDomain ? \"none\" : \"outside\",\n scalePadding: xScalePadding,\n };\n if (!showY && showX) {\n xC.barConfig = {stroke: \"transparent\"};\n xC.tickSize = 0;\n xC.shapeConfig = {\n labelBounds: (d: {labelBounds: {height: number; y: number}}, i: number) => {\n const {height, y} = d.labelBounds;\n const width = viz.schema.width / 2;\n const x = i ? -width : 0;\n return {x, y, width, height};\n },\n labelConfig: {\n padding: 0,\n rotate: 0,\n textAnchor: (d: {id: unknown}) =>\n xTicks && d.id === xTicks[0] ? \"start\" : \"end\",\n },\n labelRotation: false,\n };\n }\n\n return xC;\n}\n\n/**\n Measure the x/x2 test axes and solve the coupled four-side offsets,\n interleaving the line-label measure between the two x-axis passes.\n*/\nfunction measureXTestAxes(\n viz: Viz,\n inputs: AxisMeasureInputs,\n xC: Record<string, unknown>,\n yWidth: number | undefined,\n y2Width: number | undefined,\n measureLineLabels: () => LineLabelMeasurement,\n): Omit<AxisMeasureResult, \"yBounds\" | \"y2Bounds\" | \"yWidth\" | \"y2Width\" | \"xC\"> {\n const {\n xTest, x2Test, yTest, xDomain, x2Domain, xTicks, x2Ticks,\n xConfigScale, x2ConfigScale, defaultX2Config,\n showX, showY, x2Exists, height, width,\n } = inputs;\n\n let xRangeMax: number | undefined = undefined;\n\n if (showX) {\n xTest\n .domain(xDomain)\n .height(height)\n .maxSize(height / 2)\n .range([undefined, xRangeMax])\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .scale(xConfigScale)\n .measure();\n }\n\n const {labelWidths, largestLabel, xRangeMax: measuredXRangeMax} =\n measureLineLabels();\n if (measuredXRangeMax !== undefined) xRangeMax = measuredXRangeMax;\n\n if (showX && xRangeMax) {\n xTest\n .domain(xDomain)\n .height(height)\n .maxSize(height / 2)\n .range([undefined, xRangeMax])\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .scale(xConfigScale)\n .measure();\n }\n\n if (x2Exists) {\n x2Test\n .domain(x2Domain)\n .height(height)\n .range([undefined, xRangeMax])\n .ticks(x2Ticks)\n .width(width)\n .config(xC)\n .tickSize(0)\n .config(defaultX2Config)\n .config(viz._x2Config)\n .scale(x2ConfigScale)\n .measure();\n }\n\n const xTestRange = xTest._getRange() as number[];\n const x2TestRange = x2Test._getRange() as number[];\n\n const x2Bounds = x2Test.outerBounds() as AxisBounds;\n const x2Height = x2Exists ? x2Bounds.height + x2Test.padding() : 0;\n\n const xOffsetLeft = max([yWidth, xTestRange[0], x2TestRange[0]] as number[])!;\n\n if (showX) {\n xTest.range([xOffsetLeft, undefined]).measure();\n }\n\n const topOffset = showY\n ? (\n yTest.shapeConfig().labelConfig as {fontSize: () => number}\n ).fontSize() / 2\n : 0;\n\n const xOffsetRight = max([\n y2Width,\n width - xTestRange[1],\n width - x2TestRange[1],\n ] as number[])!;\n const xBounds = xTest.outerBounds() as AxisBounds;\n const xHeight = xBounds.height + (showY ? xTest.padding() : 0);\n\n return {\n xRangeMax,\n labelWidths,\n largestLabel,\n xTestRange,\n x2TestRange,\n x2Height,\n xOffsetLeft,\n xOffsetRight,\n topOffset,\n xHeight,\n };\n}\n\n/**\n MEASURE half of the joint axis solve. Configures + measures the four\n throwaway test axes, solves the coupled offsets, writes the resulting\n four-side claim to `viz._padding.*`, and returns the offsets + the\n measured bounds + the line-label measurement for the paint phase.\n\n `measureLineLabels` is invoked once, after the first x-axis measure and\n before the re-measure, so its `xRangeMax` can re-bound the x range.\n*/\nexport function measureAxes(\n viz: Viz,\n inputs: AxisMeasureInputs,\n measureLineLabels: () => LineLabelMeasurement,\n): AxisMeasureResult {\n const {yBounds, yWidth, y2Bounds, y2Width} = measureYTestAxes(viz, inputs);\n\n const xC = buildXConfig(viz, inputs);\n\n const xResult = measureXTestAxes(viz, inputs, xC, yWidth, y2Width, measureLineLabels);\n\n viz._padding.left += xResult.xOffsetLeft;\n viz._padding.right += xResult.xOffsetRight;\n viz._padding.bottom += xResult.xHeight;\n viz._padding.top += xResult.x2Height + xResult.topOffset;\n\n return {yBounds, y2Bounds, yWidth, y2Width, xC, ...xResult};\n}\n\n/**\n Re-measure the y/y2 axes against `yRange` and resolve the final left/right\n offsets they claim.\n*/\nfunction solveFinalYAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n yRange: number[],\n): YAxisMeasure & {xOffsetLeft: number; xOffsetRight: number} {\n const {yDomain, y2Domain, yConfigScale, y2ConfigScale} = pCtx;\n const {defaultY2Config, showY, y2Exists, yC} = pCtx;\n const {yTicks, x2TestRange, xTestRange, height, width} = pCtx;\n const {yTest, y2Test} = pCtx;\n let {xOffsetRight} = pCtx;\n\n if (showY) {\n yTest\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range(yRange)\n .ticks(yTicks)\n .width(width)\n .config(yC)\n .config(viz._yConfig)\n .scale(yConfigScale)\n .measure();\n }\n\n const yBounds = yTest.outerBounds() as AxisBounds;\n const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;\n const xOffsetLeft = max([yWidth, xTestRange[0], x2TestRange[0]] as number[])!;\n\n if (y2Exists) {\n y2Test\n .config(yC)\n .domain(y2Domain)\n .gridSize(0)\n .height(height)\n .range(yRange)\n .width(width - max([0, xOffsetRight - (pCtx.y2Width as number)])!)\n .title(false)\n .config(viz._y2Config)\n .config(defaultY2Config)\n .scale(y2ConfigScale)\n .measure();\n }\n\n const y2Bounds = y2Test.outerBounds() as AxisBounds;\n const y2Width = y2Bounds.width\n ? y2Bounds.width + y2Test.padding()\n : undefined;\n xOffsetRight = max([\n 0,\n y2Width,\n width - xTestRange[1],\n width - x2TestRange[1],\n ] as number[])!;\n\n return {yBounds, yWidth, y2Bounds, y2Width, xOffsetLeft, xOffsetRight};\n}\n\n/**\n Set `viz._chartTransform` and derive the per-axis relative transform\n helper used when absorbing axis scenes into `_chartScene`.\n*/\nfunction setupAxisTransforms(\n viz: Viz,\n pCtx: PlotPaintContext,\n xOffsetLeft: number,\n yWidth: number | undefined,\n): RelativeTransform {\n const {x2Height, topOffset} = pCtx;\n\n // The shape-group offset. `_chartScene` is wrapped with this transform,\n // so nodes absorbed into it (the background Rect, axes) pass their coords\n // RELATIVE to this origin.\n const chartTransform = {\n x: viz._margin.left,\n y: viz._margin.top + x2Height + topOffset,\n };\n viz._chartTransform = chartTransform;\n\n // Each axis's absolute transform. Stored so we can derive the axis's\n // transform RELATIVE to `_chartTransform` when absorbing axis scenes into\n // `_chartScene` (the chart-cells group already applies `_chartTransform`).\n // Axes are scene-only: `renderMode(\"compute\")` renders into a detached svg\n // and `axis.toScene()` produces the visible output.\n const yW = yWidth as number;\n const xTrans = xOffsetLeft > yW ? xOffsetLeft - yW : 0;\n const axisAbsoluteTransforms = {\n x: {x: viz._margin.left, y: viz._margin.top + x2Height + topOffset},\n x2: {x: viz._margin.left, y: viz._margin.top + topOffset},\n y: {x: viz._margin.left + xTrans, y: viz._margin.top + topOffset},\n y2: {x: -viz._margin.right, y: viz._margin.top + topOffset},\n };\n return (which: \"x\" | \"x2\" | \"y\" | \"y2\") => ({\n x: axisAbsoluteTransforms[which].x - chartTransform.x,\n y: axisAbsoluteTransforms[which].y - chartTransform.y,\n });\n}\n\n/**\n Render the production x/x2 axes against `xRange`, queue their scenes, and\n build the `viz._xFunc` position accessor.\n*/\nfunction renderXAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n xRange: number[],\n axisRelativeTransform: RelativeTransform,\n axisSceneQueue: AxisScene[],\n): PositionAccessor {\n const {xDomain, x2Domain, xConfigScale, x2ConfigScale} = pCtx;\n const {defaultX2Config, showX, x2Exists, xC} = pCtx;\n const {xTicks, x2Ticks, x2Height, topOffset, height, width, verticalMargin} = pCtx;\n\n // Plot sets these before the axis pass runs.\n const xAxis = viz._xAxis!;\n const x2Axis = viz._x2Axis!;\n\n xAxis\n .renderMode(\"compute\")\n .select(null)\n .domain(xDomain)\n .height(height - (x2Height + topOffset + verticalMargin))\n .maxSize(height / 2)\n .range(xRange)\n .ticks(xTicks)\n .width(width)\n .config(xC)\n .config(viz._xConfig)\n .config(pCtx.zoomAxes?.x ?? {})\n .scale(xConfigScale)\n .render();\n if (showX) {\n axisSceneQueue.push({\n key: \"plot-x-axis\",\n transform: axisRelativeTransform(\"x\"),\n axis: xAxis,\n });\n }\n\n if (x2Exists) {\n x2Axis\n .renderMode(\"compute\")\n .select(null)\n .domain(x2Domain)\n .height(height - (pCtx.xHeight + topOffset + verticalMargin))\n .range(xRange)\n .ticks(x2Ticks)\n .width(width)\n .config(xC)\n .config(defaultX2Config)\n .config(viz._x2Config)\n .config(pCtx.zoomAxes?.x2 ?? {})\n .scale(x2ConfigScale)\n .render();\n axisSceneQueue.push({\n key: \"plot-x2-axis\",\n transform: axisRelativeTransform(\"x2\"),\n axis: x2Axis,\n });\n }\n\n const x = (d: unknown, x?: string): number => {\n if (x === \"x2\") {\n if (x2ConfigScale === \"log\" && d === 0)\n d =\n x2Domain[0] < 0\n ? x2Axis._d3Scale!.domain()[1]\n : x2Axis._d3Scale!.domain()[0];\n return x2Axis._getPosition.bind(x2Axis)(d);\n } else {\n if (xConfigScale === \"log\" && d === 0)\n d =\n xDomain[0] < 0\n ? xAxis._d3Scale!.domain()[1]\n : xAxis._d3Scale!.domain()[0];\n return xAxis._getPosition.bind(xAxis)(d);\n }\n };\n viz._xFunc = x;\n return x;\n}\n\n/**\n Render the production y/y2 axes against `yRange`, queue their scenes, and\n build the `viz._yFunc` position accessor.\n*/\nfunction renderYAxes(\n viz: Viz,\n pCtx: PlotPaintContext,\n xRange: number[],\n yRange: number[],\n xOffsetRight: number,\n y2Width: number | undefined,\n axisRelativeTransform: RelativeTransform,\n axisSceneQueue: AxisScene[],\n): PositionAccessor {\n const {yDomain, y2Domain, yConfigScale, y2ConfigScale} = pCtx;\n const {defaultY2Config, showY, y2Exists, yC} = pCtx;\n const {yTicks, x2Height, height, width} = pCtx;\n\n // Plot sets these before the axis pass runs.\n const yAxis = viz._yAxis!;\n const y2Axis = viz._y2Axis!;\n\n yAxis\n .renderMode(\"compute\")\n .select(null)\n .domain(yDomain)\n .height(height)\n .maxSize(width / 2)\n .range(yRange)\n .ticks(yTicks)\n .width(xRange[xRange.length - 1])\n .config(yC)\n .config(viz._yConfig)\n .config(pCtx.zoomAxes?.y ?? {})\n .scale(yConfigScale)\n .render();\n if (showY) {\n axisSceneQueue.push({\n key: \"plot-y-axis\",\n transform: axisRelativeTransform(\"y\"),\n axis: yAxis,\n });\n }\n\n if (y2Exists) {\n y2Axis\n .renderMode(\"compute\")\n .select(null)\n .config(yC)\n .domain(y2Exists ? y2Domain : yDomain)\n .gridSize(0)\n .height(height)\n .range(yRange)\n .width(width - max([0, xOffsetRight - (y2Width as number)])!)\n .title(false)\n .config(viz._y2Config)\n .config(defaultY2Config)\n .config(pCtx.zoomAxes?.y2 ?? {})\n .scale(y2ConfigScale)\n .render();\n axisSceneQueue.push({\n key: \"plot-y2-axis\",\n transform: axisRelativeTransform(\"y2\"),\n axis: y2Axis,\n });\n }\n\n const y = (d: unknown, y?: string): number => {\n if (y === \"y2\") {\n if (y2ConfigScale === \"log\" && d === 0)\n d =\n y2Domain[1] < 0\n ? y2Axis._d3ScaleNegative!.domain()[0]\n : y2Axis._d3Scale!.domain()[1];\n return y2Axis._getPosition.bind(y2Axis)(d) - x2Height;\n } else {\n if (yConfigScale === \"log\" && d === 0)\n d =\n yDomain[1] < 0\n ? yAxis._d3ScaleNegative!.domain()[0]\n : yAxis._d3Scale!.domain()[1];\n return yAxis._getPosition.bind(yAxis)(d) - x2Height;\n }\n };\n viz._yFunc = y;\n return y;\n}\n\n/**\n Render the production axes and solve the final ranges/offsets.\n\n Reads `pCtx`, runs each production-mode axis through\n `renderMode(\"compute\").select(null).render()`, computes the final\n `xRange`/`yRange` + offsets, sets `viz._xFunc` / `viz._yFunc` accessors,\n bumps the line labels, and queues axis scenes for the emit phase.\n Returns everything `plotEmit` needs to consume.\n*/\nexport function renderAxes(viz: Viz, pCtx: PlotPaintContext, frozen?: PlotMeasureResult): PlotMeasureResult {\n let {x, y} = pCtx;\n const {labelWidths} = pCtx;\n const {xHeight, x2Height, topOffset, height, horizontalMargin, verticalMargin} = pCtx;\n\n let yRange = [x2Height, height - (xHeight + topOffset + verticalMargin)];\n\n // A `frozen` layout (a zoom repaint) keeps the previous draw's axis sizes\n // and plot rect, so changing tick labels can't make the plot area jump\n // mid-gesture; the axes still re-render their ticks for the new domains.\n const {yBounds, yWidth, y2Bounds, y2Width, xOffsetLeft, xOffsetRight} =\n frozen || solveFinalYAxes(viz, pCtx, yRange);\n\n const xRange = frozen?.xRange ?? [xOffsetLeft, pCtx.width - (xOffsetRight + horizontalMargin)];\n\n const axisRelativeTransform = setupAxisTransforms(viz, pCtx, xOffsetLeft, yWidth);\n\n // Queued axis scenes — pushed onto `_chartScene` AFTER the shape loop so\n // axes render above shapes.\n const axisSceneQueue: AxisScene[] = [];\n\n x = renderXAxes(viz, pCtx, xRange, axisRelativeTransform, axisSceneQueue);\n\n yRange = frozen?.yRange ?? [\n viz._xAxis!.outerBounds().y + x2Height,\n height - (xHeight + topOffset + verticalMargin),\n ];\n\n y = renderYAxes(\n viz, pCtx, xRange, yRange, xOffsetRight, y2Width,\n axisRelativeTransform, axisSceneQueue,\n );\n\n const labelPositions = bumpLineLabels(viz, labelWidths, yRange);\n\n let yOffset = viz._xAxis!.barConfig()[\"stroke-width\"] as number;\n if (yOffset) yOffset /= 2;\n\n return {\n x,\n y,\n xRange,\n yRange,\n xOffsetLeft: xOffsetLeft as number,\n xOffsetRight: xOffsetRight as number,\n yWidth,\n y2Width,\n yBounds,\n y2Bounds,\n axisSceneQueue,\n yOffset: yOffset || 0,\n labelPositions: labelPositions as Record<string, number>,\n };\n}\n"],"names":["max","bumpLineLabels","measureYTestAxes","viz","inputs","yTest","y2Test","yDomain","y2Domain","yTicks","y2Ticks","yConfigScale","y2ConfigScale","defaultY2Config","yC","showY","y2Exists","height","width","domain","maxSize","range","undefined","ticks","config","_yConfig","scale","measure","yBounds","outerBounds","yWidth","padding","_y2Config","y2Bounds","y2Width","buildXConfig","xTicks","showX","xData","xScalePadding","xC","data","locale","schema","rounding","xDomain","scalePadding","barConfig","stroke","tickSize","shapeConfig","labelBounds","d","i","y","x","labelConfig","rotate","textAnchor","id","labelRotation","measureXTestAxes","measureLineLabels","xTest","x2Test","x2Domain","x2Ticks","xConfigScale","x2ConfigScale","defaultX2Config","x2Exists","xRangeMax","_xConfig","labelWidths","largestLabel","measuredXRangeMax","_x2Config","xTestRange","_getRange","x2TestRange","x2Bounds","x2Height","xOffsetLeft","topOffset","fontSize","xOffsetRight","xBounds","xHeight","measureAxes","xResult","_padding","left","right","bottom","top","solveFinalYAxes","pCtx","yRange","gridSize","title","setupAxisTransforms","chartTransform","_margin","_chartTransform","yW","xTrans","axisAbsoluteTransforms","x2","y2","which","renderXAxes","xRange","axisRelativeTransform","axisSceneQueue","verticalMargin","xAxis","_xAxis","x2Axis","_x2Axis","renderMode","select","zoomAxes","render","push","key","transform","axis","_d3Scale","_getPosition","bind","_xFunc","renderYAxes","yAxis","_yAxis","y2Axis","_y2Axis","length","_d3ScaleNegative","_yFunc","renderAxes","frozen","horizontalMargin","labelPositions","yOffset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,GAEA,SAAQA,GAAG,QAAO,WAAW;AAI7B,SAAQC,cAAc,QAAO,kBAAkB;AAwF/C,yEAAyE,GACzE,SAASC,iBAAiBC,GAAQ,EAAEC,MAAyB;IAC3D,IACEC,QAGED,OAHFC,OAAOC,SAGLF,OAHKE,QAAQC,UAGbH,OAHaG,SAASC,WAGtBJ,OAHsBI,UAAUC,SAGhCL,OAHgCK,QAAQC,UAGxCN,OAHwCM,SAC1CC,eAEEP,OAFFO,cAAcC,gBAEZR,OAFYQ,eAAeC,kBAE3BT,OAF2BS,iBAAiBC,KAE5CV,OAF4CU,IAC9CC,QACEX,OADFW,OAAOC,WACLZ,OADKY,UAAUC,SACfb,OADea,QAAQC,QACvBd,OADuBc;IAG3B,IAAIH,OAAO;QACTV,MACGc,MAAM,CAACZ,SACPU,MAAM,CAACA,QACPG,OAAO,CAACF,QAAQ,GAChBG,KAAK,CAAC;YAACC;YAAWA;SAAU,EAC5BC,KAAK,CAACd,QACNS,KAAK,CAACA,OACNM,MAAM,CAACV,IACPU,MAAM,CAACrB,IAAIsB,QAAQ,EACnBC,KAAK,CAACf,cACNgB,OAAO;IACZ;IAEA,IAAMC,UAAUvB,MAAMwB,WAAW;IACjC,IAAMC,SAASF,QAAQV,KAAK,GAAGU,QAAQV,KAAK,GAAGb,MAAM0B,OAAO,KAAKT;IAEjE,IAAIN,UAAU;QACZV,OACGa,MAAM,CAACX,UACPS,MAAM,CAACA,QACPI,KAAK,CAAC;YAACC;YAAWA;SAAU,EAC5BC,KAAK,CAACb,SACNQ,KAAK,CAACA,OACNM,MAAM,CAACV,IACPU,MAAM,CAACX,iBACPW,MAAM,CAAC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ewD,gBAAe;KAAG;IAE9F,IAAM7B,wBAAwBZ,oBAAoBjG,KAAK6F,MAAMd,aAAapD;IAE1E,yEAAyE;IACzE,4BAA4B;IAC5B,IAAMmF,iBAA8B,EAAE;IAEtC1D,IAAIuD,YAAY3G,KAAK6F,MAAMe,QAAQC,uBAAuBC;IAE1DhB,kBAAS2C,mBAAAA,6BAAAA,OAAQ3C,MAAM,yCAAI;QACzB9F,IAAIiH,MAAM,CAAEvF,WAAW,GAAGyB,CAAC,GAAG2B;QAC9BhE,SAAUsE,CAAAA,UAAUJ,YAAY+B,cAAa;KAC9C;IAED5D,IAAI6E,YACFhI,KAAK6F,MAAMe,QAAQd,QAAQZ,cAAcnD,SACzC8E,uBAAuBC;IAGzB,IAAM6B,iBAAiB7I,eAAeE,KAAKsE,aAAawB;IAExD,IAAI8C,UAAU5I,IAAIiH,MAAM,CAAErE,SAAS,EAAE,CAAC,eAAe;IACrD,IAAIgG,SAASA,WAAW;IAExB,OAAO;QACLxF,GAAAA;QACAD,GAAAA;QACAyD,QAAAA;QACAd,QAAAA;QACAf,aAAaA;QACbG,cAAcA;QACdvD,QAAAA;QACAI,SAAAA;QACAN,SAAAA;QACAK,UAAAA;QACAgF,gBAAAA;QACA8B,SAASA,WAAW;QACpBD,gBAAgBA;IAClB;AACJ"}
@@ -50,8 +50,8 @@
50
50
  y: this._margin.top + height / 2,
51
51
  };
52
52
 
53
- Used by Pie, Donut, RadialMatrix, Radar — every chart whose data
54
- lays out around a center point (polar / circular geometry).
53
+ Used by Pie, Donut, RadialMatrix, Radar, Chord — every chart whose
54
+ data lays out around a center point (polar / circular geometry).
55
55
 
56
56
  Width and height are the margin-adjusted chart-area dimensions —
57
57
  callers usually have them on hand from `chartBounds(viz)` or from
@@ -62,5 +62,19 @@
62
62
  y: viz._margin.top + height / 2
63
63
  };
64
64
  }
65
+ /**
66
+ The chart area (the svg minus its margins) as a scene-space rect clip —
67
+ where zoomable content is clipped so pan/zoom can't spill it over the
68
+ legend, title, or timeline.
69
+ */ export function chartAreaRect(viz) {
70
+ var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
71
+ return {
72
+ type: "rect",
73
+ x: viz._margin.left,
74
+ y: viz._margin.top,
75
+ width: width,
76
+ height: height
77
+ };
78
+ }
65
79
 
66
80
  //# sourceMappingURL=chartGeometry.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/chartGeometry.ts"],"sourcesContent":["/**\n Shared geometry helpers for chart `_draw` methods and layout stages.\n\n Three patterns repeat across every chart subclass + layout stage:\n\n 1. Compute the margin-adjusted chart-area width/height.\n 2. Compute the chart's `_chartTransform` (where the chart-cells\n group sits relative to the svg origin).\n 3. Pull the nested data slice for the current draw depth.\n\n Centralizing these into one module:\n - removes 14+ lines of duplication across the codebase\n - gives one place to fix coord-system bugs\n - makes the chart classes' `_draw` bodies easier to scan\n - removes the temptation to inline a slightly-different variant\n\n @module\n*/\n\nimport type {Transform} from \"@d3plus/render\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/**\n Margin-adjusted chart-area dimensions. Replaces the pattern:\n\n const height = viz.schema.height - viz._margin.top - viz._margin.bottom;\n const width = viz.schema.width - viz._margin.left - viz._margin.right;\n*/\nexport function chartBounds(viz: Viz): {width: number; height: number} {\n return {\n width: viz.schema.width - viz._margin.left - viz._margin.right,\n height: viz.schema.height - viz._margin.top - viz._margin.bottom,\n };\n}\n\n/**\n Build a `_chartTransform` that places the chart-cells group at the\n margin origin. Replaces the pattern:\n\n this._chartTransform = {x: this._margin.left, y: this._margin.top};\n\n Used by Tree, Network, Rings, Sankey, Treemap, etc. — every\n rectangular chart whose data lays out from the top-left of the\n chart area.\n*/\nexport function marginOriginTransform(viz: Viz): Transform {\n return {x: viz._margin.left, y: viz._margin.top};\n}\n\n/**\n Build a `_chartTransform` that centers the chart-cells group within\n the chart area. Replaces the pattern:\n\n this._chartTransform = {\n x: this._margin.left + width / 2,\n y: this._margin.top + height / 2,\n };\n\n Used by Pie, Donut, RadialMatrix, Radar — every chart whose data\n lays out around a center point (polar / circular geometry).\n\n Width and height are the margin-adjusted chart-area dimensions —\n callers usually have them on hand from `chartBounds(viz)` or from\n fields a stage stashed (e.g. `_pieWidth` / `_radialMatrixWidth`).\n*/\nexport function centerChartTransform(\n viz: Viz,\n width: number,\n height: number,\n): Transform {\n return {\n x: viz._margin.left + width / 2,\n y: viz._margin.top + height / 2,\n };\n}\n"],"names":["chartBounds","viz","width","schema","_margin","left","right","height","top","bottom","marginOriginTransform","x","y","centerChartTransform"],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBA,GAKA;;;;;AAKA,GACA,OAAO,SAASA,YAAYC,GAAQ;IAClC,OAAO;QACLC,OAAOD,IAAIE,MAAM,CAACD,KAAK,GAAGD,IAAIG,OAAO,CAACC,IAAI,GAAGJ,IAAIG,OAAO,CAACE,KAAK;QAC9DC,QAAQN,IAAIE,MAAM,CAACI,MAAM,GAAGN,IAAIG,OAAO,CAACI,GAAG,GAAGP,IAAIG,OAAO,CAACK,MAAM;IAClE;AACF;AAEA;;;;;;;;;AASA,GACA,OAAO,SAASC,sBAAsBT,GAAQ;IAC5C,OAAO;QAACU,GAAGV,IAAIG,OAAO,CAACC,IAAI;QAAEO,GAAGX,IAAIG,OAAO,CAACI,GAAG;IAAA;AACjD;AAEA;;;;;;;;;;;;;;;AAeA,GACA,OAAO,SAASK,qBACdZ,GAAQ,EACRC,KAAa,EACbK,MAAc;IAEd,OAAO;QACLI,GAAGV,IAAIG,OAAO,CAACC,IAAI,GAAGH,QAAQ;QAC9BU,GAAGX,IAAIG,OAAO,CAACI,GAAG,GAAGD,SAAS;IAChC;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/features/chartGeometry.ts"],"sourcesContent":["/**\n Shared geometry helpers for chart `_draw` methods and layout stages.\n\n Three patterns repeat across every chart subclass + layout stage:\n\n 1. Compute the margin-adjusted chart-area width/height.\n 2. Compute the chart's `_chartTransform` (where the chart-cells\n group sits relative to the svg origin).\n 3. Pull the nested data slice for the current draw depth.\n\n Centralizing these into one module:\n - removes 14+ lines of duplication across the codebase\n - gives one place to fix coord-system bugs\n - makes the chart classes' `_draw` bodies easier to scan\n - removes the temptation to inline a slightly-different variant\n\n @module\n*/\n\nimport type {ClipShape, Transform} from \"@d3plus/render\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/**\n Margin-adjusted chart-area dimensions. Replaces the pattern:\n\n const height = viz.schema.height - viz._margin.top - viz._margin.bottom;\n const width = viz.schema.width - viz._margin.left - viz._margin.right;\n*/\nexport function chartBounds(viz: Viz): {width: number; height: number} {\n return {\n width: viz.schema.width - viz._margin.left - viz._margin.right,\n height: viz.schema.height - viz._margin.top - viz._margin.bottom,\n };\n}\n\n/**\n Build a `_chartTransform` that places the chart-cells group at the\n margin origin. Replaces the pattern:\n\n this._chartTransform = {x: this._margin.left, y: this._margin.top};\n\n Used by Tree, Network, Rings, Sankey, Treemap, etc. — every\n rectangular chart whose data lays out from the top-left of the\n chart area.\n*/\nexport function marginOriginTransform(viz: Viz): Transform {\n return {x: viz._margin.left, y: viz._margin.top};\n}\n\n/**\n Build a `_chartTransform` that centers the chart-cells group within\n the chart area. Replaces the pattern:\n\n this._chartTransform = {\n x: this._margin.left + width / 2,\n y: this._margin.top + height / 2,\n };\n\n Used by Pie, Donut, RadialMatrix, Radar, Chord — every chart whose\n data lays out around a center point (polar / circular geometry).\n\n Width and height are the margin-adjusted chart-area dimensions —\n callers usually have them on hand from `chartBounds(viz)` or from\n fields a stage stashed (e.g. `_pieWidth` / `_radialMatrixWidth`).\n*/\nexport function centerChartTransform(\n viz: Viz,\n width: number,\n height: number,\n): Transform {\n return {\n x: viz._margin.left + width / 2,\n y: viz._margin.top + height / 2,\n };\n}\n\n/**\n The chart area (the svg minus its margins) as a scene-space rect clip —\n where zoomable content is clipped so pan/zoom can't spill it over the\n legend, title, or timeline.\n*/\nexport function chartAreaRect(viz: Viz): ClipShape {\n const {width, height} = chartBounds(viz);\n return {type: \"rect\", x: viz._margin.left, y: viz._margin.top, width, height};\n}\n"],"names":["chartBounds","viz","width","schema","_margin","left","right","height","top","bottom","marginOriginTransform","x","y","centerChartTransform","chartAreaRect","type"],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBA,GAKA;;;;;AAKA,GACA,OAAO,SAASA,YAAYC,GAAQ;IAClC,OAAO;QACLC,OAAOD,IAAIE,MAAM,CAACD,KAAK,GAAGD,IAAIG,OAAO,CAACC,IAAI,GAAGJ,IAAIG,OAAO,CAACE,KAAK;QAC9DC,QAAQN,IAAIE,MAAM,CAACI,MAAM,GAAGN,IAAIG,OAAO,CAACI,GAAG,GAAGP,IAAIG,OAAO,CAACK,MAAM;IAClE;AACF;AAEA;;;;;;;;;AASA,GACA,OAAO,SAASC,sBAAsBT,GAAQ;IAC5C,OAAO;QAACU,GAAGV,IAAIG,OAAO,CAACC,IAAI;QAAEO,GAAGX,IAAIG,OAAO,CAACI,GAAG;IAAA;AACjD;AAEA;;;;;;;;;;;;;;;AAeA,GACA,OAAO,SAASK,qBACdZ,GAAQ,EACRC,KAAa,EACbK,MAAc;IAEd,OAAO;QACLI,GAAGV,IAAIG,OAAO,CAACC,IAAI,GAAGH,QAAQ;QAC9BU,GAAGX,IAAIG,OAAO,CAACI,GAAG,GAAGD,SAAS;IAChC;AACF;AAEA;;;;AAIA,GACA,OAAO,SAASO,cAAcb,GAAQ;IACpC,IAAwBD,eAAAA,YAAYC,MAA7BC,QAAiBF,aAAjBE,OAAOK,SAAUP,aAAVO;IACd,OAAO;QAACQ,MAAM;QAAQJ,GAAGV,IAAIG,OAAO,CAACC,IAAI;QAAEO,GAAGX,IAAIG,OAAO,CAACI,GAAG;QAAEN,OAAAA;QAAOK,QAAAA;IAAM;AAC9E"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ Shared arrowhead geometry for edge charts (Network, Rings, Sankey).
3
+
4
+ Arrowheads are drawn as filled-triangle `path` scene nodes rather than SVG
5
+ `marker-end`, because d3plus renders to both SVG and Canvas and Canvas has no
6
+ marker support. Each chart computes the tip point + tangent angle from its own
7
+ edge geometry (edges terminate differently per chart) and calls `arrowNode`.
8
+ The triangle lives in the same content coordinate space as its edge, so it
9
+ pans/zooms and hover-dims in lockstep with the edge.
10
+
11
+ Chord doesn't use this module — its ribbons carry arrowheads via d3-chord's
12
+ `ribbonArrow`.
13
+
14
+ @module
15
+ */ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
27
+ }
28
+ function _object_spread(target) {
29
+ for(var i = 1; i < arguments.length; i++){
30
+ var source = arguments[i] != null ? arguments[i] : {};
31
+ var ownKeys = Object.keys(source);
32
+ if (typeof Object.getOwnPropertySymbols === "function") {
33
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
34
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35
+ }));
36
+ }
37
+ ownKeys.forEach(function(key) {
38
+ _define_property(target, key, source[key]);
39
+ });
40
+ }
41
+ return target;
42
+ }
43
+ /** Normalize an `arrows` config value for one edge into `{source, target}` flags. */ export function arrowEnds(arrows, d, i) {
44
+ var v = typeof arrows === "function" ? arrows(d, i) : arrows;
45
+ if (v === true || v === "target") return {
46
+ source: false,
47
+ target: true
48
+ };
49
+ if (v === "source") return {
50
+ source: true,
51
+ target: false
52
+ };
53
+ if (v === "both") return {
54
+ source: true,
55
+ target: true
56
+ };
57
+ return {
58
+ source: false,
59
+ target: false
60
+ };
61
+ }
62
+ var round = function round(n) {
63
+ return Math.round(n * 100) / 100;
64
+ };
65
+ /**
66
+ SVG path `d` for a filled isosceles triangle whose tip is at `(x, y)`, pointing
67
+ along `angle` (radians), with `size` the tip-to-base length.
68
+ */ export function arrowPathD(x, y, angle, size) {
69
+ var halfBase = size * 0.6;
70
+ var bx = x - Math.cos(angle) * size;
71
+ var by = y - Math.sin(angle) * size;
72
+ var nx = Math.cos(angle + Math.PI / 2);
73
+ var ny = Math.sin(angle + Math.PI / 2);
74
+ return "M".concat(round(x), ",").concat(round(y), "L").concat(round(bx + nx * halfBase), ",").concat(round(by + ny * halfBase), "L").concat(round(bx - nx * halfBase), ",").concat(round(by - ny * halfBase), "Z");
75
+ }
76
+ /**
77
+ Tip point + direction for a straight-edge arrowhead sitting at the boundary of
78
+ an endpoint node (radius `r`), pointing from `(fromX, fromY)` toward
79
+ `(toX, toY)`. `gap` insets the tip slightly off the node edge. Used by Network
80
+ (center-to-center links) and Rings' straight center-links.
81
+ */ export function straightArrowTip(fromX, fromY, toX, toY, r) {
82
+ var gap = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
83
+ var angle = Math.atan2(toY - fromY, toX - fromX);
84
+ return {
85
+ x: toX - Math.cos(angle) * (r + gap),
86
+ y: toY - Math.sin(angle) * (r + gap),
87
+ angle: angle
88
+ };
89
+ }
90
+ /**
91
+ Resolve the arrowhead size from the `arrowSize` config (a number or per-edge
92
+ accessor), falling back to a size derived from the edge's stroke width.
93
+ */ export function arrowSizeFor(arrowSize, d, i, strokeWidth) {
94
+ var cfg = typeof arrowSize === "function" ? arrowSize(d, i) : arrowSize;
95
+ return typeof cfg === "number" ? cfg : Math.max(6, strokeWidth * 3);
96
+ }
97
+ /**
98
+ Emit arrowhead nodes for a straight, center-to-center edge between two nodes
99
+ (radii `source.r`/`target.r`), insetting each tip to the node boundary.
100
+ Returns `[]` when `arrows` selects neither end. Used by Network and Rings'
101
+ straight center-links.
102
+ */ export function straightEdgeArrows(opts) {
103
+ var ends = arrowEnds(opts.arrows, opts.datum, opts.i);
104
+ if (!ends.source && !ends.target) return [];
105
+ var size = arrowSizeFor(opts.arrowSize, opts.datum, opts.i, typeof opts.strokeWidth === "number" ? opts.strokeWidth : 1);
106
+ var s = opts.source, t = opts.target, datum = opts.datum, fill = opts.fill, keyPrefix = opts.keyPrefix;
107
+ var out = [];
108
+ if (ends.target) {
109
+ var _t_r;
110
+ var tip = straightArrowTip(s.x, s.y, t.x, t.y, (_t_r = t.r) !== null && _t_r !== void 0 ? _t_r : 0, 1);
111
+ out.push(arrowNode({
112
+ key: "".concat(keyPrefix, "-t"),
113
+ datum: datum,
114
+ x: tip.x,
115
+ y: tip.y,
116
+ angle: tip.angle,
117
+ size: size,
118
+ fill: fill
119
+ }));
120
+ }
121
+ if (ends.source) {
122
+ var _s_r;
123
+ var tip1 = straightArrowTip(t.x, t.y, s.x, s.y, (_s_r = s.r) !== null && _s_r !== void 0 ? _s_r : 0, 1);
124
+ out.push(arrowNode({
125
+ key: "".concat(keyPrefix, "-s"),
126
+ datum: datum,
127
+ x: tip1.x,
128
+ y: tip1.y,
129
+ angle: tip1.angle,
130
+ size: size,
131
+ fill: fill
132
+ }));
133
+ }
134
+ return out;
135
+ }
136
+ /**
137
+ Build one arrowhead scene node. `interactive: false` so the edge path owns
138
+ hit-testing, and the same `datum` as its edge so the hover-dim pass keeps the
139
+ arrow paired with its edge.
140
+ */ export function arrowNode(opts) {
141
+ return {
142
+ type: "path",
143
+ key: opts.key,
144
+ d: arrowPathD(opts.x, opts.y, opts.angle, opts.size),
145
+ datum: opts.datum,
146
+ interactive: false,
147
+ paint: _object_spread({
148
+ fill: opts.fill
149
+ }, opts.opacity !== undefined ? {
150
+ opacity: opts.opacity
151
+ } : {})
152
+ };
153
+ }
154
+
155
+ //# sourceMappingURL=edgeArrows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/features/edgeArrows.ts"],"sourcesContent":["/**\n Shared arrowhead geometry for edge charts (Network, Rings, Sankey).\n\n Arrowheads are drawn as filled-triangle `path` scene nodes rather than SVG\n `marker-end`, because d3plus renders to both SVG and Canvas and Canvas has no\n marker support. Each chart computes the tip point + tangent angle from its own\n edge geometry (edges terminate differently per chart) and calls `arrowNode`.\n The triangle lives in the same content coordinate space as its edge, so it\n pans/zooms and hover-dims in lockstep with the edge.\n\n Chord doesn't use this module — its ribbons carry arrowheads via d3-chord's\n `ribbonArrow`.\n\n @module\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\n/** Which end(s) of an edge carry an arrowhead. `true` is equivalent to `\"target\"`. */\nexport type ArrowEndValue = boolean | \"target\" | \"source\" | \"both\";\n\n/** The `arrows` config: a fixed value or a per-edge accessor. */\nexport type ArrowValue =\n | ArrowEndValue\n | ((d: DataPoint, i: number) => ArrowEndValue);\n\n/** Resolved per-edge arrow ends. */\nexport interface ArrowEnds {\n source: boolean;\n target: boolean;\n}\n\n/** Normalize an `arrows` config value for one edge into `{source, target}` flags. */\nexport function arrowEnds(arrows: ArrowValue, d: DataPoint, i: number): ArrowEnds {\n const v = typeof arrows === \"function\" ? arrows(d, i) : arrows;\n if (v === true || v === \"target\") return {source: false, target: true};\n if (v === \"source\") return {source: true, target: false};\n if (v === \"both\") return {source: true, target: true};\n return {source: false, target: false};\n}\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\n/**\n SVG path `d` for a filled isosceles triangle whose tip is at `(x, y)`, pointing\n along `angle` (radians), with `size` the tip-to-base length.\n*/\nexport function arrowPathD(\n x: number,\n y: number,\n angle: number,\n size: number,\n): string {\n const halfBase = size * 0.6;\n const bx = x - Math.cos(angle) * size;\n const by = y - Math.sin(angle) * size;\n const nx = Math.cos(angle + Math.PI / 2);\n const ny = Math.sin(angle + Math.PI / 2);\n return `M${round(x)},${round(y)}L${round(bx + nx * halfBase)},${round(by + ny * halfBase)}L${round(bx - nx * halfBase)},${round(by - ny * halfBase)}Z`;\n}\n\n/**\n Tip point + direction for a straight-edge arrowhead sitting at the boundary of\n an endpoint node (radius `r`), pointing from `(fromX, fromY)` toward\n `(toX, toY)`. `gap` insets the tip slightly off the node edge. Used by Network\n (center-to-center links) and Rings' straight center-links.\n*/\nexport function straightArrowTip(\n fromX: number,\n fromY: number,\n toX: number,\n toY: number,\n r: number,\n gap = 1,\n): {x: number; y: number; angle: number} {\n const angle = Math.atan2(toY - fromY, toX - fromX);\n return {\n x: toX - Math.cos(angle) * (r + gap),\n y: toY - Math.sin(angle) * (r + gap),\n angle,\n };\n}\n\n/**\n Resolve the arrowhead size from the `arrowSize` config (a number or per-edge\n accessor), falling back to a size derived from the edge's stroke width.\n*/\nexport function arrowSizeFor(\n arrowSize: unknown,\n d: DataPoint,\n i: number,\n strokeWidth: number,\n): number {\n const cfg =\n typeof arrowSize === \"function\"\n ? (arrowSize as (d: DataPoint, i: number) => unknown)(d, i)\n : arrowSize;\n return typeof cfg === \"number\" ? cfg : Math.max(6, strokeWidth * 3);\n}\n\n/**\n Emit arrowhead nodes for a straight, center-to-center edge between two nodes\n (radii `source.r`/`target.r`), insetting each tip to the node boundary.\n Returns `[]` when `arrows` selects neither end. Used by Network and Rings'\n straight center-links.\n*/\nexport function straightEdgeArrows(opts: {\n arrows: ArrowValue;\n arrowSize: unknown;\n strokeWidth?: number;\n datum: DataPoint;\n i: number;\n keyPrefix: string;\n fill?: string;\n source: {x: number; y: number; r?: number};\n target: {x: number; y: number; r?: number};\n}): SceneNode[] {\n const ends = arrowEnds(opts.arrows, opts.datum, opts.i);\n if (!ends.source && !ends.target) return [];\n const size = arrowSizeFor(\n opts.arrowSize,\n opts.datum,\n opts.i,\n typeof opts.strokeWidth === \"number\" ? opts.strokeWidth : 1,\n );\n const {source: s, target: t, datum, fill, keyPrefix} = opts;\n const out: SceneNode[] = [];\n if (ends.target) {\n const tip = straightArrowTip(s.x, s.y, t.x, t.y, t.r ?? 0, 1);\n out.push(arrowNode({key: `${keyPrefix}-t`, datum, x: tip.x, y: tip.y, angle: tip.angle, size, fill}));\n }\n if (ends.source) {\n const tip = straightArrowTip(t.x, t.y, s.x, s.y, s.r ?? 0, 1);\n out.push(arrowNode({key: `${keyPrefix}-s`, datum, x: tip.x, y: tip.y, angle: tip.angle, size, fill}));\n }\n return out;\n}\n\n/** Inputs for a single arrowhead scene node. */\nexport interface ArrowNodeOpts {\n key: string | number;\n datum: DataPoint;\n x: number;\n y: number;\n /** Direction the arrow points, in radians. */\n angle: number;\n size: number;\n fill?: string;\n opacity?: number;\n}\n\n/**\n Build one arrowhead scene node. `interactive: false` so the edge path owns\n hit-testing, and the same `datum` as its edge so the hover-dim pass keeps the\n arrow paired with its edge.\n*/\nexport function arrowNode(opts: ArrowNodeOpts): SceneNode {\n return {\n type: \"path\",\n key: opts.key,\n d: arrowPathD(opts.x, opts.y, opts.angle, opts.size),\n datum: opts.datum,\n interactive: false,\n paint: {\n fill: opts.fill,\n ...(opts.opacity !== undefined ? {opacity: opts.opacity} : {}),\n },\n } as SceneNode;\n}\n"],"names":["arrowEnds","arrows","d","i","v","source","target","round","n","Math","arrowPathD","x","y","angle","size","halfBase","bx","cos","by","sin","nx","PI","ny","straightArrowTip","fromX","fromY","toX","toY","r","gap","atan2","arrowSizeFor","arrowSize","strokeWidth","cfg","max","straightEdgeArrows","opts","ends","datum","s","t","fill","keyPrefix","out","tip","push","arrowNode","key","type","interactive","paint","opacity","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,mFAAmF,GACnF,OAAO,SAASA,UAAUC,MAAkB,EAAEC,CAAY,EAAEC,CAAS;IACnE,IAAMC,IAAI,OAAOH,WAAW,aAAaA,OAAOC,GAAGC,KAAKF;IACxD,IAAIG,MAAM,QAAQA,MAAM,UAAU,OAAO;QAACC,QAAQ;QAAOC,QAAQ;IAAI;IACrE,IAAIF,MAAM,UAAU,OAAO;QAACC,QAAQ;QAAMC,QAAQ;IAAK;IACvD,IAAIF,MAAM,QAAQ,OAAO;QAACC,QAAQ;QAAMC,QAAQ;IAAI;IACpD,OAAO;QAACD,QAAQ;QAAOC,QAAQ;IAAK;AACtC;AAEA,IAAMC,QAAQ,eAACC;WAAsBC,KAAKF,KAAK,CAACC,IAAI,OAAO;;AAE3D;;;A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,OAAAA;YAAO5B,GAAGkC,KAAIlC,CAAC;YAAEC,GAAGiC,KAAIjC,CAAC;YAAEC,OAAOgC,KAAIhC,KAAK;YAAEC,MAAAA;YAAM4B,MAAAA;QAAI;IACpG;IACA,OAAOE;AACT;AAeA;;;;AAIA,GACA,OAAO,SAASG,UAAUV,IAAmB;IAC3C,OAAO;QACLY,MAAM;QACND,KAAKX,KAAKW,GAAG;QACb9C,GAAGQ,WAAW2B,KAAK1B,CAAC,EAAE0B,KAAKzB,CAAC,EAAEyB,KAAKxB,KAAK,EAAEwB,KAAKvB,IAAI;QACnDyB,OAAOF,KAAKE,KAAK;QACjBW,aAAa;QACbC,OAAO;YACLT,MAAML,KAAKK,IAAI;WACXL,KAAKe,OAAO,KAAKC,YAAY;YAACD,SAASf,KAAKe,OAAO;QAAA,IAAI,CAAC;IAEhE;AACF"}
@@ -132,6 +132,14 @@ import * as shapes from "../../shapes/index.js";
132
132
  vectorEffect: ve === "none" || ve === "non-scaling-stroke" ? ve : undefined
133
133
  };
134
134
  }
135
+ /**
136
+ Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`
137
+ wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree
138
+ convention — same unwrap `paintFromShapeConfig` callers already do).
139
+ */ export function drawNodeLabel(viz, d, i) {
140
+ var _d_data, _d_i;
141
+ return viz._drawLabel((_d_data = d.data) !== null && _d_data !== void 0 ? _d_data : d, (_d_i = d.i) !== null && _d_i !== void 0 ? _d_i : i);
142
+ }
135
143
  /**
136
144
  Apply a shape-config object to a chart-specific shape key, returning the
137
145
  configPrep-massaged object suitable for `.config(...)`. Equivalent to
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/emitHelpers.ts"],"sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is\n forced to `string | undefined` to match `Paint.fill` (texture/object\n fills fall through to `undefined`; the existing flat-data emits already\n do this same coercion).\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","shapes","shapeCtors","makeShape","key","resolveAccessor","val","d","i","paintFromShapeConfig","sc","fill","stroke","strokeWidth","opacity","ve","vectorEffect","undefined","shapeConfigFor","viz","shapeKey","config","kind","bind","schema","shapeConfig","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAMnD,YAAYC,YAAY,wBAAwB;AAEhD,uEAAuE,GACvE,IAAMC,aAAaD;AAEnB,yEAAyE,GACzE,OAAO,IAAME,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA;;;;;;;AAOA,GACA,OAAO,SAASG,qBACdC,EAA2B,EAC3BH,CAAY,EACZC,CAAqB;IAQrB,IAAMG,OAAON,gBAAyBK,GAAGC,IAAI,EAAEJ,GAAGC;IAClD,IAAMI,SAASP,gBAAwBK,GAAGE,MAAM,EAAEL,GAAGC;IACrD,IAAMK,cAAcR,gBAAwBK,GAAGG,WAAW,EAAEN,GAAGC;IAC/D,IAAMM,UAAUT,gBAAwBK,GAAGI,OAAO,EAAEP,GAAGC;IACvD,IAAMO,KAAKV,gBAAwBK,GAAGM,YAAY,EAAET,GAAGC;IACvD,OAAO;QACLG,MA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,GACA,OAAO,SAASU,0BACdxB,GAAY,EACZQ,KAAmC,EACnCiB,IAAwD;IAExD,IAAI,CAACjB,SAAS,OAAOA,MAAMO,OAAO,KAAK,YAAY;IACnD,IAAI,CAACE,MAAMC,OAAO,CAAClB,IAAI0B,WAAW,GAAG1B,IAAI0B,WAAW,GAAG,EAAE;IACzD,IAAMP,WAAWZ,gBAAgBC;IACjC,IAAI,CAACW,SAASQ,MAAM,EAAE;IACtB,IAAIF,MAAM;QACRzB,IAAI0B,WAAW,CAAEN,IAAI,CAAC;YAACQ,MAAM;WAAYH;YAAMN,UAAAA;;IACjD,OAAO;YACLnB;QAAAA,CAAAA,mBAAAA,IAAI0B,WAAW,EAAEN,IAAI,OAArBpB,kBAAsB,qBAAGmB;IAC3B;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/features/emitHelpers.ts"],"sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is\n forced to `string | undefined` to match `Paint.fill` (texture/object\n fills fall through to `undefined`; the existing flat-data emits already\n do this same coercion).\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`\n wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree\n convention — same unwrap `paintFromShapeConfig` callers already do).\n*/\nexport function drawNodeLabel(\n viz: {_drawLabel: (d: DataPoint, i: number) => string},\n d: DataPoint & {data?: DataPoint; i?: number},\n i: number,\n): string {\n return viz._drawLabel((d.data ?? d) as DataPoint, (d.i ?? i) as number);\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","shapes","shapeCtors","makeShape","key","resolveAccessor","val","d","i","paintFromShapeConfig","sc","fill","stroke","strokeWidth","opacity","ve","vectorEffect","undefined","drawNodeLabel","viz","_drawLabel","data","shapeConfigFor","shapeKey","config","kind","bind","schema","shapeConfig","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAMnD,YAAYC,YAAY,wBAAwB;AAEhD,uEAAuE,GACvE,IAAMC,aAAaD;AAEnB,yEAAyE,GACzE,OAAO,IAAME,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA;;;;;;;AAOA,GACA,OAAO,SAASG,qBACdC,EAA2B,EAC3BH,CAAY,EACZC,CAAqB;IAQrB,IAAMG,OAAON,gBAAyBK,GAAGC,IAAI,EAAEJ,GAAGC;IAClD,IAAMI,SAASP,gBAAwBK,GAAGE,MAAM,EAAEL,GAAGC;IACrD,IAAMK,cAAcR,gBAAwBK,GAAGG,WAAW,EAAEN,GAAGC;IAC/D,IAAMM,UAAUT,gBAAwBK,GAAGI,OAAO,EAAEP,GAAGC;IACvD,IAAMO,KAAKV,gBAAwBK,GAAGM,YAAY,EAAET,GAAGC;IACvD,OAAO;QACLG,MAAM,OAAOA,SAAS,WAAWA,OAAOM;QACxCL,QAAAA;QACAC,aAAAA;QACAC,SAAAA;QACAE,cAAcD,OAAO,UAAUA,OAAO,uBAAuBA,KAAKE;IACpE;AACF;AAEA;;;;AAIA,GACA,OAAO,SAASC,cACdC,GAAsD,EACtDZ,CAA6C,EAC7CC,CAAS;QAEcD,SAA4BA;IAAnD,OAAOY,IAAIC,UAAU,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