Supporting plugins
You can use defineChartComponent
to create ChartJs plugins components
Example:
import { Chart, registerables } from 'chart.js';
import { defineChartComponent } from 'vue-chart-3';
import { MatrixController, MatrixElement } from 'chartjs-chart-matrix';
Chart.register(MatrixController, MatrixElement, ...registerables);
const Matrix = defineChartComponent('MatrixChart', 'matrix');
// You can now use this component anywhere
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
If you are using Typescript, you have to augment the interface ChartTypeRegistry
from chart.js
manually.
The plugins for Chart.js are usually typed, but if they aren't you can do it manually
(Example taken from chartjs-chart-matrix)
declare module 'chart.js' {
export interface ChartTypeRegistry {
matrix: {
chartOptions: CoreChartOptions<'matrix'>;
datasetOptions: MatrixControllerDatasetOptions<'matrix'>;
defaultDataPoint: MatrixDataPoint;
parsedDataType: MatrixDataPoint;
scales: never;
};
}
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11