|
@@ -1,24 +1,29 @@
|
|
|
<template>
|
|
|
<div id="iscome">
|
|
|
- <div id="chartPie" style="height:350px;"></div>
|
|
|
+ <div id="chartPie" style="height:400px;"></div>
|
|
|
</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 { Ring } from '@antv/g2plot';
|
|
|
+// 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: 'iscome',
|
|
|
props: {
|
|
|
istrain: { type: Number, default: 0 },
|
|
|
nottrain: { type: Number, default: 0 },
|
|
|
+ // data: { type: [Object, Array], default: () => [] },
|
|
|
+ // axis: { type: Object, default: () => {} },
|
|
|
+ // gid: { type: String, default: `${new Date().getTime()}` },
|
|
|
},
|
|
|
components: {},
|
|
|
data: function() {
|
|
@@ -32,38 +37,80 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
- init(type) {
|
|
|
- this.myPie = echarts.init(document.getElementById('chartPie'));
|
|
|
- const option = {
|
|
|
- title: { text: '当前学生参加培训情况' },
|
|
|
- tooltip: { trigger: 'item', formatter: '{a} <br/>{b} : {c} ({d}%)' },
|
|
|
- legend: {
|
|
|
- data: ['已参加培训', '未参加培训'],
|
|
|
+ init() {
|
|
|
+ const data = [
|
|
|
+ {
|
|
|
+ type: '已参加培训',
|
|
|
+ value: this.istrain,
|
|
|
+ itemStyle: { color: '#7cb5ec' },
|
|
|
},
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '统计',
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- position: 'top',
|
|
|
- },
|
|
|
- type: 'pie',
|
|
|
- data: [
|
|
|
- { name: '已参加培训', value: this.istrain, itemStyle: { color: '#7cb5ec' } },
|
|
|
- { name: '未参加培训', value: this.nottrain, itemStyle: { color: '#ffa94b' } },
|
|
|
- ],
|
|
|
- animationType: 'scale',
|
|
|
- },
|
|
|
- ],
|
|
|
- toolbox: {
|
|
|
- show: true,
|
|
|
- feature: {
|
|
|
- dataView: { readOnly: false },
|
|
|
- saveAsImage: {},
|
|
|
+ {
|
|
|
+ type: '未参加培训',
|
|
|
+ value: this.nottrain,
|
|
|
+ itemStyle: { color: '#ffa94b' },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const ringPlot = new Ring(document.getElementById('chartPie'), {
|
|
|
+ forceFit: true,
|
|
|
+ radius: 0.8,
|
|
|
+ data,
|
|
|
+ angleField: 'value',
|
|
|
+ colorField: 'type',
|
|
|
+ title: {
|
|
|
+ visible: true,
|
|
|
+ text: '当前学生参加培训情况',
|
|
|
+ style: {
|
|
|
+ fontSize: 30,
|
|
|
+ fill: 'black',
|
|
|
},
|
|
|
},
|
|
|
- };
|
|
|
- this.myPie.setOption(option);
|
|
|
+ });
|
|
|
+ ringPlot.render();
|
|
|
+ // const columnPlot = new Column(document.getElementById('container'), {
|
|
|
+ // title: {
|
|
|
+ // visible: true,
|
|
|
+ // text: '图表标题及描述',
|
|
|
+ // },
|
|
|
+ // description: {
|
|
|
+ // visible: true,
|
|
|
+ // text: '这是一个关于配置图表标题和描述文本内容的demo',
|
|
|
+ // },
|
|
|
+ // data,
|
|
|
+ // xField: 'year',
|
|
|
+ // yField: 'value',
|
|
|
+ // });
|
|
|
+
|
|
|
+ // 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: this.istrain, itemStyle: { color: '#7cb5ec' } },
|
|
|
+ // { name: '未参加培训', value: this.nottrain, itemStyle: { color: '#ffa94b' } },
|
|
|
+ // ],
|
|
|
+ // animationType: 'scale',
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ // toolbox: {
|
|
|
+ // show: true,
|
|
|
+ // feature: {
|
|
|
+ // dataView: { readOnly: false },
|
|
|
+ // saveAsImage: {},
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // };
|
|
|
+ // this.myPie.setOption(option);
|
|
|
},
|
|
|
},
|
|
|
computed: {
|