Browse Source

企业饼图

lyn7568 6 years ago
parent
commit
2634fb7ec7

+ 1 - 0
src/api/statistics.js

@ -2,6 +2,7 @@ export const pqFilterList = '/ajax/log/article/pq' // 筛选内容列表
2 2
export const queryCreator = '/ajax/sys/name' // 查询发布者
3 3
export const queryTotalView = '/ajax/log/total' // 查询每天浏览量
4 4
export const queryOneView = '/ajax/log/qo' // 查询单个浏览量
5
export const pqCompanyState = '/ajax/log/company'
5 6
6 7
export const pqCompanyFilterList = '/ajax/log/company/pq'
7 8
export const pqProductFilterList = '/ajax/log/product/pq'

+ 30 - 6
src/views/statistics/companyCount.vue

@ -5,10 +5,20 @@
5 5
    </div>
6 6
    <div class="content-container">
7 7
      <div class="content-item" style="padding-top:0">
8
        <div class="content-item-tit">内容浏览量统计</div>
9
        <div class="line-chart-box">
10
          <LineChart :chartData="chartData"></LineChart>
11
        </div>
8
        <el-row :gutter="20">
9
          <el-col :span="12" style="border-right: 1px solid #ccc;">
10
            <div class="content-item-tit">企业总浏览量统计</div>
11
            <div class="line-chart-box">
12
              <LineChart :chartData="chartData"></LineChart>
13
            </div>
14
          </el-col>
15
          <el-col :span="12">
16
            <div class="content-item-tit">企业状态统计</div>
17
            <div class="line-chart-box">
18
              <PieChart :chartData="chartDataPie"></PieChart>
19
            </div>
20
          </el-col>
21
        </el-row>
12 22
      </div>
13 23
      <div class="content-item">
14 24
        <div class="content-item-tit">企业浏览量查询</div>
@ -66,13 +76,14 @@
66 76
</template>
67 77
68 78
<script>
69
import { pqCompanyFilterList, queryTotalView, queryOneView } from '@/api/statistics'
79
import { pqCompanyFilterList, queryTotalView, queryOneView, pqCompanyState } from '@/api/statistics'
70 80
import { queryCompKeyword } from '@/api/companyCen'
71 81
72 82
import { parseTime } from '@/utils/index'
73 83
import complexTable from '@/components/complexTable'
74 84
import ret from '@/utils/comTable'
75 85
import LineChart from './lineChart/LineChart'
86
import PieChart from './lineChart/PieChart'
76 87
import { dayListFn, chartModel } from './lineChart/chart'
77 88
78 89
export default {
@ -130,6 +141,7 @@ export default {
130 141
          tit: '浏览数量'
131 142
        }
132 143
      ],
144
      chartDataPie: {},
133 145
      chartData: [],
134 146
      chartOneData: [],
135 147
      beginDate: dayListFn(true)
@ -137,13 +149,25 @@ export default {
137 149
  },
138 150
  components: {
139 151
    complexTable,
140
    LineChart
152
    LineChart,
153
    PieChart
141 154
  },
142 155
  created() {
143 156
    this.queryInfoList()
144 157
    this.getInfoTotal()
158
    this.queryCompnaySate()
145 159
  },
146 160
  methods: {
161
    queryCompnaySate() {
162
      this.$http.get(pqCompanyState, {}, (res) => {
163
        var obj = res.data
164
        this.chartDataPie = {
165
          actived: obj.actived,
166
          all: obj.count,
167
          unactived: obj.count - obj.actived
168
        }
169
      })
170
    },
147 171
    getInfoTotal() {
148 172
      this.$http.get(queryTotalView, {
149 173
        tn: 'company',

+ 1 - 1
src/views/statistics/contentCount.vue

@ -5,7 +5,7 @@
5 5
    </div>
6 6
    <div class="content-container">
7 7
      <div class="content-item" style="padding-top:0">
8
        <div class="content-item-tit">内容浏览量统计</div>
8
        <div class="content-item-tit">内容浏览量统计</div>
9 9
        <div class="line-chart-box">
10 10
          <LineChart :chartData="chartData"></LineChart>
11 11
        </div>

+ 128 - 0
src/views/statistics/lineChart/PieChart.vue

@ -0,0 +1,128 @@
1
<template>
2
  <div :class="className" :style="{height:height,width:width}"></div>
3
</template>
4
5
<script>
6
import echarts from 'echarts'
7
require('echarts/theme/macarons')
8
import { debounce } from './chart'
9
10
export default {
11
  props: {
12
    className: {
13
      type: String,
14
      default: 'chart'
15
    },
16
    width: {
17
      type: String,
18
      default: '100%'
19
    },
20
    height: {
21
      type: String,
22
      default: '350px'
23
    },
24
    chartData: {
25
      type: Object
26
    }
27
  },
28
  data() {
29
    return {
30
      chart: null
31
    }
32
  },
33
  mounted() {
34
    this.initChart()
35
    this.__resizeHanlder = debounce(() => {
36
      if (this.chart) {
37
        this.chart.resize()
38
      }
39
    }, 100)
40
    window.addEventListener('resize', this.__resizeHanlder)
41
  },
42
  beforeDestroy() {
43
    if (!this.chart) {
44
      return
45
    }
46
    window.removeEventListener('resize', this.__resizeHanlder)
47
    this.chart.dispose()
48
    this.chart = null
49
  },
50
  watch: {
51
    chartData: {
52
      deep: true,
53
      handler(val) {
54
        this.setOptions(val)
55
      }
56
    }
57
  },
58
  methods: {
59
    setOptions(datastr) {
60
      this.chart.setOption({
61
        title: {
62
          text: '合计:' + datastr.all,
63
          textStyle: {
64
            color: '#333',
65
            fontSize: 14
66
          },
67
          left: 'center',
68
          top: '8%'
69
        },
70
        toolbox: {
71
          show: true,
72
          feature: {
73
            dataView: { readOnly: false },
74
            restore: {},
75
            saveAsImage: {}
76
          }
77
        },
78
        tooltip: {
79
          trigger: 'item',
80
          formatter: '{a} <br/>{b} : {c} ({d}%)'
81
        },
82
        legend: {
83
          data: ['未激活企业', '激活企业', '合计']
84
        },
85
        series: [
86
          {
87
            name: '企业状态',
88
            type: 'pie',
89
            radius: '65%',
90
            center: ['50%', '56%'],
91
            data: [
92
              {
93
                name: '未激活企业',
94
                value: datastr.unactived
95
              },
96
              {
97
                name: '激活企业',
98
                value: datastr.actived
99
              }
100
            ],
101
            itemStyle: {
102
              emphasis: {
103
                shadowBlur: 10,
104
                shadowOffsetX: 0,
105
                shadowColor: 'rgba(0, 0, 0, 0.5)'
106
              },
107
              normal: {
108
                label: {
109
                  show: true,
110
                  formatter: '{b} : {c} ({d}%)'
111
                },
112
                labelLine: { show: true }
113
              }
114
            }
115
          }
116
        ]
117
      })
118
    },
119
    initChart() {
120
      this.chart = echarts.init(this.$el) // , 'macarons'
121
      var that = this
122
      setTimeout(function() {
123
        that.setOptions(that.chartData)
124
      }, 1)
125
    }
126
  }
127
}
128
</script>