|
@@ -0,0 +1,97 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="pie">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24" style="padding:10px">
|
|
|
|
+ <el-radio-group v-model="myPieRadio" @change="init('reload')">
|
|
|
|
+ <el-radio label="year">按年统计</el-radio>
|
|
|
|
+ <el-radio label="term">按期统计</el-radio>
|
|
|
|
+ <el-radio label="class">按班统计</el-radio>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <div id="chartPie" class="" style="height:350px;"></div>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import _ from 'lodash';
|
|
|
|
+import echarts from 'echarts/lib/echarts';
|
|
|
|
+import 'echarts/lib/chart/pie';
|
|
|
|
+import 'echarts/lib/component/title';
|
|
|
|
+import 'echarts/lib/component/legend';
|
|
|
|
+import 'echarts/lib/component/toolbox';
|
|
|
|
+import 'echarts/lib/component/markPoint';
|
|
|
|
+import 'echarts/lib/component/tooltip';
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+export default {
|
|
|
|
+ name: 'pie',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data: function() {
|
|
|
|
+ return {
|
|
|
|
+ myPie: null,
|
|
|
|
+ myPieRadio: 'year',
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.init();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ init(type) {
|
|
|
|
+ if (type) this.myPie.dispose();
|
|
|
|
+ let data = [];
|
|
|
|
+ for (let index = 0; index < 4; index++) {
|
|
|
|
+ data.push(_.round(_.random(50, true)));
|
|
|
|
+ }
|
|
|
|
+ this.myPie = echarts.init(document.getElementById('chartPie'));
|
|
|
|
+ const option = {
|
|
|
|
+ title: { text: '满意度调查' },
|
|
|
|
+ tooltip: { trigger: 'item', formatter: '{a} <br/>{b} : {c} ({d}%)' },
|
|
|
|
+ legend: {
|
|
|
|
+ data: ['满意', '一般', '强差人意', '不满意'],
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '统计',
|
|
|
|
+ label: {
|
|
|
|
+ show: true,
|
|
|
|
+ position: 'top',
|
|
|
|
+ },
|
|
|
|
+ type: 'pie',
|
|
|
|
+ data: [
|
|
|
|
+ { name: '满意', value: data[0] || 0, itemStyle: { color: '#7cb5ec' } },
|
|
|
|
+ { name: '一般', value: data[1] || 0, itemStyle: { color: '#ffa94b' } },
|
|
|
|
+ { name: '强差人意', value: data[2] || 0, itemStyle: { color: '#346da4' } },
|
|
|
|
+ { name: '不满意', value: data[3] || 0, itemStyle: { color: '#abcdef' } },
|
|
|
|
+ ],
|
|
|
|
+ animationType: 'scale',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ toolbox: {
|
|
|
|
+ show: true,
|
|
|
|
+ feature: {
|
|
|
|
+ dataView: { readOnly: false },
|
|
|
|
+ saveAsImage: {},
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ this.myPie.setOption(option);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user']),
|
|
|
|
+ pageTitle() {
|
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped></style>
|