Skip to content

prototype channel alias #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

prototype channel alias #719

wants to merge 1 commit into from

Conversation

mbostock
Copy link
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
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
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