许成详 6 年前
父节点
当前提交
b7c1c0d7d7

+ 66
- 0
src/components/brokenLineGraphGroup/index.vue 查看文件

@@ -0,0 +1,66 @@
1
+<template>
2
+  <div class="component">
3
+    <h6 class="title">{{data.title}}</h6>
4
+    <div :id="'brokenLineGraphGroup' + index" ref="box"></div>
5
+  </div>
6
+</template>
7
+
8
+<script>
9
+import G2 from '@antv/g2'
10
+
11
+export default {
12
+  name: '',
13
+  props: ['data', 'index'],
14
+  data () {
15
+    return {
16
+    }
17
+  },
18
+  components: {
19
+    G2,
20
+  },
21
+  mounted () {
22
+    this.$nextTick(function () {
23
+      this.init()
24
+    })
25
+  },
26
+  methods: {
27
+    init () {
28
+      var _that = this
29
+      var chart = new G2.Chart({
30
+        container: 'brokenLineGraphGroup' + _that.index,
31
+        forceFit: true,
32
+        width: _that.$refs.box.clientWidth,
33
+        height: 400,
34
+      })
35
+      chart.source(_that.data.list, {
36
+        month: {
37
+          range: [0, 1]
38
+        }
39
+      })
40
+      chart.tooltip({
41
+        crosshairs: {
42
+          type: 'line'
43
+        }
44
+      })
45
+      chart.axis('temperature', {
46
+        label: {
47
+          formatter: function formatter (val) {
48
+            return val + '°C'
49
+          }
50
+        }
51
+      })
52
+      chart.line().position('month*temperature').color('city')
53
+      chart.point().position('month*temperature').color('city').size(4).shape('circle').style({
54
+        stroke: '#fff',
55
+        lineWidth: 1
56
+      })
57
+      chart.render()
58
+    },
59
+  }
60
+}
61
+</script>
62
+
63
+<!-- Add "scoped" attribute to limit CSS to this component only -->
64
+<style lang="scss" scoped>
65
+@import "page.scss";
66
+</style>

+ 0
- 0
src/components/brokenLineGraphGroup/page.scss 查看文件


+ 8
- 0
src/pages/system/dashboard/index.vue 查看文件

@@ -30,6 +30,9 @@
30 30
         <div v-if="subItem.type === 'dashboard'">
31 31
           <dashboard :data="subItem.data" :index="index + '-' + subIndex"></dashboard>
32 32
         </div>
33
+        <div v-if="subItem.type === 'brokenLineGraphGroup'">
34
+          <brokenLineGraphGroup :data="subItem.data" :index="index + '-' + subIndex"></brokenLineGraphGroup>
35
+        </div>
33 36
       </div>
34 37
     </div>
35 38
   </div>
@@ -43,6 +46,7 @@ import pieDiagram from '../../../components/pieDiagram/index'
43 46
 import brokenLineGraph from '../../../components/brokenLineGraph/index'
44 47
 import ringChart from '../../../components/ringChart/index'
45 48
 import dashboard from '../../../components/dashboard/index'
49
+import brokenLineGraphGroup from '../../../components/brokenLineGraphGroup/index'
46 50
 
47 51
 export default {
48 52
   name: '',
@@ -67,6 +71,9 @@ export default {
67 71
           { type: 'dashboard', remark: '仪表盘', data: { title: '参与率', list: [{ value: 5.6 }] } },
68 72
           { type: 'dashboard', remark: '仪表盘', data: { title: '参与率', list: [{ value: 3.1 }] } },
69 73
         ],
74
+        [
75
+          { type: 'brokenLineGraphGroup', remark: '折线图组合', data: { title: '下单饮品数据', list: [{ month: 'Jan', city: 'Tokyo', temperature: 7 }, { month: 'Jan', city: 'London', temperature: 3.9 }, { month: 'Feb', city: 'Tokyo', temperature: 6.9 }, { month: 'Feb', city: 'London', temperature: 4.2 }, { month: 'Mar', city: 'Tokyo', temperature: 9.5 }, { month: 'Mar', city: 'London', temperature: 5.7 }, { month: 'Apr', city: 'Tokyo', temperature: 14.5 }, { month: 'Apr', city: 'London', temperature: 8.5 }, { month: 'May', city: 'Tokyo', temperature: 18.4 }, { month: 'May', city: 'London', temperature: 11.9 }, { month: 'Jun', city: 'Tokyo', temperature: 21.5 }, { month: 'Jun', city: 'London', temperature: 15.2 }, { month: 'Jul', city: 'Tokyo', temperature: 25.2 }, { month: 'Jul', city: 'London', temperature: 17 }, { month: 'Aug', city: 'Tokyo', temperature: 26.5 }, { month: 'Aug', city: 'London', temperature: 16.6 }, { month: 'Sep', city: 'Tokyo', temperature: 23.3 }, { month: 'Sep', city: 'London', temperature: 14.2 }, { month: 'Oct', city: 'Tokyo', temperature: 18.3 }, { month: 'Oct', city: 'London', temperature: 10.3 }, { month: 'Nov', city: 'Tokyo', temperature: 13.9 }, { month: 'Nov', city: 'London', temperature: 6.6 }, { month: 'Dec', city: 'Tokyo', temperature: 9.6 }, { month: 'Dec', city: 'London', temperature: 4.8 }] } },
76
+        ],
70 77
       ],
71 78
     }
72 79
   },
@@ -77,6 +84,7 @@ export default {
77 84
     brokenLineGraph,
78 85
     ringChart,
79 86
     dashboard,
87
+    brokenLineGraphGroup,
80 88
   },
81 89
   computed: {
82 90
     ...mapState({