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

Export the vega API #39

Open
pschmiedel opened this issue Nov 8, 2017 · 4 comments
Open

Export the vega API #39

pschmiedel opened this issue Nov 8, 2017 · 4 comments

Comments

@pschmiedel
Copy link

Currently, it is not possible to call vega APIs directly (e.g. vega.scheme) when using the minified version of vue-vega. Simply importing from vega and calling the API has no effect, since it is a different file (from node_modules/vega* instead of the minified file) with a different scope.

This could probably be remedied by something like this (in index.js):

export * from 'vega'

That way we could use the following to access the API in the same scope:

import { scheme } from 'vue-vega'
scheme('my-scheme', [ ... ])

Alternatively, something like this could be used:

import * as vega from 'vega'
export { vega }
import { vega } from 'vue-vega'
vega.scheme('my-scheme', [ ... ])
@nesterone
Copy link
Owner

nesterone commented Nov 11, 2017

Hi, @pschmiedel

Could you make it more clear on which API methods you not able to use?

vue-vega is just an adapter around vega View

Right now I expose only one default object with install, mapVegaLiteSpec, and VueVegaLiteComponent, however, in near future, I want to leave only vue plugin as default object and other entities would go as ordinary exports

Meanwhile I have a #6, to exclude vega and vega-lite from budle

@pschmiedel
Copy link
Author

As I wrote above, e.g. vega.scheme. Another one would be the Locale API. It's not possible because there is no way to get to the same "vega object" instance (more accurately, the vega scope) that is used in your bundled code. Anyway, I'm using the default vega-embed package now, which seems to work fine.

@nesterone
Copy link
Owner

nesterone commented Nov 11, 2017

I see, few questions if you don't mind ;)

Did you use vega embedded with some vue component wrapper?

I didn't touch vega schemas and other global vega configs yet, however as potential library consumer what do you think about next approach ?

import Vue fron 'vue'
import vega from 'vega'
import VueVega from 'vue-vega'

// vega global configs 
vega.scheme({/* collor here */})

Vue.use(VueVega, { vega })

@pschmiedel
Copy link
Author

No, I just used vega-embed without any vue wrapper.

Your approach could work however there are the following issues:

  • it means the vega library is potentially included twice in the output generated by e.g. weback (once from vue-vega.min.js and once from node_modules/vega)
  • it allows using a different version of vega than the one bundled with vue-vega (potential version conflict)
  • it is one more import statement than simply import { default as VueVega, vega } from 'vue-vega'

Btw vega-embed does in fact export the imported vega object again.

@nesterone nesterone mentioned this issue Dec 9, 2018
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

No branches or pull requests

2 participants