chartjs / chartjs-plugin-datalabels

Chart.js plugin to display labels on data elements
https://chartjs-plugin-datalabels.netlify.app
MIT License
863 stars 460 forks source link

Lazy loading the plugin nested in Vue 3 Script setup #336

Open CasperNH opened 1 year ago

CasperNH commented 1 year ago

I am trying to lazyload this plugin into my Vue3 script setup, like this:

const Vue3ChartJs = defineAsyncComponent(() => import('@j-t-mcc/vue3-chartjs'));
const ChartJsPluginDataLabels= defineAsyncComponent(() => import('chartjs-plugin-datalabels'));

The problem is that it that the datalabels plugin requires the chartjs to be there. Can you tell me how to load the label plugin after the load of the chartjs?

I could imagine something nested like:

const Vue3ChartJs = defineAsyncComponent(() => import("@j-t-mcc/vue3-chartjs").then(() => 
const ChartJsPluginDataLabels= defineAsyncComponent(() => import('chartjs-plugin-datalabels'));
));