许成详 6 anni fa
parent
commit
b23f60af2a

+ 61
- 0
src/components/brokenLineGraph/index.vue Vedi File

@@ -0,0 +1,61 @@
1
+<template>
2
+  <div class="component">
3
+    <h6 class="title">{{data.title}}</h6>
4
+    <div id="brokenLineGraph" 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'],
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: 'brokenLineGraph',
31
+        forceFit: true,
32
+        width: _that.$refs.box.clientWidth,
33
+        height: 400
34
+      })
35
+      chart.source(_that.data.list)
36
+      chart.scale('y', {
37
+        min: 0
38
+      })
39
+      chart.scale('x', {
40
+        range: [0, 1]
41
+      })
42
+      chart.tooltip({
43
+        crosshairs: {
44
+          type: 'line'
45
+        }
46
+      })
47
+      chart.line().position('x*y')
48
+      chart.point().position('x*y').size(4).shape('circle').style({
49
+        stroke: '#fff',
50
+        lineWidth: 1
51
+      })
52
+      chart.render()
53
+    },
54
+  }
55
+}
56
+</script>
57
+
58
+<!-- Add "scoped" attribute to limit CSS to this component only -->
59
+<style lang="scss" scoped>
60
+@import "page.scss"
61
+</style>

+ 28
- 0
src/components/brokenLineGraph/page.scss Vedi File

@@ -0,0 +1,28 @@
1
+
2
+.component{
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
+

+ 1
- 1
src/components/dashboardList/index.vue Vedi File

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div class="dashboardList">
3 3
     <ul class="flex-h">
4
-      <li class="flex-item" v-for="(item,index) in data" :key="index">
4
+      <li class="flex-item" v-for="(item,index) in data.list" :key="index">
5 5
         <div>
6 6
           <div class="centerLabel">
7 7
             <span>{{item.name}}</span>

+ 86
- 0
src/components/ringChart/index.vue Vedi File

@@ -0,0 +1,86 @@
1
+<template>
2
+  <div class="component">
3
+    <h6 class="title">{{data.title}}</h6>
4
+    <div id="ringChart" 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'],
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: 'ringChart',
31
+        forceFit: true,
32
+        width: _that.$refs.box.clientWidth,
33
+        height: 400
34
+      })
35
+      chart.source(_that.data.list, {
36
+        percent: {
37
+          formatter: function formatter (val) {
38
+            val = val * 100 + '%'
39
+            return val
40
+          }
41
+        }
42
+      })
43
+      chart.coord('theta', {
44
+        radius: 0.75,
45
+        innerRadius: 0.6
46
+      })
47
+      chart.tooltip({
48
+        showTitle: false,
49
+        itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
50
+      })
51
+      var num = 0
52
+      for (var n = 0; n < _that.data.list.length; n++) {
53
+        num += _that.data.list[n].count
54
+      }
55
+      // 辅助文本
56
+      chart.guide().html({
57
+        position: ['50%', '50%'],
58
+        html: '<div style="color:#8c8c8c;font-size: 14px;text-align: center;width: 10em;">' + _that.data.title + '<br><span style="color:#8c8c8c;font-size:20px">' + num + '</span></div>',
59
+        alignX: 'middle',
60
+        alignY: 'middle'
61
+      })
62
+      var interval = chart.intervalStack().position('percent').color('item').label('percent', {
63
+        formatter: function formatter (val, item) {
64
+          return item.point.item + ': ' + val
65
+        }
66
+      }).tooltip('item*percent', function (item, percent) {
67
+        percent = percent * 100 + '%'
68
+        return {
69
+          name: item,
70
+          value: percent
71
+        }
72
+      }).style({
73
+        lineWidth: 1,
74
+        stroke: '#fff'
75
+      })
76
+      chart.render()
77
+      interval.setSelected(_that.data.list[0])
78
+    },
79
+  }
80
+}
81
+</script>
82
+
83
+<!-- Add "scoped" attribute to limit CSS to this component only -->
84
+<style lang="scss" scoped>
85
+@import "page.scss";
86
+</style>

+ 28
- 0
src/components/ringChart/page.scss Vedi File

