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
66
67
| <template>
| <div class="dashboard-container">
| <div :id="data.value" style="height: 260px; width: 100%"></div>
| </div>
| </template>
|
| <script>
| import * as echarts from "echarts";
|
| export default {
| name: "Chart",
| props:{
| data: {
| type: Object,
| }
| },
| mounted() {
| this.loadEcharts();
| },
| methods: {
| //加载echarts
| loadEcharts() {
| // 基于准备好的dom,初始化echarts实例
| var myChart = echarts.init(document.getElementById(this.data.value));
| // 绘制图表
| myChart.setOption({
| title: {
| text: this.data.lable,
| },
| xAxis: {
| type: "category",
| data: [
| "8月4号",
| "8月4号",
| "8月4号",
| "8月4号",
| "8月4号",
| "8月4号",
| "8月4号",
| ],
| },
| yAxis: {
| type: "value",
| },
| series: [
| {
| data: [150, 230, 224, 218, 135, 147, 260],
| type: "line",
| },
| ],
| });
| },
| },
| };
| </script>
|
| <style lang="scss" scoped>
| .dashboard {
| &-container {
| margin: 30px;
| }
| &-text {
| font-size: 30px;
| line-height: 46px;
| }
| }
| </style>
|
|