77 lines
1.6 KiB
TypeScript
77 lines
1.6 KiB
TypeScript
import { defineComponent, h, PropType } from 'vue';
|
|
|
|
import { Line } from 'vue-chartjs';
|
|
import {
|
|
Chart as ChartJS,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
LineElement,
|
|
LinearScale,
|
|
PointElement,
|
|
CategoryScale,
|
|
Plugin,
|
|
} from 'chart.js';
|
|
|
|
ChartJS.register(
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
LineElement,
|
|
LinearScale,
|
|
PointElement,
|
|
CategoryScale
|
|
);
|
|
|
|
export default defineComponent({
|
|
name: 'LineChart',
|
|
components: {
|
|
Line,
|
|
},
|
|
props: {
|
|
chartId: {
|
|
type: String,
|
|
default: 'line-chart',
|
|
},
|
|
chartData: {
|
|
type: Object,
|
|
},
|
|
chartOptions: {
|
|
type: Object,
|
|
},
|
|
width: {
|
|
type: Number,
|
|
default: 400,
|
|
},
|
|
height: {
|
|
type: Number,
|
|
default: 400,
|
|
},
|
|
cssClasses: {
|
|
default: '',
|
|
type: String,
|
|
},
|
|
styles: {
|
|
type: Object as PropType<Partial<CSSStyleDeclaration>>,
|
|
default: () => {},
|
|
},
|
|
plugins: {
|
|
type: Array as PropType<Plugin<'line'>[]>,
|
|
default: () => [],
|
|
},
|
|
},
|
|
setup(props) {
|
|
return () =>
|
|
h(Line, {
|
|
chartData: props.chartData,
|
|
chartOptions: props.chartOptions,
|
|
chartId: props.chartId,
|
|
width: props.width,
|
|
height: props.height,
|
|
cssClasses: props.cssClasses,
|
|
styles: props.styles,
|
|
plugins: props.plugins,
|
|
});
|
|
},
|
|
});
|