فهرست منبع

层叠面积图和折线图

wangziqian 5 سال پیش
والد
کامیت
78b4ff79d4
2فایلهای تغییر یافته به همراه204 افزوده شده و 1 حذف شده
  1. 199 0
      src/views/quality/components/statusChart.vue
  2. 5 1
      src/views/quality/requireStatistics.vue

+ 199 - 0
src/views/quality/components/statusChart.vue

@@ -0,0 +1,199 @@
+<template>
+  <div class="chart-contain">
+    <el-row type="flex" align="middle">
+      <el-col :span="4" :offset="18" class="col-flex-end">
+        <div class="pile-line" :class="[pileOrLine==='pile'?'active':'']" @click="changePileOrLine('pile')">堆叠面积图</div>
+        <div class="pile-line" :class="[pileOrLine==='line'?'active':'']" @click="changePileOrLine('line')">折线图</div>
+      </el-col>
+    </el-row>
+    <normal-echart v-if="echartsOption" :chart-id="id" :option="echartsOption" />
+  </div>
+</template>
+<script>
+import normalEchart from '@/components/chart/normalEchart'
+export default {
+  components: { normalEchart },
+  props: {
+    id: {
+      type: String,
+      default: 'statusChart',
+      required: false
+    }
+  },
+  data() {
+    return {
+      echartsOption: null,
+      pileOrLine: 'pile' // 图的类型,pile:堆叠面积图,line:折线图
+    }
+  },
+  mounted() {
+    this.changePileOrLine(this.pileOrLine)
+  },
+  methods: {
+    changePileOrLine(type) { // 图类型切换
+      this.pileOrLine = type
+      if (type === 'pile') {
+        this.setPile()
+      } else {
+        this.setLine()
+      }
+    },
+    setPile() {
+      this.echartsOption = {
+        tooltip: {
+          trigger: 'axis',
+          axisPointer: {
+            type: 'cross',
+            label: {
+              backgroundColor: '#6a7985'
+            }
+          }
+        },
+        legend: {
+          data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎'],
+          left: '7%'
+        },
+        grid: { left: '5%', right: '5%', bottom: '5%', top: '10%', containLabel: true },
+        xAxis: [
+          {
+            type: 'category',
+            boundaryGap: false,
+            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
+          }
+        ],
+        yAxis: [{ type: 'value' }],
+        series: [
+          {
+            name: '邮件营销',
+            type: 'line',
+            smooth: 0.5,
+            stack: '总量',
+            areaStyle: {},
+            data: [120, 132, 101, 134, 90, 230, 210]
+          },
+          {
+            name: '联盟广告',
+            type: 'line',
+            smooth: 0.5,
+            stack: '总量',
+            areaStyle: {},
+            data: [220, 182, 191, 234, 290, 330, 310]
+          },
+          {
+            name: '视频广告',
+            type: 'line',
+            smooth: 0.5,
+            stack: '总量',
+            areaStyle: {},
+            data: [150, 232, 201, 154, 190, 330, 410]
+          },
+          {
+            name: '直接访问',
+            type: 'line',
+            smooth: 0.5,
+            stack: '总量',
+            areaStyle: {},
+            data: [320, 332, 301, 334, 390, 330, 320]
+          },
+          {
+            name: '搜索引擎',
+            type: 'line',
+            smooth: 0.5,
+            stack: '总量',
+            label: { normal: { show: true, position: 'top' }},
+            areaStyle: {},
+            data: [820, 932, 901, 934, 1290, 1330, 1320]
+          }
+        ]
+      }
+    },
+    setLine() {
+      this.echartsOption = {
+        tooltip: {
+          trigger: 'axis',
+          axisPointer: {
+            type: 'cross',
+            label: {
+              backgroundColor: '#6a7985'
+            }
+          }
+        },
+        legend: {
+          data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎'],
+          left: '7%'
+        },
+        grid: { left: '5%', right: '5%', bottom: '5%', top: '10%', containLabel: true },
+        xAxis: [
+          {
+            type: 'category',
+            boundaryGap: false,
+            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
+          }
+        ],
+        yAxis: [{ type: 'value' }],
+        series: [
+          {
+            name: '邮件营销',
+            type: 'line',
+            stack: '总量',
+            data: [120, 132, 101, 134, 90, 230, 210]
+          },
+          {
+            name: '联盟广告',
+            type: 'line',
+            stack: '总量',
+            data: [220, 182, 191, 234, 290, 330, 310]
+          },
+          {
+            name: '视频广告',
+            type: 'line',
+            stack: '总量',
+            data: [150, 232, 201, 154, 190, 330, 410]
+          },
+          {
+            name: '直接访问',
+            type: 'line',
+            stack: '总量',
+            data: [320, 332, 301, 334, 390, 330, 320]
+          },
+          {
+            name: '搜索引擎',
+            type: 'line',
+            stack: '总量',
+            label: { normal: { show: true, position: 'top' }},
+            data: [820, 932, 901, 934, 1290, 1330, 1320]
+          }
+        ]
+      }
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+.chart-contain {
+  position: relative;
+  height: 400px;
+  width: 100%;
+  margin-top: 20px;
+  .col-flex-end {
+    display: flex;
+    justify-content: flex-end;
+  }
+  .pile-line{
+    font-size: 14px;
+    width: 45%;
+    display: inline-block;
+    padding: 6px 10px;
+    margin-left: 5%;
+    color: #50A6FF;
+    border: 1px solid #50A6FF;
+    border-radius: 4px;
+    text-align: center;
+    cursor: pointer;
+  }
+  .active {
+    color: #ffffff;
+    background: #50A6FF;
+  }
+}
+</style>

+ 5 - 1
src/views/quality/requireStatistics.vue

@@ -97,7 +97,9 @@
         <h3>状态累积流量图</h3>
         <el-row type="flex" align="middle">
           <el-col :span="24">
-            <div class="chart-contain" />
+            <div class="chart-contain">
+              <status-chart />
+            </div>
           </el-col>
         </el-row>
       </div>
@@ -112,7 +114,9 @@ import { teamQueryTeamInfoList } from '@/api/configure'
 import {
   getSummary
 } from '@/api/defectStatistics'
+import statusChart from './components/statusChart'
 export default {
+  components: { statusChart },
   data() {
     return {
       bugCountTimeType: 1, // 获取趋缺陷势图数据接口入参:1本周 2本月 3本年