@d3plus/core 4.2.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 (214) hide show
  1. package/README.md +2137 -953
  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 +58 -9
  23. package/es/src/charts/Geomap/emit.js.map +1 -1
  24. package/es/src/charts/Geomap/index.js +93 -99
  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 +99 -4
  45. package/es/src/charts/Plot/index.js.map +1 -1
  46. package/es/src/charts/Plot/pipeline.js +25 -5
  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/shapeEmit.js +3 -1
  124. package/es/src/charts/features/shapeEmit.js.map +1 -1
  125. package/es/src/charts/features/zoomExtent.js +185 -0
  126. package/es/src/charts/features/zoomExtent.js.map +1 -0
  127. package/es/src/charts/helpers/tileAttributions.js +26 -0
  128. package/es/src/charts/helpers/tileAttributions.js.map +1 -1
  129. package/es/src/charts/index.js +1 -0
  130. package/es/src/charts/index.js.map +1 -1
  131. package/es/src/charts/pipeline/runVizPipeline.js +33 -14
  132. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  133. package/es/src/charts/pipeline/vizDrawPure.js +32 -6
  134. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  135. package/es/src/charts/viz/Viz.js +102 -61
  136. package/es/src/charts/viz/Viz.js.map +1 -1
  137. package/es/src/charts/viz/VizBase.js +157 -4
  138. package/es/src/charts/viz/VizBase.js.map +1 -1
  139. package/es/src/charts/viz/VizBaseConfig.js +32 -2
  140. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  141. package/es/src/charts/viz/interactionOpacity.js +4 -1
  142. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  143. package/es/src/charts/viz/vizDefaults.js +247 -51
  144. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  145. package/es/src/charts/viz/vizRender.js +7 -3
  146. package/es/src/charts/viz/vizRender.js.map +1 -1
  147. package/es/src/charts/viz/vizTypes.js.map +1 -1
  148. package/es/src/components/Axis/Axis.js +10 -1
  149. package/es/src/components/Axis/Axis.js.map +1 -1
  150. package/es/src/components/Axis/axisLayoutLabels.js +2 -1
  151. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  152. package/es/src/components/Axis/axisRender.js +5 -1
  153. package/es/src/components/Axis/axisRender.js.map +1 -1
  154. package/es/src/components/Legend/legendConfig.js +86 -20
  155. package/es/src/components/Legend/legendConfig.js.map +1 -1
  156. package/es/src/shapes/Shape.js +12 -10
  157. package/es/src/shapes/Shape.js.map +1 -1
  158. package/es/src/shapes/hitAreaNode.js +31 -5
  159. package/es/src/shapes/hitAreaNode.js.map +1 -1
  160. package/es/src/shapes/interactionPoints.js +30 -0
  161. package/es/src/shapes/interactionPoints.js.map +1 -0
  162. package/es/src/utils/D3plusConfig.js.map +1 -1
  163. package/package.json +11 -10
  164. package/types/index.d.ts +1 -1
  165. package/types/internal.d.ts +8 -1
  166. package/types/src/charts/Chord/applyLayout.d.ts +43 -0
  167. package/types/src/charts/Chord/emit.d.ts +10 -0
  168. package/types/src/charts/Chord/index.d.ts +19 -0
  169. package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
  170. package/types/src/charts/Plot/index.d.ts +32 -2
  171. package/types/src/charts/Plot/pipeline.d.ts +2 -1
  172. package/types/src/charts/Plot/plotZoom.d.ts +65 -0
  173. package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
  174. package/types/src/charts/drawSteps/backControl.d.ts +29 -0
  175. package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
  176. package/types/src/charts/drawSteps/minimap.d.ts +19 -0
  177. package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
  178. package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
  179. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
  180. package/types/src/charts/drawSteps/tableView.d.ts +23 -0
  181. package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
  182. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
  183. package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
  184. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
  185. package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
  186. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
  187. package/types/src/charts/features/attributionFeature.d.ts +21 -0
  188. package/types/src/charts/features/axes.d.ts +1 -1
  189. package/types/src/charts/features/chartGeometry.d.ts +9 -3
  190. package/types/src/charts/features/edgeArrows.d.ts +92 -0
  191. package/types/src/charts/features/emitHelpers.d.ts +11 -0
  192. package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
  193. package/types/src/charts/features/features.d.ts +32 -17
  194. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  195. package/types/src/charts/features/plotPaint.d.ts +15 -2
  196. package/types/src/charts/features/zoomExtent.d.ts +25 -0
  197. package/types/src/charts/index.d.ts +1 -0
  198. package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
  199. package/types/src/charts/viz/Viz.d.ts +31 -1
  200. package/types/src/charts/viz/VizBase.d.ts +86 -4
  201. package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
  202. package/types/src/charts/viz/vizDefaults.d.ts +155 -0
  203. package/types/src/charts/viz/vizTypes.d.ts +75 -1
  204. package/types/src/components/Axis/Axis.d.ts +2 -0
  205. package/types/src/shapes/Shape.d.ts +2 -2
  206. package/types/src/shapes/hitAreaNode.d.ts +5 -4
  207. package/types/src/shapes/interactionPoints.d.ts +15 -0
  208. package/types/src/utils/D3plusConfig.d.ts +102 -8
  209. package/umd/d3plus-core.full.js +39793 -34875
  210. package/umd/d3plus-core.full.js.map +1 -1
  211. package/umd/d3plus-core.full.min.js +5836 -4264
  212. package/umd/d3plus-core.js +13998 -9927
  213. package/umd/d3plus-core.js.map +1 -1
  214. package/umd/d3plus-core.min.js +3716 -2264
