/* * @Descripttion: * @version: * @Author: sueRimn * @Date: 2020-09-05 13:50:45 * @LastEditors: sueRimn * @LastEditTime: 2021-07-22 11:28:02 */ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import {EchartsDataService} from '../../echarts-data.service' declare var echarts: any; @Component({ selector: 'app-page-zhong-dui-details', templateUrl: './page-zhong-dui-details.component.html', styleUrls: ['./page-zhong-dui-details.component.scss'] }) export class PageZhongDuiDetailsComponent implements OnInit { constructor( public route: ActivatedRoute,public data: EchartsDataService,private router: Router) { } zhongNameData = [] zhongNumData = [] tiaoshiPao:any headtext:string; headName:string; type lastid tabledata organizationId=[] padHw tid yuanName pieonetype//判断是级别还是类型,上个页面传过来的参数 planType//预案类型 ngOnInit(): void { if(sessionStorage.getItem('refresh') === 'true') { sessionStorage.removeItem('refresh'); location.reload(); } if(window.matchMedia("(max-width: 1400px)").matches){ this.padHw=true //this.padjt= }else{ this.padHw=false } let level:string; this.route.queryParams.subscribe(param=>{ //this.headtext=param.headtext level=param.level this.headName=level; this.type=param.type this.lastid=param.id this.tid=param.tid this.yuanName=param.name this.pieonetype=param.pieonetype }); if(this.yuanName=='二维预案'){ this.planType=1 }else if(this.yuanName=='三维预案'){ this.planType=2 }else if(this.yuanName=='其他预案'){ this.planType=4 }else if(this.yuanName=='文本预案'){ this.planType=16 } window.setTimeout(()=>{ this.getechartsdata() }) } ngOnDestroy(): void { this.detailPlanEchart.clear() this.detailPlanEchart.dispose() } async getechartsdata(){ let paramdata={ planStatus:this.tid=='pieone'?'': this.type, PlanCategory:this.tid=='pieone'&&this.pieonetype=='true'?this.type:'', OrganizationId:this.lastid, PlanType:this.tid=='pieone'&&this.pieonetype=='false'?this.planType:'' } await this.data.getData(paramdata,this.tid=='pieone'&&this.pieonetype=='true'?'/api/StatisticsAnalysis/Plans/Category':this.tid=='pieone'&&this.pieonetype=='false'?'/api/StatisticsAnalysis/Plans/Type': `/api/StatisticsAnalysis/Plans/Status`) this.tabledata=JSON.parse(JSON.stringify(this.data.allDate)) // console.log(this.tabledata) for(var i=0;i 1)//如果类目项的文字大于3, { for (var i = 0; i < rowN; i++) { var temp = "";//每次截取的字符串 var start = i * maxLength;//开始截取的位置 var end = start + maxLength;//结束截取的位置 //这里也可以加一个是否是最后一行的判断,但是不加也没有影响,那就不加吧 temp = value.substring(start, end) + "\n"; ret += temp; //凭借最终的字符串 } return ret; } else { return value; } } }//echarts两个字换行 detailPlanEchart detailEcharts(){ this.detailPlanEchart = echarts.init(document.getElementById('detailBox'),'walden'); var option = { title: { text: this.headName+this.yuanName+`总数(${this.tabledata[0].totalCount})`, left: "center", top: "0", textStyle: { fontSize: 30 } }, grid: { containLabel:true, top: 110, //bottom: 10 }, xAxis: { id:this.organizationId, type: 'category', data: this.zhongNameData, axisLabel:this.padHw?this.axisLabel: { //this.axisLabel, interval: 0, textStyle:{ fontSize :18, color:'#000000' } } }, yAxis: { type: 'value', axisLabel:{ textStyle:{ fontSize :18, color:'#000000' } } }, tooltip: { trigger: 'item', formatter: (params)=>{ return this.data.biaogeTishida(params) } }, series: [{ data: this.zhongNumData, type: 'bar', markPoint: { symbolSize:[65, 65], data: this.tiaoshiPao }, backgroundStyle: { color: 'rgba(220, 220, 220, 0.8)' }, barWidth :'38' }] }; this.detailPlanEchart.setOption(option); this.detailPlanEchart.getZr().on('click', (params) => { const pointInPixel= [params.offsetX, params.offsetY]; if (this.detailPlanEchart.containPixel('grid',pointInPixel)){ let xIndex=this.detailPlanEchart.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0]; this.router.navigate(['/statisticanalysis/AllPlan'],{queryParams:{'xname':option.xAxis.data[xIndex],'name':this.yuanName,'id':option.xAxis.id[xIndex],'type':this.type,'tid':this.tid,'pieonetype':this.pieonetype}}); } }); } tableTooltip(params:any){ var data = [ {name:params.name,number:params.value,zhanbi:(params.value/1340 * 100).toFixed(2) + "%"} ] var res = '
'+params.name+'
' res+='
'; res+=''; res+=''; res+='' res+='' res+='' res+=''; for(var i=0;i' res+='' res+='' } res+='' // res+='' res+='
名称数量总占比
'+data[i].number+''+data[i].zhanbi+'
总计135619%
' return res } }