From f5a28359c81df8ca3e6c6a6ca8293ab52d0b77d9 Mon Sep 17 00:00:00 2001 From: Arvind Satyanarayan Date: Mon, 13 Jun 2022 16:46:36 -0400 Subject: [PATCH] fix: don't fire geo-brush intersection on unit signal updates --- src/compile/selection/interval.ts | 16 ++++++++++------ test/compile/selection/interval.test.ts | 24 ++++++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/compile/selection/interval.ts b/src/compile/selection/interval.ts index 8ba94381fba..cda65f2b39e 100644 --- a/src/compile/selection/interval.ts +++ b/src/compile/selection/interval.ts @@ -154,15 +154,19 @@ const interval: SelectionCompiler<'interval'> = { const intersect = `intersect(${bbox}, {markname: ${stringValue(model.getName('marks'))}}, unit.mark)`; const base = `{unit: ${unitName(model)}}`; const update = `vlSelectionTuples(${intersect}, ${base})`; + const visualSignals = channels.map(proj => proj.signals.visual); return signals.concat({ name: tupleSg, - update, - ...(init - ? { - on: [{events: {signal: GEO_INIT_TICK}, update}] - } - : {}) + on: [ + { + events: [ + ...(visualSignals.length ? [{signal: visualSignals.join(' || ')}] : []), + ...(init ? [{signal: GEO_INIT_TICK}] : []) + ], + update + } + ] }); } }, diff --git a/test/compile/selection/interval.test.ts b/test/compile/selection/interval.test.ts index dfc9f8df2bc..c626cd0784b 100644 --- a/test/compile/selection/interval.test.ts +++ b/test/compile/selection/interval.test.ts @@ -1014,15 +1014,25 @@ describe('Interval Selections', () => { const oneSg = interval.signals(model, selCmpts['one'], []); expect(oneSg).toContainEqual({ name: 'one_tuple', - update: - 'vlSelectionTuples(intersect([[one_longitude_1[0], one_latitude_1[0]],[one_longitude_1[1], one_latitude_1[1]]], {markname: "marks"}, unit.mark), {unit: ""})' + on: [ + { + events: [{signal: 'one_longitude_1 || one_latitude_1'}], + update: + 'vlSelectionTuples(intersect([[one_longitude_1[0], one_latitude_1[0]],[one_longitude_1[1], one_latitude_1[1]]], {markname: "marks"}, unit.mark), {unit: ""})' + } + ] }); const twoSg = interval.signals(model, selCmpts['two'], []); expect(twoSg).toContainEqual({ name: 'two_tuple', - update: - 'vlSelectionTuples(intersect([[two_longitude_1[0], 0],[two_longitude_1[1], height]], {markname: "marks"}, unit.mark), {unit: ""})' + on: [ + { + events: [{signal: 'two_longitude_1'}], + update: + 'vlSelectionTuples(intersect([[two_longitude_1[0], 0],[two_longitude_1[1], height]], {markname: "marks"}, unit.mark), {unit: ""})' + } + ] }); const threeSg = interval.signals(model, selCmpts['three'], []); @@ -1030,8 +1040,7 @@ describe('Interval Selections', () => { 'vlSelectionTuples(intersect([[three_longitude_1[0], three_latitude_1[0]],[three_longitude_1[1], three_latitude_1[1]]], {markname: "marks"}, unit.mark), {unit: ""})'; expect(threeSg).toContainEqual({ name: 'three_tuple', - update, - on: [{events: {signal: GEO_INIT_TICK}, update}] + on: [{events: [{signal: 'three_latitude_1 || three_longitude_1'}, {signal: GEO_INIT_TICK}], update}] }); const fourSg = interval.signals(model, selCmpts['four'], []); @@ -1039,8 +1048,7 @@ describe('Interval Selections', () => { 'vlSelectionTuples(intersect([[0, four_latitude_1[0]],[width, four_latitude_1[1]]], {markname: "marks"}, unit.mark), {unit: ""})'; expect(fourSg).toContainEqual({ name: 'four_tuple', - update, - on: [{events: {signal: GEO_INIT_TICK}, update}] + on: [{events: [{signal: 'four_latitude_1'}, {signal: GEO_INIT_TICK}], update}] }); }); });