/
VaChart.vue
65 lines (60 loc) 路 1.15 KB
/
VaChart.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<template>
<component
ref="chart"
class='va-chart'
:is="chartComponent"
:options="options"
:chart-data="data"
/>
</template>
<script>
import PieChart from './chart-types/PieChart'
import BubbleChart from './chart-types/BubbleChart'
import DonutChart from './chart-types/DonutChart'
import HorizontalBarChart from './chart-types/HorizontalBarChart'
import VerticalBarChart from './chart-types/VerticalBarChart'
import LineChart from './chart-types/LineChart'
import { chartTypesMap } from './VaChartConfigs'
export default {
name: 'va-chart',
props: {
data: {},
options: {},
type: {
validator (type) {
return type in chartTypesMap
},
},
},
components: {
PieChart,
LineChart,
VerticalBarChart,
HorizontalBarChart,
DonutChart,
BubbleChart,
},
computed: {
chartComponent () {
return chartTypesMap[this.type]
},
},
}
</script>
<style lang='scss'>
.va-chart {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
> * {
height: 100%;
width: 100%;
}
canvas {
width: 100%;
height: auto;
}
}
</style>