mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
44 lines
847 B
Vue
44 lines
847 B
Vue
<template>
|
|
<div>
|
|
<canvas ref="chartCanvas"></canvas>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
Chart as ChartJS,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
BarElement,
|
|
CategoryScale,
|
|
LinearScale
|
|
} from 'chart.js'
|
|
import { Bar } from 'vue-chartjs'
|
|
ChartJS.register(Title, Tooltip,Legend, BarElement, CategoryScale, LinearScale)
|
|
|
|
export default {
|
|
props: ['chartData'],
|
|
mounted(){
|
|
this.renderChart();
|
|
},
|
|
methods: {
|
|
renderChart() {
|
|
const ctx = this.$refs.chartCanvas.getContext('2d');
|
|
new ChartJS(ctx, {
|
|
type: 'bar',
|
|
data: this.chartData,
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: true
|
|
|
|
},
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
|
|
</style>
|