-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize selection functions for ID-only stores.
- Loading branch information
Showing
5 changed files
with
63 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import {field} from 'vega-util'; | ||
|
||
export const Intersect = 'intersect'; | ||
export const Union = 'union'; | ||
export const VlMulti = 'vlMulti'; | ||
export const VlPoint = 'vlPoint'; | ||
export const Or = 'or'; | ||
export const And = 'and'; | ||
|
||
export const SelectionId = '_vgsid_'; | ||
export const $selectionId = field(SelectionId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import {extend, field} from 'vega-util'; | ||
import {$selectionId, SelectionId} from './constants'; | ||
|
||
/** | ||
* Maps an array of scene graph items to an array of selection tuples. | ||
* @param {string} name - The name of the dataset representing the selection. | ||
* @param {string} unit - The name of the unit view. | ||
* @param {string} base - The base object that generated tuples extend. | ||
* | ||
* @returns {array} An array of selection entries for the given unit. | ||
*/ | ||
export function selectionTuples(array, base) { | ||
return array.map(x => extend({ | ||
values: base.fields.map(f => (f.getter || (f.getter = field(f.field)))(x.datum)) | ||
}, base)); | ||
return array.map(x => extend( | ||
base.fields ? { | ||
values: base.fields.map(f => (f.getter || (f.getter = field(f.field)))(x.datum)) | ||
} : { | ||
[SelectionId]: $selectionId(x.datum) | ||
}, base)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters