diff --git a/dev/examples/gaia.js b/dev/examples/gaia.js index 6372a480a..95e8cf2a1 100644 --- a/dev/examples/gaia.js +++ b/dev/examples/gaia.js @@ -45,7 +45,7 @@ export default async function(el) { from(table, { filterBy: brush }), { x: 'u', y: 'v', fill: 'density', bandwidth, binType, binWidth } ), - intervalXY({ as: brush, pixelSize }), + intervalXY({ as: brush, pixelSize, activateOn: 'mousedown' }), domainXY(Fixed), scaleColor('sqrt'), schemeColor('viridis'), width(700), height(400), marginLeft(25), marginTop(20), marginRight(1) @@ -57,7 +57,7 @@ export default async function(el) { { x: bin('phot_g_mean_mag'), y: count(), fill: 'steelblue', inset: 0.5 } ), scaleY(histScale), gridY(true), - intervalX({ as: brush }), domainX(Fixed), + intervalX({ as: brush, activateOn: 'mousedown' }), domainX(Fixed), width(350), height(200), marginLeft(65) ), plot( @@ -66,7 +66,7 @@ export default async function(el) { { x: bin('parallax'), y: count(), fill: 'steelblue', inset: 0.5 } ), scaleY(histScale), gridY(true), - intervalX({ as: brush }), domainX(Fixed), + intervalX({ as: brush, activateOn: 'mousedown' }), domainX(Fixed), width(350), height(200), marginLeft(65) ) ) @@ -78,7 +78,7 @@ export default async function(el) { { x: 'bp_rp', y: 'phot_g_mean_mag', fill: 'density', bandwidth, binType, binWidth } ), scaleColor('sqrt'), schemeColor('viridis'), reverseY(true), - intervalXY({ as: brush, pixelSize }), domainXY(Fixed), + intervalXY({ as: brush, pixelSize, activateOn: 'mousedown' }), domainXY(Fixed), width(400), height(600), marginLeft(25), marginTop(20), marginRight(1) ) ) diff --git a/dev/specs/gaia.yaml b/dev/specs/gaia.yaml index 973ed6b3c..bb3d54205 100644 --- a/dev/specs/gaia.yaml +++ b/dev/specs/gaia.yaml @@ -36,6 +36,7 @@ hconcat: - select: intervalXY pixelSize: 2 as: $brush + activateOn: mousedown domainXY: Fixed scaleColor: $scaleType schemeColor: viridis @@ -54,6 +55,7 @@ hconcat: inset: 0.5 - select: intervalX as: $brush + activateOn: mousedown domainX: Fixed scaleY: $scaleType gridY: true @@ -69,6 +71,7 @@ hconcat: inset: 0.5 - select: intervalX as: $brush + activateOn: mousedown domainX: Fixed scaleY: $scaleType gridY: true @@ -88,6 +91,7 @@ hconcat: - select: intervalXY pixelSize: 2 as: $brush + activateOn: mousedown domainXY: Fixed scaleColor: $scaleType schemeColor: viridis diff --git a/packages/vgplot/src/interactors/Interval1D.js b/packages/vgplot/src/interactors/Interval1D.js index dd5f92bad..cd53f9db2 100644 --- a/packages/vgplot/src/interactors/Interval1D.js +++ b/packages/vgplot/src/interactors/Interval1D.js @@ -12,7 +12,8 @@ export class Interval1D { field, pixelSize = 1, peers = true, - brush: style + brush: style, + activateOn = 'mouseenter' }) { this.mark = mark; this.channel = channel; @@ -24,6 +25,7 @@ export class Interval1D { this.style = style && sanitizeStyles(style); this.brush = channel === 'y' ? brushY() : brushX(); this.brush.on('brush end', ({ selection }) => this.publish(selection)); + this.activateOn = activateOn; } activate() { @@ -79,6 +81,6 @@ export class Interval1D { } } - svg.addEventListener('mouseenter', () => this.activate()); + svg.addEventListener(this.activateOn, () => this.activate()); } } diff --git a/packages/vgplot/src/interactors/Interval2D.js b/packages/vgplot/src/interactors/Interval2D.js index 7bb4275d7..69af2494b 100644 --- a/packages/vgplot/src/interactors/Interval2D.js +++ b/packages/vgplot/src/interactors/Interval2D.js @@ -14,7 +14,8 @@ export class Interval2D { yfield, pixelSize = 1, peers = true, - brush: style + brush: style, + activateOn = 'mouseenter' }) { this.mark = mark; this.pixelSize = pixelSize || 1; @@ -25,6 +26,7 @@ export class Interval2D { this.style = style && sanitizeStyles(style); this.brush = brush(); this.brush.on('brush end', ({ selection }) => this.publish(selection)); + this.activateOn = activateOn; } activate() { @@ -90,6 +92,6 @@ export class Interval2D { this.g.call(brush.move, [[x1, y1], [x2, y2]]); } - svg.addEventListener('mouseenter', () => this.activate()); + svg.addEventListener(this.activateOn, () => this.activate()); } }