@@ -0,0 +1,28 @@
1
+
2
+.component{
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
+

+ 35
- 73
src/pages/system/dashboard/index.vue Vedi File

@@ -10,26 +10,25 @@
10 10
         </el-option>
11 11
       </el-select>
12 12
     </div>
13
-    <div class="top flex-h">
14
-      <div class="flex-item" v-for="(item,index) in topData" :key="index">
15
-        <div v-if="item.type === 'dashboardList'">
16
-          <dashboardList :data="item.data"></dashboardList>
13
+    <div class="flex-h" v-for="(item,index) in pageData" :key="index">
14
+      <div class="flex-item" v-for="(subItem,subIndex) in item" :key="subIndex">
15
+        <div v-if="subItem.type === 'dashboardList'">
16
+          <dashboardList :data="subItem.data"></dashboardList>
17 17
         </div>
18
-      </div>
19
-    </div>
20
-    <div class="body flex-h">
21
-      <div class="flex-item" v-for="(item,index) in bodyData" :key="index">
22
-        <div v-if="item.type === 'histogram'">
23
-          <histogram :data="item.data"></histogram>
18
+        <div v-if="subItem.type === 'histogram'">
19
+          <histogram :data="subItem.data"></histogram>
20
+        </div>
21
+        <div v-if="subItem.type === 'pieDiagram'">
22
+          <pieDiagram :data="subItem.data"></pieDiagram>
23
+        </div>
24
+        <div v-if="subItem.type === 'brokenLineGraph'">
25
+          <brokenLineGraph :data="subItem.data"></brokenLineGraph>
26
+        </div>
27
+        <div v-if="subItem.type === 'ringChart'">
28
+          <ringChart :data="subItem.data"></ringChart>
24 29
         </div>
25
-        <template v-if="item.type === 'pieDiagram'">
26
-          <pieDiagram :data="item.data"></pieDiagram>
27
-        </template>
28 30
       </div>
29 31
     </div>
30
-    <div class="bottom flex-h">
31
-      3
32
-    </div>
33 32
   </div>
34 33
 </template>
35 34
 
@@ -38,6 +37,8 @@ import { mapState } from 'vuex'
38 37
 import dashboardList from '../../../components/dashboardList/index'
39 38
 import histogram from '../../../components/histogram/index'
40 39
 import pieDiagram from '../../../components/pieDiagram/index'
40
+import brokenLineGraph from '../../../components/brokenLineGraph/index'
41
+import ringChart from '../../../components/ringChart/index'
41 42
 
42 43
 export default {
43 44
   name: '',
@@ -46,69 +47,30 @@ export default {
46 47
       postData: {
47 48
         caseid: ''
48 49
       },
49
-      topData: [{
50
-        type: 'dashboardList', // 列表面板
51
-        data: [{
52
-          name: '会员总数',
53
-          value: '1000',
54
-        }, {
55
-          name: '课程预约总量',
56
-          value: '1000',
57
-        }, {
58
-          name: '饮品下单总量',
59
-          value: '1000',
60
-        }]
61
-      }],
62
-      bodyData: [{
63
-        type: 'histogram', // 柱状图
64
-        data: {
65
-          title: '今日数据',
66
-          list: [{
67
-            x: '推荐会员新增',
68
-            y: 38
69
-          }, {
70
-            x: '课程数',
71
-            y: 52
72
-          }, {
73
-            x: '预约数',
74
-            y: 61
75
-          }, {
76
-            x: '到场人次',
77
-            y: 145
78
-          }]
79
-        },
80
-      }, {
81
-        type: 'pieDiagram', // 扇形图
82
-        data: {
83
-          title: '明日课程预约数据',
84
-          list: [{
85
-            item: '小小体验官',
86
-            count: 40,
87
-            percent: 0.4
88
-          }, {
89
-            item: '哈他瑜伽',
90
-            count: 52,
91
-            percent: 0.52
92
-          }, {
93
-            item: '小小飞行家',
94
-            count: 8,
95
-            percent: 0.08
96
-          }]
97
-        },
98
-      }],
99
-      bottomData: [{
100
-        type: 'brokenLineGraph', // 折线图
101
-        data: [],
102
-      }, {
103
-        type: 'ringChart', // 环形图
104
-        data: [],
105
-      }],
50
+      pageData: [
51
+        [
52
+          { type: 'dashboardList', remark: '列表面板', data: { title: '', list: [{ name: '会员总数', value: '1000', }, { name: '课程预约总量', value: '1000', }, { name: '饮品下单总量', value: '1000', }] } }
53
+        ],
54
+        [
55
+          { type: 'histogram', remark: '柱状图', data: { title: '今日数据', list: [{ x: '推荐会员新增', y: 38 }, { x: '课程数', y: 52 }, { x: '预约数', y: 61 }, { x: '到场人次', y: 145 }] } },
56
+          { type: 'pieDiagram', remark: '扇形图', data: { title: '明日课程预约数据', list: [{ item: '小小体验官', count: 40, percent: 0.4 }, { item: '哈他瑜伽', count: 52, percent: 0.52 }, { item: '小小飞行家', count: 8, percent: 0.08 }] } }
57
+        ],
58
+        [
59
+          { type: 'brokenLineGraph', remark: '折线图', data: { title: '下单饮品数据', list: [{ x: '09/05', y: 3 }, { x: '09/06', y: 4 }, { x: '09/07', y: 3.5 }, { x: '09/08', y: 5 }, { x: '09/09', y: 4.9 }, { x: '09/10', y: 6 }, { x: '09/11', y: 7 }, { x: '09/12', y: 9 }, { x: '09/13', y: 13 }] } },
60
+          { type: 'ringChart', remark: '环形图', data: { title: '本月课程预约', list: [{ item: '健身课程', count: 40, percent: 0.4 }, { item: '社交课程', count: 21, percent: 0.21 }, { item: '教育课程', count: 17, percent: 0.17 }, { item: '健康课程', count: 13, percent: 0.13 }, { item: '艺术课程', count: 9, percent: 0.09 }] } },
61
+        ],
62
+        [
63
+          { type: '', remark: '', data: { title: '', list: [] } },
64
+        ],
65
+      ],
106 66
     }
107 67
   },
108 68
   components: {
109 69
     dashboardList,
110 70
     histogram,
111 71
     pieDiagram,
72
+    brokenLineGraph,
73
+    ringChart,
112 74
   },
113 75
   computed: {
114 76
     ...mapState({