Skip to content
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

Extensions for vgplot #409

Closed
domoritz opened this issue May 29, 2024 · 1 comment
Closed

Extensions for vgplot #409

domoritz opened this issue May 29, 2024 · 1 comment
Labels
projects Project ideas for Mosaic

Comments

@domoritz
Copy link
Member

People may want to add new clients like charts or widgets to vgplot or even override the built-in clients like the table. It would be nice if there was a way to register new clients that can be used in the spec.

A possible API would be to register a new client could be this:

import { registerClient } from "@uwdata/vgplot";

registerClient("foo", CustomClient);
{
  "hconcat: [
    { "foo": { x: "x", y: "y", table: "table", filter: "$filter" } }
  ]
}

One tricky thing will be to provide some way to extend the TS types for spec with a new client.

@jheer
Copy link
Member

jheer commented May 29, 2024

The vgplot API already supports extensions and overrides. One can use new clients directly by creating their own directive methods, and they can add them to a vg API instance by passing them to the createAPIContext method.

The spec parser is also extensible, as one can specify component parsers via ParseContext's component option. Still, one needs to provide a proper parse function that returns compatible AST nodes.

That said, we need better documentation for this, maybe as part of #394.

How best to extend the TS types remains an open question.

@jheer jheer closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
projects Project ideas for Mosaic
Projects
None yet
Development

No branches or pull requests

2 participants