tl;dr -- megaPlot should log a warning to the console any time two successive calls to Selection.bind() overwrite each other in the scheduler before the former call to .bind() starts work.
Background
In LIT, I'm using multiple Selections to act as proxies for layers in the Scene. One of these Selections is always bound to the entire dataset, and the other Selections are bound to com subset of the dataset (not that it matters for this issue, but one Selection can contain [0, N] datums and the other 3 can contain [0, 1] datums). For the Selections containing subsets, I assumed that calling .bind() with an empty array would mark all existing datums (and their associated Sprites) for removal from the Scene, effectively clearing the Selection and allowing me to make a successive call to .bind() with the new contents that would render the data I now cared about in the Scene. Some example code below.
const data = [/* let's assume this is populated */];
const container = document.querySelector('some_query');
const scene = new Scene({container});
const allData = scene.createSelection();
const someData = scene.createSelection();
allData.bind(data);
function update(someSentinel) {
someData.bind([]);
const interestingData = data.filter(d => /* some predicate */);
someData.bind(interestingData);
}
This assumption was incorrect because of how the Selection.bind() uniquely identifies binding tasks. Calls to .bind() are transformed into bindingTasks that are uniquely identified by the Selection on which .bind() is being called. In the example above, the successive calls to .bind()effectively overwrite each other in the scheduler because they process before the next animation frame happens.
Desired Solution
It would be useful if MegaPlot could console.warn() when two successive calls to .bind() overwrite each other in the scheduler if the existing .bind() call has not yet started doing work. This would have made the behavior described above much easier to identify and mitigate.
tl;dr -- megaPlot should log a warning to the console any time two successive calls to
Selection.bind()
overwrite each other in the scheduler before the former call to.bind()
starts work.Background
In LIT, I'm using multiple
Selection
s to act as proxies for layers in theScene
. One of theseSelection
s is always bound to the entire dataset, and the otherSelection
s are bound to com subset of the dataset (not that it matters for this issue, but one Selection can contain [0, N] datums and the other 3 can contain [0, 1] datums). For theSelection
s containing subsets, I assumed that calling.bind()
with an empty array would mark all existing datums (and their associated Sprites) for removal from theScene
, effectively clearing theSelection
and allowing me to make a successive call to.bind()
with the new contents that would render the data I now cared about in theScene
. Some example code below.This assumption was incorrect because of how the
Selection.bind()
uniquely identifies binding tasks. Calls to.bind()
are transformed intobindingTask
s that are uniquely identified by theSelection
on which.bind()
is being called. In the example above, the successive calls to.bind()
effectively overwrite each other in the scheduler because they process before the next animation frame happens.Desired Solution
It would be useful if MegaPlot could
console.warn()
when two successive calls to.bind()
overwrite each other in the scheduler if the existing.bind()
call has not yet started doing work. This would have made the behavior described above much easier to identify and mitigate.