123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <div>
- <div id="riskLevelChart" :style="{width:width,height:height}"></div>
- </div>
- </template>
- <script>
- import { riskLevelData } from "@/api/process/moc";
- export default {
- props: {
- timeliness: null,
- width: {
- type: String,
- default: '100%'
- },
- height: {
- type: String,
- default: '200px'
- },
- },
- data() {
- return {
- option: {
- title: {
- left: 'center'
- },
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b} : {c} ({d}%)'
- },
- legend: {
- orient: 'vertical',
- left: 'left',
- data: []
- },
- toolbox: {
- show: true,
- feature: {
- mark: {show: true},
- magicType: {
- show: true,
- type: ['pie', 'funnel']
- },
- restore: {show: true},
- saveAsImage: {show: true}
- }
- },
- series: [
- {
- label: {
- formatter: '{b}: ({d}%)'
- },
- name: this.$t('区域'),
- type: 'pie',
- radius: ['50%', '70%'],
- selectedMode: 'single',
- data: [
- {value: 335, name: this.$t('直接访问')},
- ],
- emphasis: {
- label: {
- show: true,
- // fontSize: '21',
- fontWeight: 'bold'
- }
- },
- }
- ]
- },
- // 查询参数
- queryParams: {
- timeliness: null,
- },
- chart: null,
- chartData : []
- }
- },
- mounted() {
- this.$nextTick(() => {
- this.queryParams.timeliness = this.timeliness;
- riskLevelData(this.queryParams).then(response => {
- this.chartData = response
- for(let i = 0 ; i <this.chartData.length ; i++){
- this.option.legend.data[i] = this.chartData[i].dataName
- this.option.series[0].data[i] = {value:this.chartData[i].dataNum , name: this.chartData[i].dataName }
- }
- this.initChart()
- });
- })
- },
- methods: {
- /** 获取当前年份 */
- getNowTime() {
- var now = new Date();
- },
- initChart() {
- // 基于准备好的dom,初始化echarts实例
- this.chart = this.echarts.init(document.getElementById('riskLevelChart'))
- this.chart.setOption(this.option)
- }
- }
- }
- </script>
|