adding vue component

This commit is contained in:
Lucas Silva 2023-05-05 10:23:06 +02:00
parent 6028efdc7c
commit 191b416c6c
3 changed files with 76 additions and 9 deletions

View File

@ -31,7 +31,9 @@
"typescript": "^4.7.2", "typescript": "^4.7.2",
"vue-loader": "^17.0.0", "vue-loader": "^17.0.0",
"webpack": "^5.75.0", "webpack": "^5.75.0",
"webpack-cli": "^5.0.1" "webpack-cli": "^5.0.1",
"chart.js": "^4.2.1",
"vue-chartjs": "^5.2.0"
}, },
"dependencies": { "dependencies": {
"@fullcalendar/core": "^6.1.4", "@fullcalendar/core": "^6.1.4",

View File

@ -1,7 +1,7 @@
<template> <template>
<span v-if="noResults" class="chill-no-data-statement">{{ $t('no_dashboard') }}</span> <span v-if="noResults" class="chill-no-data-statement">{{ $t('no_dashboard') }}</span>
<div v-else id="dashboards" class="row g-3" data-masonry='{"percentPosition": true }'> <div v-else id="dashboards" class="row g-3" data-masonry='{"percentPosition": true }'>
<div class="mbloc col col-sm-6 col-lg-4"> <div class="mbloc col col-sm-6 col-lg-4">
<div class="custom1"> <div class="custom1">
<ul class="list-unstyled"> <ul class="list-unstyled">
@ -38,8 +38,11 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="mbloc col col-sm-6 col-lg-4">
<!-- <div class="custom2">
<MyWidget :chart-data="chartData" />
</div>
</div>
<div class="mbloc col col-sm-6 col-lg-4"> <div class="mbloc col col-sm-6 col-lg-4">
<div class="custom2"> <div class="custom2">
Mon dashboard personnalisé Mon dashboard personnalisé
@ -55,22 +58,29 @@
Mon dashboard personnalisé Mon dashboard personnalisé
</div> </div>
</div> </div>
-->
</div> </div>
</template> </template>
<script> <script>
import MyWidget from './MyWidget.vue'
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import Masonry from 'masonry-layout/masonry'; import Masonry from 'masonry-layout/masonry';
export default { export default {
name: "MyCustoms", name: "MyCustoms",
components:{
MyWidget
},
data() { data() {
return { return {
counterClass: { counterClass: {
counter: true //hack to pass class 'counter' in i18n-t counter: true //hack to pass class 'counter' in i18n-t
} },
chartData: null,
} }
}, },
computed: { computed: {
@ -82,8 +92,20 @@ export default {
mounted() { mounted() {
const elem = document.querySelector('#dashboards'); const elem = document.querySelector('#dashboards');
const masonry = new Masonry(elem, {}); const masonry = new Masonry(elem, {});
} this.chartData = {
} labels: ['Label 1', 'Label 2', 'Label 3'],
datasets: [
{
label: 'Dataset 1',
data: [10, 20, 30],
backgroundColor: ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)'],
borderColor: ['rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)'],
borderWidth: 1,
},
],
};
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -98,4 +120,4 @@ span.counter {
background-color: unset; background-color: unset;
} }
} }
</style> </style>

View File

@ -0,0 +1,43 @@
<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>