-
Notifications
You must be signed in to change notification settings - Fork 3
generate dev environment, add <vue-vega> component, and add example #5
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
base: main
Are you sure you want to change the base?
Conversation
dev tooling was automatically generated using https://www.npmjs.com/package/vue-sfc-rollup
@jsbroks please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job
data: props.data, | ||
}; | ||
|
||
const { render, loading } = useVega(config as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to set the correct typing on the props with PropType
@@ -33,7 +33,7 @@ export function useVega(config: VueVegaConfig) { | |||
const { el, spec, data, embedOptions, signals, ...options } = configToRefs( | |||
config | |||
) | |||
const { embed, ...vegaEmbed } = useVegaEmbed(el, spec, embedOptions) | |||
const { embed, ...vegaEmbed } = useVegaEmbed(el, spec as any, embedOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the as any? We should reframe from using it when possible
@@ -45,7 +45,8 @@ export function useVega(config: VueVegaConfig) { | |||
if (output?.view != null) options?.onNewView?.(output.view) | |||
return output | |||
} catch (error) { | |||
options?.onError?.(error) | |||
console.log("error is ", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to remove console the log by default.
@@ -45,7 +45,8 @@ export function useVega(config: VueVegaConfig) { | |||
if (output?.view != null) options?.onNewView?.(output.view) | |||
return output | |||
} catch (error) { | |||
options?.onError?.(error) | |||
console.log("error is ", error); | |||
options?.onError?.(error as any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as any
?
@@ -55,7 +56,7 @@ export function useVega(config: VueVegaConfig) { | |||
const { modify } = vegaEmbed | |||
// Watchers that update vega in the most optimal way by either modifying or | |||
// re-rendering | |||
useVegaUpdater(spec, embedOptions, signals, data, render, modify) | |||
useVegaUpdater(spec as any, embedOptions, signals, data, render, modify) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as any
console.log("embed called") | ||
if (el.value == null) { | ||
console.log("its null") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console logs
Thank you for the comments. Will fix and update the PR. I have two rollup related questions I'm hoping someone can help with.
|
Alright, I've fixed the former issue with massive build sizes. Looks like the defaults from https://www.npmjs.com/package/vue-sfc-rollup weren't sane after all. I've removed the non-ESM builds as they were broken. |
I've gotten this closer to working but it is still somewhat broken. It looks like there is a fundamental issue using vue-demi for component libraries and there needs to be two versions of vue-vega - one for vue2 and one for vue3: vuejs/rollup-plugin-vue#427 |
I wont have time to work on this in the near future, but I did find an example project that is using Vue-Demi for a component library. If I or someone else picks this up, it's probably worth looking at: https://github.com/open-data-plan/g2plot-vue (see package.json and the scripts/postinstall.sh). This doesn't use rollup though. |
A few comments:
npm run serve
to see a working application that uses this library. It demoes the very basic component that I added on top of the existing composition API.TODOs:
any
to fix typing errors in the existing code. This needs to be fixed.