sgratzl / chartjs-chart-boxplot

Chart.js Box Plots and Violin Plot Charts
https://www.sgratzl.com/chartjs-chart-boxplot/
MIT License
107 stars 24 forks source link

Error: "boxplot" is not a registered controller when using plugin with PrimeVue Charts #92

Closed movy closed 10 months ago

movy commented 10 months ago

"@sgratzl/chartjs-chart-boxplot": "^4.2.7"

I've read other issues with this error, but still cannot understand how to properly init BoxPlot plugin when Chart.register() is not exposed.

Their canonical way to attach plugins is:

  <Chart
    :data="boxplotData" 
    :options="{ responsive: true }"
    :plugins="[BoxPlotChart]" 
  />

And it seem to work with other plugins, but not with BoxPlot.

Full repro: https://stackblitz.com/edit/mgfvrw-3xiqfx?file=src%2FApp.vue

(the page is empty as it fails at setup stage, please see console for errors)

I ended up using vue-chartjs: "^5.2.0" for charts only, so in general this plugin works fine within vue, but only with .register() method.

As it's not clear whether it's a bug or usage specifics, so I crossposted it their repo also: https://github.com/orgs/primefaces/discussions/187#discussioncomment-7510393

Thanks heaps for the plugin! Very useful.

sgratzl commented 10 months ago

this chart js extension is not a plugin it but a handful of components that need to be registered if used in ESM module .

i..e

import { Chart, LinearScale, CategoryScale } from 'chart.js';
import { BoxPlotController, BoxAndWiskers } from '@sgratzl/chartjs-chart-boxplot';

// register controller in chart.js and ensure the defaults are set
Chart.register(BoxPlotController, BoxAndWiskers, LinearScale, CategoryScale);
movy commented 10 months ago

Yes, apparently PrimeVue chartjs component does not expose Chart.register() call, so I'll raise it with them.