Skip to content

prototype channel alias#719

Closed
mbostock wants to merge 1 commit into
mainfrom
mbostock/channel-alias
Closed

prototype channel alias#719
mbostock wants to merge 1 commit into
mainfrom
mbostock/channel-alias

Conversation

@mbostock
Copy link
Copy Markdown
Member

This is a quick sketch at allowing channels to be shared across marks as mentioned in #708 (comment). We should think through the syntax and the semantics a bit more.

@Fil
Copy link
Copy Markdown
Contributor

Fil commented Jan 29, 2022

I made this helper to allow inlining the functionality:

combine = (data, ...rest) => {
  const known = new Map();
  return Array.from(rest, ({ mark, ...options }) => {
    for (let k in options) {
      if (known.has(k)) options[k] = { alias: known.get(k) };
    }
    const m = mark(data, options);
    for (let k in options) {
      if (!known.has(k)) known.set(k, m);
    }
    return m;
  });
}

and the mark becomes:

marks: [
 combine(
  data,
  { mark: Plot.dot, x: "bill_length", y: "body_mass", symbol: "species" },
  { mark: Plot.text, x: "bill_length", y: "body_mass", text: "sex" }
 )
]

@mbostock
Copy link
Copy Markdown
Member Author

mbostock commented Mar 7, 2022

Superseded by #798.

@mbostock mbostock closed this Mar 7, 2022
@mbostock mbostock deleted the mbostock/channel-alias branch March 7, 2022 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants