diff --git a/src/compile/mark/mark.ts b/src/compile/mark/mark.ts index 74e241b4ff..aa6e69c60f 100644 --- a/src/compile/mark/mark.ts +++ b/src/compile/mark/mark.ts @@ -313,6 +313,21 @@ function getMarkGroup(model: UnitModel, opt: {fromPrefix: string} = {fromPrefix: const key = encoding.key; const sort = getSort(model); const interactive = interactiveFlag(model); + + let isPoint = false; + let isBind = false; + if (model.component.selection) { + for (const k of keys(model.component.selection)) { + if (model.component.selection[k].bind) { + isBind = true; + } + if (model.component.selection[k].type == 'point') { + isPoint = true; + } + } + } + interactive && isPoint && !isBind ? (model.markDef.cursor ??= 'pointer') : {}; + const aria = getMarkPropOrConfig('aria', markDef, config); const postEncodingTransform = markCompiler[mark].postEncodingTransform diff --git a/test/compile/compile.test.ts b/test/compile/compile.test.ts index e4667bdc07..e589bd0ebd 100644 --- a/test/compile/compile.test.ts +++ b/test/compile/compile.test.ts @@ -573,3 +573,55 @@ describe('compile/compile', () => { expect(spec.autosize['resize']).toBeTruthy(); }); }); + +it('should generate right cursor for point selection', () => { + const {spec} = compile({ + data: {url: 'data/population.json'}, + params: [{name: 'select', select: 'point'}], + mark: 'bar', + encoding: { + x: {field: 'a', type: 'ordinal'}, + y: {field: 'b', type: 'quantitative'} + } + }); + + expect(spec.marks[0].encode.update.cursor).toEqual({value: 'pointer'}); +}); + +it('should not generate cursor for point selection with binding', () => { + const {spec} = compile({ + data: {url: 'data/population.json'}, + params: [ + { + name: 'highlight', + value: [{Cylinders: 4, Year: 1977}], + select: {type: 'point', fields: ['Cylinders', 'Year']}, + bind: { + Cylinders: {input: 'range', min: 3, max: 8, step: 1}, + Year: {input: 'range', min: 1969, max: 1981, step: 1} + } + } + ], + mark: 'bar', + encoding: { + x: {field: 'a', type: 'ordinal'}, + y: {field: 'b', type: 'quantitative'} + } + }); + + expect(spec.marks[0].encode.update.cursor).toBeUndefined(); +}); + +it('should not generate cursor for interval selection', () => { + const {spec} = compile({ + data: {url: 'data/population.json'}, + params: [{name: 'brush', select: {type: 'interval', encodings: ['x']}}], + mark: 'bar', + encoding: { + x: {field: 'a', type: 'ordinal'}, + y: {field: 'b', type: 'quantitative'} + } + }); + + expect(spec.marks[0].encode.update.cursor).toBeUndefined(); +});