Skip to content

Commit

Permalink
fix: Fix SVG data lookup to support series.
Browse files Browse the repository at this point in the history
  • Loading branch information
jheer committed May 31, 2024
1 parent 353f318 commit ca3f23d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/plot/src/interactors/Highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export class Highlight {
for (let i = 0; i < nodes.length; ++i) {
const node = nodes[i];
const base = values[i];
const t = test(node.__data__);
const data = node.__data__;
const t = test(Array.isArray(data) ? data[0] : data);
// TODO? handle inherited values / remove attributes
for (let j = 0; j < channels.length; ++j) {
const [attr, value] = channels[j];
Expand All @@ -91,9 +92,11 @@ async function predicateFunction(mark, selection) {

const s = { __: and(pred) };
const q = mark.query(filter);
const p = q.groupby().length ? q.select(s) : q.$select(s);
(q.queries || [q]).forEach(q => {
q.groupby().length ? q.select(s) : q.$select(s);
});

const data = await mark.coordinator.query(p);
const data = await mark.coordinator.query(q);
const v = data.getChild?.('__');
return !(data.numRows || data.length) ? (() => false)
: v ? (i => v.get(i))
Expand Down
5 changes: 4 additions & 1 deletion packages/plot/src/interactors/Toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class Toggle {
init(svg, selector, accessor) {
const { mark, as, selection } = this;
const { data: { columns = {} } = {} } = mark;
accessor ??= target => as.map(name => columns[name][target.__data__]);
accessor ??= target => as.map(name => {
const data = target.__data__;
return columns[name][Array.isArray(data) ? data[0] : data];
});
selector ??= `[data-index="${mark.index}"]`;
const groups = new Set(svg.querySelectorAll(selector));

Expand Down

0 comments on commit ca3f23d

Please sign in to comment.