许静 5 years ago
parent
commit
890eacf054
2 changed files with 86 additions and 104 deletions
  1. 0
    4
      src/components/charts/XLine.vue
  2. 86
    100
      src/views/indexEcharts/index.vue

+ 0
- 4
src/components/charts/XLine.vue View File

10
     return {
10
     return {
11
       chart: undefined,
11
       chart: undefined,
12
       defaultOpts: {
12
       defaultOpts: {
13
-        //  dataset: {
14
-        //   dimensions: ['date', 'userCount', 'authorizationCount'],
15
-        //   source,
16
-        // },
17
         title: {
13
         title: {
18
           text: "新增用户"
14
           text: "新增用户"
19
         },
15
         },

+ 86
- 100
src/views/indexEcharts/index.vue View File

34
   </el-row>
34
   </el-row>
35
   <p class="title under-line" @click="toBehaviorAnalysis()">用户行为</p>
35
   <p class="title under-line" @click="toBehaviorAnalysis()">用户行为</p>
36
   <span class="title-desc under-line" @click="toBehaviorAnalysis()">最近7天</span>
36
   <span class="title-desc under-line" @click="toBehaviorAnalysis()">最近7天</span>
37
-  <div class="grid-content" ref="thirdChart"  id="thirdChart"  :style="{ height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" ></div>
38
-  <el-row :gutter="20">
37
+  <!-- <div class="grid-content" ref="thirdChart"  id="thirdChart"  :style="{ height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" ></div> -->
38
+   <x-line :style="{height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}"  :value="lineSeting"></x-line>
39
+ <el-row :gutter="20">
39
     <el-col :span="12">
40
     <el-col :span="12">
40
-      <div class="grid-content" ref="fourthChart"  id="fourthChart"  :style="{ height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" >
41
-      </div>
41
+      <div class="grid-content" ref="fourthChart"  id="fourthChart"  :style="{height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" ></div>
42
     </el-col>
42
     </el-col>
43
     <el-col :span="12">
43
     <el-col :span="12">
44
       <div class="grid-content" ref="fifthChart"  id="fifthChart"  :style="{ height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" >
44
       <div class="grid-content" ref="fifthChart"  id="fifthChart"  :style="{ height: '500px',margin:'20px 0',border:'1px solid #eee', padding:'20px',borderRadius:'5px'}" >
79
 } = createNamespacedHelpers("indexEcharts");
79
 } = createNamespacedHelpers("indexEcharts");
80
 
80
 
81
 export default {
81
 export default {
82
-  components: {},
82
+  components: {
83
+    XLine: () => import('@/components/charts/XLine.vue'),
84
+  },
83
   data() {
85
   data() {
84
     return {
86
     return {
85
       // 新增用户
87
       // 新增用户
88
         { label: '授权注册', }
90
         { label: '授权注册', }
89
       ],
91
       ],
90
       tableTitle: [ '类型' ],
92
       tableTitle: [ '类型' ],
91
-      tableData2: [
92
-        {
93
-          num: "98",
94
-          name: "王晓红",
95
-          phone: "15742389456",
96
-          building: "香颂.蔚澜半岛"
97
-        },
98
-        {
99
-          num: "99",
100
-          name: "王晓红2",
101
-          phone: "15742389456",
102
-          building: "香颂.蔚澜半岛"
93
+      tableData2: [ ],
94
+      userBehavior: [], // 用户行为
95
+      lineSeting: {
96
+        dataset: {
97
+          dimensions: ['date', 'activity', 'activityCount'],
98
+          source: [],
103
         },
99
         },
104
-        {
105
-          num: "88",
106
-          name: "王晓红3",
107
-          phone: "15742389456",
108
-          building: "香颂.蔚澜半岛"
109
-        },
110
-        {
111
-          num: "94",
112
-          name: "王晓红4",
113
-          phone: "15742389456",
114
-          building: "香颂.蔚澜半岛"
115
-        }
116
-      ],
117
-      userBehavior: [] // 用户行为
100
+      },
118
     };
101
     };
119
   },
102
   },
120
   computed: {
103
   computed: {
127
     initPage() {
110
     initPage() {
128
       this.setDetailNull();
111
       this.setDetailNull();
129
       this.getIndexEcharts().then(x => {
112
       this.getIndexEcharts().then(x => {
113
+        this.lineSeting.dataset.source = this.echartsInfo.selectUserBehavior
130
         const data = this.echartsInfo.selectNewsUserCount
114
         const data = this.echartsInfo.selectNewsUserCount
131
-        // this.lineSeting.dataset.source = data
132
         this.tableData = (data || []).reduce((acc, item, index) => {
115
         this.tableData = (data || []).reduce((acc, item, index) => {
133
           const { date, userCount, authorizationCount } = item
116
           const { date, userCount, authorizationCount } = item
134
           const row2 = {
117
           const row2 = {
172
       };
155
       };
173
       // 绘制图表
156
       // 绘制图表
174
       firstChart.setOption({
157
       firstChart.setOption({
175
-        color: ["#ff580f", "#ffb400"],
158
+        color: ["#3688f8", "#7974ce"],
176
         backgroundColor: "#fff",
159
         backgroundColor: "#fff",
177
         tooltip: {
160
         tooltip: {
178
           trigger: "axis"
161
           trigger: "axis"
250
       let secondChart = Echarts.init(this.$refs.secondChart);
233
       let secondChart = Echarts.init(this.$refs.secondChart);
251
       // 绘制图表
234
       // 绘制图表
252
       secondChart.setOption({
235
       secondChart.setOption({
236
+        color: ["#7974ce","#f5749d","#3688f8"],
253
         tooltip: {
237
         tooltip: {
254
           trigger: "item",
238
           trigger: "item",
255
           formatter: "{a} <br/>{b} : {c} ({d}%)"
239
           formatter: "{a} <br/>{b} : {c} ({d}%)"
286
         ]
270
         ]
287
       });
271
       });
288
       // 折线图
272
       // 折线图
289
-      let thirdChart = Echarts.init(this.$refs.thirdChart);
273
+      // let thirdChart = Echarts.init(this.$refs.thirdChart);
290
       // 绘制图表
274
       // 绘制图表
291
-      thirdChart.setOption({
292
-        title: {
293
-          text: "访问人数"
294
-        },
295
-        color: ["#000", "green", "#5793f3", "#d14a61", "#241bba", "orange"],
296
-        tooltip: {
297
-          trigger: "axis"
298
-        },
299
-        legend: {
300
-          data: ["首页", "项目", "咨询", "名片", "活动", "资讯"]
301
-        },
302
-        grid: {
303
-          left: "3%",
304
-          right: "4%",
305
-          bottom: "3%",
306
-          containLabel: true
307
-        },
308
-        toolbox: {},
309
-        xAxis: {
310
-          type: "category",
311
-          boundaryGap: false,
312
-          data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
313
-        },
314
-        yAxis: {
315
-          type: "value"
316
-        },
317
-        series: [
318
-          {
319
-            name: "首页",
320
-            type: "line",
321
-            stack: "1",
322
-            data: []
323
-          },
324
-          {
325
-            name: "项目",
326
-            type: "line",
327
-            stack: "2",
328
-            data: [220, 182, 191, 234, 290, 330, 310]
329
-          },
330
-          {
331
-            name: "咨询",
332
-            type: "line",
333
-            stack: "3",
334
-            data: [150, 232, 201, 154, 190, 330, 410]
335
-          },
336
-          {
337
-            name: "名片",
338
-            type: "line",
339
-            stack: "4",
340
-            data: [320, 332, 301, 334, 390, 330, 320]
341
-          },
342
-          {
343
-            name: "活动",
344
-            type: "line",
345
-            stack: "5",
346
-            data: [820, 932, 901, 544, 1290, 1330, 1320]
347
-          },
348
-          {
349
-            name: "资讯",
350
-            type: "line",
351
-            stack: "6",
352
-            data: [400, 500, 201, 934, 1290, 1423, 777]
353
-          }
354
-        ]
355
-      });
275
+      // thirdChart.setOption({
276
+      //   title: {
277
+      //     text: "访问人数"
278
+      //   },
279
+      //   color: ["#ed3a3d", "#e613d2", "#2ed9f7", "#0ab662", "#165cf8", "#8854b9"],
280
+      //   tooltip: {
281
+      //     trigger: "axis"
282
+      //   },
283
+      //   legend: {
284
+      //     data: ["首页", "项目", "咨询", "名片", "活动", "资讯"]
285
+      //   },
286
+      //   grid: {
287
+      //     left: "3%",
288
+      //     right: "4%",
289
+      //     bottom: "3%",
290
+      //     containLabel: true
291
+      //   },
292
+      //   toolbox: {},
293
+      //   xAxis: {
294
+      //     type: "category",
295
+      //     boundaryGap: false,
296
+      //     data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
297
+      //   },
298
+      //   yAxis: {
299
+      //     type: "value"
300
+      //   },
301
+      //   series: [
302
+      //     {
303
+      //       name: "首页",
304
+      //       type: "line",
305
+      //       stack: "1",
306
+      //       data: []
307
+      //     },
308
+      //     {
309
+      //       name: "项目",
310
+      //       type: "line",
311
+      //       stack: "2",
312
+      //       data: [220, 182, 191, 234, 290, 330, 310]
313
+      //     },
314
+      //     {
315
+      //       name: "咨询",
316
+      //       type: "line",
317
+      //       stack: "3",
318
+      //       data: [150, 232, 201, 154, 190, 330, 410]
319
+      //     },
320
+      //     {
321
+      //       name: "名片",
322
+      //       type: "line",
323
+      //       stack: "4",
324
+      //       data: [320, 332, 301, 334, 390, 330, 320]
325
+      //     },
326
+      //     {
327
+      //       name: "活动",
328
+      //       type: "line",
329
+      //       stack: "5",
330
+      //       data: [820, 932, 901, 544, 1290, 1330, 1320]
331
+      //     },
332
+      //     {
333
+      //       name: "资讯",
334
+      //       type: "line",
335
+      //       stack: "6",
336
+      //       data: [400, 500, 201, 934, 1290, 1423, 777]
337
+      //     }
338
+      //   ]
339
+      // });
356
       // 柱状图
340
       // 柱状图
357
       let fourthChart = Echarts.init(this.$refs.fourthChart);
341
       let fourthChart = Echarts.init(this.$refs.fourthChart);
358
       // 绘制图表
342
       // 绘制图表
372
         title: {
356
         title: {
373
           text: "活跃用户数"
357
           text: "活跃用户数"
374
         },
358
         },
375
-        color: ["#3398DB"],
359
+        color: ["#7571cf"],
376
         tooltip: {
360
         tooltip: {
377
           trigger: "axis",
361
           trigger: "axis",
378
           axisPointer: {
362
           axisPointer: {
416
         title: {
400
         title: {
417
           text: "转化率"
401
           text: "转化率"
418
         },
402
         },
403
+        color:["#6a96f7","#f5749d"],
419
         tooltip: {
404
         tooltip: {
420
           trigger: "item",
405
           trigger: "item",
421
           formatter: "{a} <br/>{b}: {c} ({d}%)"
406
           formatter: "{a} <br/>{b}: {c} ({d}%)"
458
         title: {
443
         title: {
459
           text: "性别比例"
444
           text: "性别比例"
460
         },
445
         },
446
+        color:["#6a96f7","#f5749d"],
461
         tooltip: {
447
         tooltip: {
462
           trigger: "item",
448
           trigger: "item",
463
           formatter: "{a} <br/>{b}: {c} ({d}%)"
449
           formatter: "{a} <br/>{b}: {c} ({d}%)"