@@ -48,31 +48,82 @@ function _unsupported_iterable_to_array(o, minLen) {
48
48
  if (n === "Map" || n === "Set") return Array.from(n);
49
49
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
50
50
  }
51
- import { zoomTransform } from "d3-zoom";
51
+ import { select } from "d3-selection";
52
+ import { zoomIdentity, zoomTransform } from "d3-zoom";
52
53
  import { attrize } from "@d3plus/dom";
53
54
  import { chartBounds } from "../features/chartGeometry.js";
55
+ import { ensureZoomDom } from "../features/ensureZoomDom.js";
56
+ import { autoZoomMax } from "../features/zoomExtent.js";
57
+ import { isBrushing, mountCustomIcons, paintZoomButton, setBrushing, showsZoomControls, syncBrushButton, ZOOM_PANEL_STYLE, zoomControlsHtml } from "./zoomControlsMarkup.js";
54
58
  /**
55
- Brush mode is per-chart, not global. Previously a module-level
56
- `let brushing = false` was shared across all chart instances on the
57
- page — toggling brush on chart A silently flipped chart B's state.
58
- Now lives on `viz._brushing` and is read/written via helpers.
59
- */ function isBrushing(viz) {
60
- return Boolean(viz._brushing);
61
- }
62
- function setBrushing(viz, value) {
63
- viz._brushing = value;
64
- }
65
- /**
66
- Apply a plain key/value style object to a real DOM element. v4 uses
67
- HtmlOverlay nodes for the zoom-control buttons, so the d3-selection
68
- `stylize` helper isn't reachable from the scene-graph escape hook.
69
- */ function applyStyleObj(el, styles) {
70
- if (!styles) return;
71
- for(var k in styles){
72
- var v = styles[k];
73
- if (v === undefined || v === null || v === false) continue;
74
- el.style[k] = String(v);
75
- }
59
+ Builds the four zoom-control buttons as an `htmlOverlay` scene-node
60
+ panel, pinned to the top-right corner of the whole chart (not the
61
+ margin-inset chart area) — top-positioned features leave room for it via
62
+ `zoomControlsBox`. Clicks ride the declarative `events` map (the
63
+ renderer delegates them from the host element, so they survive DOM
64
+ churn); hover can't be delegated (mouseenter/mouseleave don't bubble), so
65
+ `onUpdate` binds it per button. `onUpdate` (not `onMount`) because the
66
+ html isn't a fixed constant — it bakes in `zoomControlClassName`, the
67
+ locale's translated `aria-label`s, and the brush state, so those
68
+ changes swap in fresh button nodes on the next draw. The
69
+ `data-zoom-bound` guard styles, binds, and mounts each node's custom
70
+ icon (`zoomControlIcons`, if set) exactly once.
71
+ @private
72
+ */ function buildZoomControlPanel(viz) {
73
+ return {
74
+ type: "htmlOverlay",
75
+ key: "viz-zoom-controls",
76
+ x: 0,
77
+ y: 0,
78
+ width: viz.schema.width,
79
+ style: ZOOM_PANEL_STYLE,
80
+ className: "d3plus-zoom-control",
81
+ html: zoomControlsHtml(viz),
82
+ events: {
83
+ ".zoom-in": {
84
+ click: function click() {
85
+ return zoomMath.bind(viz)(viz.schema.zoomFactor);
86
+ }
87
+ },
88
+ ".zoom-out": {
89
+ click: function click() {
90
+ return zoomMath.bind(viz)(1 / viz.schema.zoomFactor);
91
+ }
92
+ },
93
+ ".zoom-reset": {
94
+ click: function click() {
95
+ return zoomMath.bind(viz)(0);
96
+ }
97
+ },
98
+ ".zoom-brush": {
99
+ click: function click(e) {
100
+ // Delegated dispatch: `e.currentTarget` is the host wrapper, so
101
+ // resolve the actual button from the event target.
102
+ var btn = e.target.closest(".zoom-brush");
103
+ if (!btn) return;
104
+ var willBrush = !isBrushing(viz);
105
+ btn.classList.toggle("active", willBrush);
106
+ btn.setAttribute("aria-pressed", String(willBrush));
107
+ paintZoomButton(viz, btn, btn.matches(":hover"));
108
+ zoomEvents.bind(viz)(willBrush);
109
+ }
110
+ }
111
+ },
112
+ onUpdate: function onUpdate(host) {
113
+ host.querySelectorAll(".zoom-control").forEach(function(btn) {
114
+ if (btn.dataset.zoomBound) return;
115
+ btn.dataset.zoomBound = "1";
116
+ paintZoomButton(viz, btn);
117
+ btn.addEventListener("mouseenter", function() {
118
+ return paintZoomButton(viz, btn, true);
119
+ });
120
+ btn.addEventListener("mouseleave", function() {
121
+ return paintZoomButton(viz, btn);
122
+ });
123
+ mountCustomIcons(viz, btn);
124
+ });
125
+ }
126
+ };
76
127
  }
