1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <div :class="className" :style="{height:height,width:width}" />
- </template>
- <script>
- import echarts from 'echarts'
- require('echarts/theme/macarons') // echarts theme
- import resize from '../mixins/resize'
- import { trainNewstaffCount} from "@/api/training/newstaff/tnNew";
- export default {
- mixins: [resize],
- props: {
- className: {
- type: String,
- default: 'chart'
- },
- width: {
- type: String,
- default: '100%'
- },
- height: {
- type: String,
- default: '210px'
- }
- },
- data() {
- return {
- chart: null,
- dataOut: []
- }
- },
- mounted() {
- this.$nextTick(() => {
- trainNewstaffCount().then(res=>{
- this.dataOut = [
- {value: res.data.count1, name: res.data.count1Name},
- {value: res.data.count0, name: res.data.count0Name},
- ]
- this.initChart()
- })
- })
- },
- beforeDestroy() {
- if (!this.chart) {
- return
- }
- this.chart.dispose()
- this.chart = null
- },
- methods: {
- initChart() {
- this.chart = echarts.init(this.$el, 'macarons')
- this.chart.setOption({
- tooltip: {
- trigger: 'item',
- formatter: "{b}: {c} " + " | " + "{d}%"
- },
- title:
- {
- text: '',
- }
- ,
- legend: {
- orient: 'vertical',
- left: 'left',
- itemWidth: 10,
- itemHeight: 10,
- textStyle: {
- fontSize: 12,
- padding:[0,0]
- },
- selectedMode: true,
- data: [],
- },
- series: [
- {
- name: '',
- type: 'pie',
- selectedMode: 'single',
- label: {
- position: 'outside',
- fontSize: 10,
- },
- animationEasing: 'cubicInOut',
- animationDuration: 1300,
- labelLine: {
- show: true
- },
- data: this.dataOut
- }
- ],
- })
- }
- }
- }
- </script>
|