Skip to content

Commit fbcb797

Browse files
Filmbostock
authored andcommitted
closes #1628
1 parent 82b7433 commit fbcb797

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/interactions/pointer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
2222
// response to pointer events.
2323
render: composeRender(function (index, scales, values, dimensions, context, next) {
2424
const svg = context.ownerSVGElement;
25+
const {data} = context.getMarkState(this);
2526

2627
// Isolate state per-pointer, per-plot; if the pointer is reused by
2728
// multiple marks, they will share the same state (e.g., sticky modality).
@@ -144,6 +145,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
144145
if (state.sticky) (state.sticky = false), state.renders.forEach((r) => r(null)); // clear all pointers
145146
else state.sticky = true;
146147
event.stopImmediatePropagation(); // suppress other pointers
148+
if (state.sticky) context.dispatchValue(data[i]);
147149
}
148150

149151
function pointerleave(event) {

src/plot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ export function plot(options = {}) {
262262
)
263263
.call(applyInlineStyles, style);
264264

265+
// A listener that will dispatch an input event on the figure element
266+
let figure = svg;
267+
context.dispatchValue = function (value) {
268+
figure.value = value;
269+
figure.dispatchEvent(new CustomEvent("input"));
270+
};
271+
265272
// Render marks.
266273
for (const mark of marks) {
267274
const {channels, values, facets: indexes} = stateByMark.get(mark);
@@ -311,7 +318,6 @@ export function plot(options = {}) {
311318
}
312319

313320
// Wrap the plot in a figure with a caption, if desired.
314-
let figure = svg;
315321
const legends = createLegends(scaleDescriptors, context, options);
316322
if (caption != null || legends.length > 0) {
317323
figure = document.createElement("figure");

0 commit comments

Comments
 (0)