77
128
  /**
78
129
  @name zoomFeature
@@ -90,115 +141,57 @@ function setBrushing(viz, value) {
90
141
  the SVG element directly via `viz._container.call(zoomBehavior)`.
91
142
  2. Returns the four control buttons (in/out/reset/brush) as an
92
143
  `htmlOverlay` scene-node panel; `runVizPipeline` appends it to
93
- `viz._featurePanels`. `onMount` is
94
- the scene's interactive-HTML escape hook: it wires the click/hover
95
- handlers + applies the user's zoomControl style configs. `onMount`
96
- fires ONCE per host element (after innerHTML is written, so the
97
- `.zoom-in` / `.zoom-out` querySelectors below resolve), not per
98
- draw — the html string is constant, so listeners attached here
99
- survive every subsequent draw (renderers only rewrite innerHTML
100
- when it differs from the current value).
144
+ `viz._featurePanels`. `onUpdate` is the scene's interactive-HTML
145
+ escape hook: it wires the hover handlers + applies the user's
146
+ zoomControl style configs, once per button DOM node (guarded by a
147
+ `data-zoom-bound` marker). Click handling instead rides the
148
+ declarative `events` map, which the renderer delegates from the
149
+ host element, so it survives DOM churn with no extra bookkeeping.
150
+ `onUpdate` (rather than `onMount`) matters because the html string
151
+ below isn't a fixed constant — it bakes in `zoomControlClassName`,
152
+ the active locale's translated `aria-label`s, and the current brush
153
+ state, so a `.locale(...)` or `.zoomControlClassName(...)` call
154
+ replaces the button nodes on the next draw. Renderers only rewrite
155
+ `innerHTML` when the string actually differs from the last-written
156
+ value, so the common case (nothing changed) is a cheap no-op.
101
157
  */ export var zoomFeature = {
102
158
  name: "zoom",
103
159
  layout: function layout(param) {
104
160
  var viz = param.viz;
161
+ if (!viz.schema.zoom) resetZoom(viz);
162
+ else ensureZoomSurface(viz);
105
163
  if (!viz._container || !viz._zoomGroup) return {
106
164
  panel: null,
107
165
  margin: {}
108
166
  };
109
167
  var bounds = chartBounds(viz);
110
- var height = viz._zoomHeight || bounds.height, that = viz, width = viz._zoomWidth || bounds.width;
111
- viz._zoomBehavior.extent([
168
+ var height = viz._zoomHeight || bounds.height, width = viz._zoomWidth || bounds.width;
169
+ // The zoom behavior works in the coordinate space of the element it's
170
+ // bound to — the outer <svg> (or the <canvas>, which shares its origin) —
171
+ // so the extent is the chart area's rect in that space, not a
172
+ // margin-relative [0, 0] → [width, height]. `Viz.toScene` applies the
173
+ // resulting transform above each chart's own positioning transform.
174
+ var _viz__margin = viz._margin, left = _viz__margin.left, top = _viz__margin.top;
175
+ var area = [
112
176
  [
113
- 0,
114
- 0
177
+ left,
178
+ top
115
179
  ],
116
180
  [
117
- width,
118
- height
181
+ left + width,
182
+ top + height
119
183
  ]
120
- ]).scaleExtent([
184
+ ];
185
+ viz._zoomBehavior.filter(function(event) {
186
+ return zoomGestureFilter(viz, event);
187
+ }).wheelDelta(wheelDelta).extent(area).scaleExtent([
121
188
  1,
122
- viz.schema.zoomMax
123
- ]).translateExtent([
124
- [
125
- 0,
126
- 0
127
- ],
128
- [
129
- width,
130
- height
131
- ]
132
- ]).on("zoom", function(event) {
189
+ zoomMax(viz, width, height)
190
+ ]).translateExtent(area).on("zoom", function(event) {
133
191
  return zoomed.bind(viz)(event.transform);
134
192
  });
135
193
  viz._zoomToBounds = zoomToBounds.bind(viz);
136
- var panel = null;
137
- if (viz.schema.zoom) {
138
- panel = {
139
- type: "htmlOverlay",
140
- key: "viz-zoom-controls",
141
- x: viz._margin.left,
142
- y: viz._margin.top,
143
- className: "d3plus-zoom-control",
144
- html: '<div class="zoom-control zoom-in">&#65291;</div>' + '<div class="zoom-control zoom-out">&#65293;</div>' + '<div class="zoom-control zoom-reset">&#8634;</div>' + '<div class="zoom-control zoom-brush">&#164;</div>',
145
- // Declarative click wiring — clicks bubble, so the renderer's
146
- // delegated dispatcher can route them by selector. The four
147
- // handlers below are the single source of truth for what each
148
- // zoom button does. Hover styles can't be delegated (mouseenter
149
- // / mouseleave don't bubble), so they live in onMount below as
150
- // a per-button binding.
151
- events: {
152
- ".zoom-in": {
153
- click: function click() {
154
- return zoomMath.bind(that)(that.schema.zoomFactor);
155
- }
156
- },
157
- ".zoom-out": {
158
- click: function click() {
159
- return zoomMath.bind(that)(1 / that.schema.zoomFactor);
160
- }
161
- },
162
- ".zoom-reset": {
163
- click: function click() {
164
- return zoomMath.bind(that)(0);
165
- }
166
- },
167
- ".zoom-brush": {
168
- click: function click(e) {
169
- // The overlay dispatches clicks via delegation, so `e.currentTarget`
170
- // is the host wrapper that encloses all four buttons — not the
171
- // clicked button. Styling/toggling the wrapper would paint the
172
- // active background around the whole control stack and offset it by
173
- // the base margin/border. Resolve the actual button from the event
174
- // target, the same way the dispatcher matches (`target.closest`).
175
- var btn = e.target.closest(".zoom-brush");
176
- if (!btn) return;
177
- var willBrush = !isBrushing(that);
178
- var isActive = btn.classList.toggle("active", willBrush);
179
- applyStyleObj(btn, isActive ? that.schema.zoomControlStyleActive || {} : that.schema.zoomControlStyle || {});
180
- zoomEvents.bind(that)(willBrush);
181
- }
182
- }
183
- },
184
- // onMount fires AFTER innerHTML is written so the querySelectorAll
185
- // matches. Applies base styles + binds non-delegable hover events
186
- // per button (mouseenter/mouseleave don't bubble through
187
- // delegated event listeners).
188
- onMount: function onMount(host) {
189
- var buttons = host.querySelectorAll(".zoom-control");
190
- buttons.forEach(function(btn) {
191
- applyStyleObj(btn, that.schema.zoomControlStyle || {});
192
- btn.addEventListener("mouseenter", function() {
193
- applyStyleObj(btn, that.schema.zoomControlStyleHover || {});
194
- });
195
- btn.addEventListener("mouseleave", function() {
196
- applyStyleObj(btn, btn.classList.contains("active") ? that.schema.zoomControlStyleActive || {} : that.schema.zoomControlStyle || {});
197
- });
198
- });
199
- }
200
- };
201
- }
194
+ var panel = showsZoomControls(viz) ? buildZoomControlPanel(viz) : null;
202
195
  viz._zoomBrush.extent([
203
196
  [
204
197
  0,
@@ -211,18 +204,111 @@ function setBrushing(viz, value) {
211
204
  ]).filter(function(event) {
212
205
  return !event.button && event.detail < 2;
213
206
  }).handleSize(viz.schema.zoomBrushHandleSize).on("start", brushStart.bind(viz)).on("brush", brushBrush.bind(viz)).on("end", brushEnd.bind(viz));
214
- var brushGroup = viz._container.selectAll("g.brush").data([
207
+ // The brush mounts in the outer <svg> above the painted scene (see
208
+ // `Viz._drawSceneToTarget`), not inside `_container` beneath it, so the
209
+ // selection box stays visible over the shapes while dragging. It's
210
+ // offset to the chart area, so selections come out chart-area-relative.
211
+ var brushGroup = viz._select.selectAll(":scope > g.d3plus-zoom-brush").data([
215
212
  0
216
213
  ]);
217
- viz._brushGroup = brushGroup.enter().append("g").attr("class", "brush").merge(brushGroup).call(viz._zoomBrush);
218
- zoomEvents.bind(viz)();
219
- if (viz._renderTiles) viz._renderTiles(zoomTransform((viz._zoomEventTarget || viz._container).node()), 0);
214
+ viz._brushGroup = brushGroup.enter().append("g").attr("class", "d3plus-zoom-brush").merge(brushGroup).attr("transform", "translate(".concat(left, ", ").concat(top, ")")).call(viz._zoomBrush);
215
+ zoomEvents.bind(viz)(isBrushing(viz));
216
+ if (viz._renderTiles) viz._renderTiles(tileZoomTransform(viz), 0);
220
217
  return {
221
218
  panel: panel,
222
219
  margin: {}
223
220
  };
224
221
  }
225
222
  };
223
+ /**
224
+ The maximum zoom scale: an explicit `zoomMax`, or — when unset — the scale
225
+ at which the chart's smallest shape fills the chart area.
226
+ @private
227
+ */ function zoomMax(viz, width, height) {
228
+ var _ref;
229
+ var _viz__chartTransform;
230
+ if (typeof viz.schema.zoomMax === "number") return viz.schema.zoomMax;
231
+ return autoZoomMax(viz._zoomShapes || viz._chartScene || [], width, height, viz.schema.zoomPadding, (_ref = (_viz__chartTransform = viz._chartTransform) === null || _viz__chartTransform === void 0 ? void 0 : _viz__chartTransform.scale) !== null && _ref !== void 0 ? _ref : 1);
232
+ }
233
+ /**
234
+ Mounts the DOM a zoomable chart needs: the `_container` <svg> hosting the
235
+ zoom brush (every chart but Network/Geomap, which mount their own
236
+ variants in `_draw`), and, on the SVG backend, points d3-zoom at the outer
237
+ <svg>. The scene paints into that same outer <svg>, so it receives wheel/
238
+ drag/dblclick both over painted shapes and over empty background. (The
239
+ Canvas backend binds the <canvas> instead — see `bindCanvasZoom`.)
240
+ @private
241
+ */ function ensureZoomSurface(viz) {
242
+ if (!viz._select) return;
243
+ if (!viz._ssr && (!viz._container || viz._container.classed("d3plus-zoom"))) {
244
+ var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
245
+ ensureZoomDom(viz, {
246
+ kind: "generic",
247
+ width: width,
248
+ height: height,
249
+ duration: viz.schema.duration
250
+ });
251
+ }
252
+ if (viz._renderer !== "canvas") retargetZoom(viz, viz._select);
253
+ }
254
+ /**
255
+ Moves the d3-zoom listeners onto a new element, clearing them from the
256
+ previous target (and from `_container`, the default target) so a single
257
+ gesture is never zoomed twice.
258
+ @private
259
+ */ function retargetZoom(viz, target) {
260
+ var prev = viz._zoomEventTarget;
261
+ if (prev && prev.node() === target.node()) return;
262
+ if (prev) prev.on(".zoom", null);
263
+ if (viz._container) viz._container.on(".zoom", null);
264
+ viz._zoomEventTarget = target;
265
+ }
266
+ /**
267
+ Canvas backend: once the scene is painted (so the <canvas> exists), bind
268
+ d3-zoom to it. The compute <svg> overlaying the canvas is transparent to
269
+ pointer events there, so the canvas is the sole interaction surface —
270
+ CanvasRenderer's pick drives tooltips and d3-zoom drives pan/zoom on the
271
+ same element. Called after every canvas paint; a no-op once bound.
272
+ */ export function bindCanvasZoom(viz) {
273
+ if (!viz.schema.zoom || viz._ssr || !viz._zoomBehavior || !viz._brushGroup) return;
274
+ var renderer = viz._sceneRenderer;
275
+ var canvasNode = renderer && typeof renderer.toCanvas === "function" ? renderer.toCanvas() : null;
276
+ if (!canvasNode || viz._zoomEventTarget && viz._zoomEventTarget.node() === canvasNode) return;
277
+ retargetZoom(viz, select(canvasNode));
278
+ zoomEvents.bind(viz)(isBrushing(viz));
279
+ }
280
+ /**
281
+ Routes pointer events between the chart surface and the zoom brush.
282
+ While brush mode is on, the outer <svg> goes transparent to pointer
283
+ events and only the brush group opts back in, so a drag anywhere over the
284
+ chart (shapes included) reaches the brush rather than a shape. On the
285
+ Canvas backend the compute <svg> stays transparent otherwise, so the
286
+ <canvas> beneath is the interaction surface.
287
+ */ export function applyZoomPointerEvents(viz) {
288
+ var canvas = viz._renderer === "canvas";
289
+ var brushing = isBrushing(viz);
290
+ if (viz._select) viz._select.style("pointer-events", canvas || brushing ? "none" : null);
291
+ if (viz._container) viz._container.style("pointer-events", canvas ? "none" : null);
292
+ if (viz._brushGroup) viz._brushGroup.style("pointer-events", brushing ? "all" : null);
293
+ }
294
+ /**
295
+ The current zoom transform re-expressed for content inside `_container`,
296
+ which sits at the chart's margin offset rather than at the surface origin
297
+ the zoom behavior measures from (Geomap's imperative tile layer).
298
+ */ export function tileZoomTransform(viz) {
299
+ var t = zoomTransform((viz._zoomEventTarget || viz._container).node());
300
+ var _viz__margin = viz._margin, left = _viz__margin.left, top = _viz__margin.top;
301
+ return zoomIdentity.translate(t.x + (t.k - 1) * left, t.y + (t.k - 1) * top).scale(t.k);
302
+ }
303
+ /**
304
+ Drops any zoom left over from before `zoom` was turned off, so the chart
305
+ renders at its natural scale and a later re-enable starts from identity.
306
+ @private
307
+ */ function resetZoom(viz) {
308
+ viz._zoomTransform = undefined;
309
+ var tgt = viz._zoomEventTarget || viz._container;
310
+ if (tgt && tgt.node()) tgt.property("__zoom", zoomIdentity);
311
+ }
226
312
  /**
227
313
  @name zoomEvents
228
314
  Handles adding/removing zoom event listeners.
@@ -232,6 +318,7 @@ function setBrushing(viz, value) {
232
318
  setBrushing(this, brush);
233
319
  if (brush) this._brushGroup.style("display", "inline");
234
320
  else this._brushGroup.style("display", "none");
321
+ applyZoomPointerEvents(this);
235
322
  // The element d3-zoom binds its pointer listeners to. Defaults to the compute
236
323
  // `<svg>` container; on the Canvas backend it's the <canvas> (see
237
324
  // `bindCanvasZoom`), because the canvas is the interaction surface there —
@@ -243,6 +330,7 @@ function setBrushing(viz, value) {
243
330
  if (!this.schema.zoomScroll) {
244
331
  tgt.on("wheel.zoom", null);
245
332
  }
333
+ applyTouchAction(this);
246
334
  if (!this.schema.zoomPan) {
247
335
  tgt.on("mousedown.zoom mousemove.zoom", null).on("touchstart.zoom touchmove.zoom touchend.zoom touchcancel.zoom", null);
248
336
  }
@@ -250,6 +338,51 @@ function setBrushing(viz, value) {
250
338
  tgt.on(".zoom", null);
251
339
  }
252
340
  }
341
+ /** Whether the chart is currently zoomed in (or panned) from its natural view. */ function isZoomedIn(viz) {
342
+ var tgt = viz._zoomEventTarget || viz._container;
343
+ return Boolean(tgt && tgt.node() && zoomTransform(tgt.node()).k > 1);
344
+ }
345
+ /**
346
+ Which gestures d3-zoom acts on. With `zoomScroll: "modifier"` (the default
347
+ for charts embedded in a scrolling page), a chart doesn't capture the
348
+ page's own scrolling: a plain wheel scrolls the page and only Ctrl/⌘ +
349
+ wheel zooms (a trackpad pinch arrives as a Ctrl + wheel, so it zooms
350
+ too), and a one-finger touch scrolls the page while a two-finger pinch
351
+ zooms — until the chart is zoomed in, when one finger pans it. d3-zoom
352
+ registers every current touch when a gesture starts, so skipping the
353
+ first finger still gives a full pinch. Everything else follows d3-zoom's
354
+ default filter (no Ctrl + drag, primary button only).
355
+ @private
356
+ */ function zoomGestureFilter(viz, event) {
357
+ var _ref;
358
+ var _event_touches;
359
+ var modifier = viz.schema.zoomScroll === "modifier";
360
+ if (event.type === "wheel") return !modifier || event.ctrlKey || event.metaKey;
361
+ if (event.type === "touchstart" && modifier) return ((_ref = (_event_touches = event.touches) === null || _event_touches === void 0 ? void 0 : _event_touches.length) !== null && _ref !== void 0 ? _ref : 0) > 1 || isZoomedIn(viz);
362
+ return !event.ctrlKey && !event.button;
363
+ }
364
+ /**
365
+ d3-zoom's wheel-to-zoom rate, except that its 10× boost for Ctrl + wheel
366
+ only applies to a trackpad pinch (which browsers report as Ctrl + wheel
367
+ with small deltas). Now that Ctrl + wheel is how a mouse zooms a chart, a
368
+ mouse notch (~100px) held with Ctrl would otherwise jump 4× per notch.
369
+ @private
370
+ */ function wheelDelta(event) {
371
+ var pinch = event.ctrlKey && event.deltaMode === 0 && Math.abs(event.deltaY) < 50;
372
+ return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * (pinch ? 10 : 1);
373
+ }
374
+ /**
375
+ Lets the browser keep one-finger page scrolling over a chart while
376
+ `zoomScroll` is "modifier" and the chart is at its natural view (a
377
+ pinch still reaches d3-zoom), and hands every touch to the chart once
378
+ it's zoomed in so one finger pans it.
379
+ @private
380
+ */ function applyTouchAction(viz) {
381
+ var tgt = viz._zoomEventTarget || viz._container;
382
+ if (!tgt) return;
383
+ var modifier = viz.schema.zoomScroll === "modifier" && viz.schema.zoomPan;
384
+ tgt.style("touch-action", modifier ? isZoomedIn(viz) ? "none" : "pan-x pan-y" : null);
385
+ }
253
386
  /**
254
387
  @name zoomed
255
388
  Handles events dispatched from this._zoomBehavior
@@ -268,14 +401,22 @@ function setBrushing(viz, value) {
268
401
  // what users see.
269
402
  var t = transform;
270
403
  if (t && (typeof t === "undefined" ? "undefined" : _type_of(t)) === "object" && "k" in t) {
271
- var _t_x, _t_y, _t_k;
404
+ var _t_k, _t_x, _t_y;
272
405
  // Nullish-coalesce rather than `||` so a legitimate zero (a deliberate
273
406
  // collapse-to-zero scale, or pan transform at origin) doesn't get
274
407
  // silently rewritten to the default.
275
- this._zoomTransform = {
408
+ var state = {
409
+ k: (_t_k = t.k) !== null && _t_k !== void 0 ? _t_k : 1,
276
410
  x: (_t_x = t.x) !== null && _t_x !== void 0 ? _t_x : 0,
277
- y: (_t_y = t.y) !== null && _t_y !== void 0 ? _t_y : 0,
278
- scale: (_t_k = t.k) !== null && _t_k !== void 0 ? _t_k : 1
411
+ y: (_t_y = t.y) !== null && _t_y !== void 0 ? _t_y : 0
412
+ };
413
+ // A chart can zoom its own way (Plot rescales its axes); otherwise the
414
+ // transform scales the rendered picture via `Viz.toScene`.
415
+ if (this._zoomRescale && this._zoomRescale(state, duration)) this._zoomTransform = undefined;
416
+ else this._zoomTransform = {
417
+ x: state.x,
418
+ y: state.y,
419
+ scale: state.k
279
420
  };
280
421
  } else if (t === false) {
281
422
  this._zoomTransform = undefined;
@@ -290,7 +431,8 @@ function setBrushing(viz, value) {
290
431
  if (this._drawSceneToTarget && this._sceneRenderer) {
291
432
  this._drawSceneToTarget(duration);
292
433
  }
293
- if (this._renderTiles) this._renderTiles(zoomTransform((this._zoomEventTarget || this._container).node()), duration);
434
+ applyTouchAction(this);
435
+ if (this._renderTiles) this._renderTiles(tileZoomTransform(this), duration);
294
436
  }
295
437
  /**
296
438
  @name zoomMath
@@ -299,64 +441,48 @@ function setBrushing(viz, value) {
299
441
  */ function zoomMath() {
300
442
  var factor = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
301
443
  if (!this._container) return;
302
- var center = this._zoomBehavior.extent().bind(document)()[1].map(function(d) {
303
- return d / 2;
304
- }), scaleExtent = this._zoomBehavior.scaleExtent(), t = zoomTransform((this._zoomEventTarget || this._container).node());
305
- if (!factor) {
306
- t.k = scaleExtent[0];
307
- t.x = 0;
308
- t.y = 0;
309
- } else {
310
- var translate0 = [
311
- (center[0] - t.x) / t.k,
312
- (center[1] - t.y) / t.k
313
- ];
314
- t.k = Math.min(scaleExtent[1], t.k * factor);
315
- if (t.k <= scaleExtent[0]) {
316
- t.k = scaleExtent[0];
317
- t.x = 0;
318
- t.y = 0;
319
- } else {
320
- t.x += center[0] - (translate0[0] * t.k + t.x);
321
- t.y += center[1] - (translate0[1] * t.k + t.y);
322
- }
323
- }
324
- zoomed.bind(this)(t, this.schema.duration);
444
+ var _this__zoomBehavior_extent_bind = _sliced_to_array(this._zoomBehavior.extent().bind(document)(), 2), _this__zoomBehavior_extent_bind_ = _sliced_to_array(_this__zoomBehavior_extent_bind[0], 2), x0 = _this__zoomBehavior_extent_bind_[0], y0 = _this__zoomBehavior_extent_bind_[1], _this__zoomBehavior_extent_bind_1 = _sliced_to_array(_this__zoomBehavior_extent_bind[1], 2), x1 = _this__zoomBehavior_extent_bind_1[0], y1 = _this__zoomBehavior_extent_bind_1[1], cx = (x0 + x1) / 2, cy = (y0 + y1) / 2, t = zoomTransform((this._zoomEventTarget || this._container).node());
445
+ if (!factor) return zoomTo(this, 1, 0, 0);
446
+ // Scale about the chart area's center: keep the content point currently at
447
+ // the center fixed on screen.
448
+ var k = t.k * factor;
449
+ zoomTo(this, k, cx - (cx - t.x) / t.k * k, cy - (cy - t.y) / t.k * k);
450
+ }
451
+ /**
452
+ Applies a programmatic zoom: clamps the scale to `scaleExtent` and the
453
+ translate to `translateExtent` (the constraint d3-zoom enforces for
454
+ pointer gestures), records it as the bound element's zoom state so the
455
+ next wheel/drag continues from here, and paints it.
456
+
457
+ Exported so `minimap.ts`'s drag-to-pan and Cmd/Ctrl+scroll-to-zoom can
458
+ reuse the same scale/translate clamping instead of reimplementing it.
459
+ */ export function zoomTo(viz, scale, x, y) {
460
+ var duration = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : viz.schema.duration;
461
+ var _viz__zoomBehavior_scaleExtent = _sliced_to_array(viz._zoomBehavior.scaleExtent(), 2), kMin = _viz__zoomBehavior_scaleExtent[0], kMax = _viz__zoomBehavior_scaleExtent[1], _viz__zoomBehavior_translateExtent = _sliced_to_array(viz._zoomBehavior.translateExtent(), 2), _viz__zoomBehavior_translateExtent_ = _sliced_to_array(_viz__zoomBehavior_translateExtent[0], 2), x0 = _viz__zoomBehavior_translateExtent_[0], y0 = _viz__zoomBehavior_translateExtent_[1], _viz__zoomBehavior_translateExtent_1 = _sliced_to_array(_viz__zoomBehavior_translateExtent[1], 2), x1 = _viz__zoomBehavior_translateExtent_1[0], y1 = _viz__zoomBehavior_translateExtent_1[1], k = Math.max(kMin, Math.min(kMax, scale));
462
+ // Content must still cover the whole area: its left edge (x0·k + tx) can't
463
+ // move right of x0, nor its right edge (x1·k + tx) left of x1.
464
+ var tx = Math.max(x1 * (1 - k), Math.min(x0 * (1 - k), x)), ty = Math.max(y1 * (1 - k), Math.min(y0 * (1 - k), y));
465
+ // A fresh transform, never a mutation of `zoomTransform(node)`'s result —
466
+ // for an element d3-zoom hasn't stored state on yet, that's d3's shared
467
+ // `zoomIdentity` constant.
468
+ var t = zoomIdentity.translate(tx, ty).scale(k);
469
+ (viz._zoomEventTarget || viz._container).property("__zoom", t);
470
+ zoomed.bind(viz)(t, duration);
325
471
  }
326
472
  /**
327
473
  @name zoomToBounds
328
- Zooms to given bounds.
474
+ Zooms so the given on-screen bounds (surface pixels, as currently
475
+ displayed) fill the chart area, less `zoomPadding`. `null` resets.
329
476
  @param bounds
330
477
  @private
331
478
  */ function zoomToBounds(bounds) {
332
479
  var duration = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.schema.duration;
333
- var scaleExtent = this._zoomBehavior.scaleExtent(), t = zoomTransform((this._zoomEventTarget || this._container).node());
334
- if (bounds) {
335
- var _this__zoomBehavior_translateExtent_ = _sliced_to_array(this._zoomBehavior.translateExtent()[1], 2), width = _this__zoomBehavior_translateExtent_[0], height = _this__zoomBehavior_translateExtent_[1], dx = bounds[1][0] - bounds[0][0], dy = bounds[1][1] - bounds[0][1];
336
- var k = Math.min(scaleExtent[1], 1 / Math.max(dx / width, dy / height));
337
- var xMod, yMod;
338
- if (dx / dy < width / height) {
339
- k *= (height - this.schema.zoomPadding * 2) / height;
340
- xMod = (width - dx * k) / 2 / k;
341
- yMod = this.schema.zoomPadding / k;
342
- } else {
343
- k *= (width - this.schema.zoomPadding * 2) / width;
344
- yMod = (height - dy * k) / 2 / k;
345
- xMod = this.schema.zoomPadding / k;
346
- }
347
- t.x = (t.x - bounds[0][0] + xMod) * (t.k * k / t.k);
348
- t.y = (t.y - bounds[0][1] + yMod) * (t.k * k / t.k);
349
- t.k *= k;
350
- if (t.x > 0) t.x = 0;
351
- else if (t.x < width * -t.k + width) t.x = width * -t.k + width;
352
- if (t.y > 0) t.y = 0;
353
- else if (t.y < height * -t.k + height) t.y = height * -t.k + height;
354
- } else {
355
- t.k = scaleExtent[0];
356
- t.x = 0;
357
- t.y = 0;
358
- }
359
- zoomed.bind(this)(t, duration);
480
+ if (!bounds) return zoomTo(this, 1, 0, 0, duration);
481
+ var _this__zoomBehavior_translateExtent = _sliced_to_array(this._zoomBehavior.translateExtent(), 2), _this__zoomBehavior_translateExtent_ = _sliced_to_array(_this__zoomBehavior_translateExtent[0], 2), x0 = _this__zoomBehavior_translateExtent_[0], y0 = _this__zoomBehavior_translateExtent_[1], _this__zoomBehavior_translateExtent_1 = _sliced_to_array(_this__zoomBehavior_translateExtent[1], 2), x1 = _this__zoomBehavior_translateExtent_1[0], y1 = _this__zoomBehavior_translateExtent_1[1], pad = this.schema.zoomPadding, t = zoomTransform((this._zoomEventTarget || this._container).node()), // Un-apply the current transform: bounds → unzoomed surface space.
482
+ bx0 = (bounds[0][0] - t.x) / t.k, by0 = (bounds[0][1] - t.y) / t.k, bx1 = (bounds[1][0] - t.x) / t.k, by1 = (bounds[1][1] - t.y) / t.k;
483
+ var k = Math.min((x1 - x0 - pad * 2) / (bx1 - bx0), (y1 - y0 - pad * 2) / (by1 - by0));
484
+ // Center the bounds in the chart area.
485
+ zoomTo(this, k, (x0 + x1) / 2 - k * (bx0 + bx1) / 2, (y0 + y1) / 2 - k * (by0 + by1) / 2, duration);
360
486
  }
361
487
  /**
362
488
  Triggered on brush "brush".
@@ -370,7 +496,20 @@ function setBrushing(viz, value) {
370
496
  */ function brushEnd(event) {
371
497
  if (!event.selection) return; // Only transition after input.
372
498
  this._brushGroup.call(this._zoomBrush.move, null);
373
- zoomToBounds.bind(this)(event.selection);
499
+ // A selection is a one-shot zoom: leave brush mode so the chart takes
500
+ // pointer events (hover, pan, wheel) again.
501
+ zoomEvents.bind(this)(false);
502
+ syncBrushButton(this);
503
+ // The brush group is offset by the chart margin; shift its selection into
504
+ // the surface space `zoomToBounds` expects.
505
+ var _this__margin = this._margin, left = _this__margin.left, top = _this__margin.top;
506
+ zoomToBounds.bind(this)(event.selection.map(function(param) {
507
+ var _param = _sliced_to_array(param, 2), x = _param[0], y = _param[1];
508
+ return [
509
+ x + left,
510
+ y + top
511
+ ];
512
+ }));
374
513
  }
375
514
  /**
376
515
  Triggered on brush "start".