|
|
@@ -1,5 +1,8 @@
|
|
|
<template>
|
|
|
<widget-card :bodyStyle="bodyStyle" ref="container">
|
|
|
+ <template #header>
|
|
|
+ 数据统计
|
|
|
+ </template>
|
|
|
<canvas ref="chart" class="chart"></canvas>
|
|
|
</widget-card>
|
|
|
</template>
|
|
|
@@ -18,27 +21,31 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.$refs.chart.width = this.$refs.container.$el.offsetWidth - 20;
|
|
|
- this.$refs.chart.height = this.$refs.container.$el.offsetHeight - 20;
|
|
|
- var gradient = this.$refs.chart.getContext('2d').createLinearGradient(0, 0, 0, 200);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.chart.width = this.$refs.container.$el.offsetWidth - 20;
|
|
|
+ this.$refs.chart.height = this.$refs.container.$el.offsetHeight - 90;
|
|
|
+ var gradient = this.$refs.chart
|
|
|
+ .getContext('2d')
|
|
|
+ .createLinearGradient(0, 0, 0, this.$refs.container.$el.offsetHeight - 100);
|
|
|
|
|
|
- gradient.addColorStop(0, 'rgba(32,160,255,0.7)');
|
|
|
- gradient.addColorStop(1, 'rgba(32,160,255,0)');
|
|
|
- this.myChart = new Chart(this.$refs.chart.getContext('2d'), {
|
|
|
- type: 'line',
|
|
|
- data: {
|
|
|
- labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
|
- datasets: [
|
|
|
- {
|
|
|
- label: 'Data One',
|
|
|
- backgroundColor: gradient,
|
|
|
- borderColor: '#20a0ff',
|
|
|
- borderWidth: '1px',
|
|
|
- data: [40, 39, 10, 40, 39, 80, 40]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- options: { responsive: true, maintainAspectRatio: false }
|
|
|
+ gradient.addColorStop(0, 'rgba(32,160,255,0.7)');
|
|
|
+ gradient.addColorStop(1, 'rgba(32,160,255,0)');
|
|
|
+ this.myChart = new Chart(this.$refs.chart.getContext('2d'), {
|
|
|
+ type: 'line',
|
|
|
+ data: {
|
|
|
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
|
+ datasets: [
|
|
|
+ {
|
|
|
+ label: 'Data One',
|
|
|
+ backgroundColor: gradient,
|
|
|
+ borderColor: '#20a0ff',
|
|
|
+ borderWidth: '1px',
|
|
|
+ data: [40, 39, 10, 40, 39, 80, 40]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ options: { responsive: true, maintainAspectRatio: false }
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
components: {
|