mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 06:21:05 +03:30
51 lines
1.1 KiB
Vue
51 lines
1.1 KiB
Vue
<template>
|
|
<div class="small">
|
|
<pie-chart :chart-data="datacollection"></pie-chart>
|
|
<bar-chart :chart-data="datacollection"></bar-chart>
|
|
<button @click="fillData()">Randomize</button>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import BarChart from '@/plugins/chart/BarChart.js'
|
|
import PieChart from '@/plugins/chart/PieChart.js'
|
|
|
|
export default {
|
|
components: {
|
|
BarChart,
|
|
PieChart
|
|
},
|
|
data () {
|
|
return {
|
|
datacollection: null
|
|
}
|
|
},
|
|
mounted () {
|
|
this.fillData()
|
|
},
|
|
methods: {
|
|
fillData () {
|
|
this.datacollection = {
|
|
labels: [this.getRandomInt(), this.getRandomInt()],
|
|
datasets: [
|
|
{
|
|
label: 'Data One',
|
|
backgroundColor: ['#f87979', '#ccc'],
|
|
data: [this.getRandomInt(), this.getRandomInt()]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
getRandomInt () {
|
|
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.small {
|
|
max-width: 600px;
|
|
margin: 150px auto;
|
|
}
|
|
</style> |