<template>
    <widget-card :bodyStyle="bodyStyle" ref="container">
        <canvas ref="chart" class="chart"></canvas>
    </widget-card>
</template>
<script>
import WidgetCard from './WidgetCard';
import VueCharts from 'vue-chartjs';

export default {
    data() {
        return {
            myChart: null,
            bodyStyle: {
                display: 'flex',
                alignItems: 'center'
            }
        };
    },
    mounted() {
        this.$refs.chart.width = this.$refs.container.$el.offsetWidth - 20;
        this.$refs.chart.height = this.$refs.container.$el.offsetHeight - 20;
        this.myChart = new Chart(this.$refs.chart.getContext('2d'), {
            type: 'pie',
            data: {
                labels: ['美术', '音乐', '舞蹈', '戏曲', '曲艺'],
                datasets: [
                    {
                        backgroundColor: ['#41B883', '#E46651', '#00D8FF', '#DD1B16', '#E6A23C'],
                        data: [40, 20, 60, 10, 5]
                    }
                ]
            },
            options: { responsive: true, maintainAspectRatio: false }
        });
    },
    components: {
        WidgetCard
    }
};
</script>
<style lang="less" scoped></style>
