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

Expose an API #460

Open
davidanthoff opened this issue Mar 14, 2020 · 1 comment
Open

Expose an API #460

davidanthoff opened this issue Mar 14, 2020 · 1 comment

Comments

@davidanthoff
Copy link

Is there a way to easily add a new dataset via code? For example, in voyager, I can run voyagerInstance.updateData(data) as JavaScript to update the data source.

Can I do something similar here, i.e. something like lyraInstance.addDataset(data), where data would just be inline data values in the format that vega accepts?

Something like store.dispatch(addDataset(...)) ? But I'm not sure what to pass to addDataset. Or am I on a wrong track entirely here?

Other APIs that would be nice to have are: a) a way to extract the current spec (i.e. lyraInstance.getCurrentSpec()) as a vega spec (I think this is all based on vega, right?). And maybe b) can one load a vega spec into lyra? The latter is a little less crucial for what I hope to do.

@davidanthoff
Copy link
Author

For now I added

(global as any).addData = (name: string, data: string) => {
  const parsed = dsUtils.parseRaw(data);

  const values = parsed.values;

  const pipeline = Pipeline({name});

  const ds = Dataset({
        name: name,
        format: parsed.format,
        _schema: dsUtils.schema(values)
      });

  addPipeline(pipeline, ds, values)(store.dispatch);
}

(global as any).getVegaSpec = () => {
  return ctrl.export()
}

to index.ts and that essentially is all I need.

Could something like that be added to the repo here?

There is one twist: instead of passing data as string it would probably make more sense if I could pass it directly as a list of objects, i.e. if I could pass something that is already parsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants