import { Component, OnInit, ViewChild } from '@angular/core'; import { Router,ActivatedRoute } from '@angular/router' import { PageZhongDuiDetailsComponent } from '../page-zhong-dui-details/page-zhong-dui-details.component'; import {EchartsDataService} from '../../echarts-data.service'; declare var echarts: any; @Component({ selector: 'app-page-two-name', templateUrl: './page-two-name.component.html', styleUrls: ['./page-two-name.component.scss'] }) export class PageTwoNameComponent implements OnInit { constructor(private router:Router,private route:ActivatedRoute,public data:EchartsDataService) { } @ViewChild('zhongDuiChild') zhongDuiChild:PageZhongDuiDetailsComponent; //父组件中获得子组件的引用 ngOnInit(): void { if(window.matchMedia("(max-width: 1400px)").matches){ this.padHw=true //this.padjt= }else{ this.padHw=false } if(sessionStorage.getItem('refresh') === 'true') { sessionStorage.removeItem('refresh'); location.reload(); } this.route.queryParams.subscribe(param=>{ this.headname=param.level this.type=param.type this.tid=param.tid this.pieonetype=param.pieonetype if(this.headname=='二维预案'){ this.planType=1 }else if(this.headname=='三维预案'){ this.planType=2 }else if(this.headname=='其他预案'){ this.planType=4 }else if(this.headname=='文本预案'){ this.planType=16 } }); setTimeout(() => { this.getechartsdata() }); } ngOnDestroy(): void { } async getechartsdata(){ let paramdata={ planStatus:this.tid=='pieone'?'': this.type, PlanCategory:this.tid=='pieone'&&this.pieonetype=='true'?this.type:'', 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两个字换行 topTextlabel = { show: true, // 开启显示 position: 'top', // 在上方显示 distance: 10, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。 verticalAlign: 'middle', textStyle: { // 数值样式 color: 'black', fontSize: 12 } }//柱状图上方显示数值 zhiNameData = [] zhiNumData = [] tiaoshiPao:any //气泡提示数据获取 bianli(){ var arrshuzu='['; for(var i=0;i{ return this.data.biaogeTishida(params) }, position: this.data.tableTooltipNoShow2 }, series: [{ data: this.zhiNumData, type: 'bar', markPoint: { data: this.tiaoshiPao }, backgroundStyle: { color: 'rgba(220, 220, 220, 0.8)' }, barWidth :'38', //label: this.topTextlabel }] }; this.addEchart.setOption(option); this.addEchart.getZr().on('click', (params) => { const pointInPixel= [params.offsetX, params.offsetY]; if (this.addEchart.containPixel('grid',pointInPixel)) { let xIndex=this.addEchart.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0]; /*事件处理代码书写位置*/ if((this.data.level=='0'||this.data.level=='1')&&this.tabledata[0].organizations[xIndex].subOrganizations.length>=1){ this.router.navigate(['/statisticanalysis/stataPageThere'],{queryParams:{'level':option.xAxis.data[xIndex],'headtext':_this.headname,'id':option.xAxis.id[xIndex],'type':this.type,'tid':this.tid,'pieonetype':this.pieonetype}}); }else{ this.router.navigate(['/statisticanalysis/AllPlan'],{queryParams:{'xname':option.xAxis.data[xIndex],'name':this.headname,'id':option.xAxis.id[xIndex],'type':this.type,'tid':this.tid,'pieonetype':this.pieonetype}}); } //this.router.navigate(['/statisticanalysis/AllPlan'],{queryParams:{'name':option.xAxis.data[xIndex],'id':option.xAxis.id[xIndex],'type':this.type}}); } }); } passPlanEchartObj tableTooltip(biaotou:string){ var shuju='[{"name":"浦东支队","number":"156","zhanbi":"3%"},{"name":"黄浦支队","number":"144","zhanbi":"2.8%"},' shuju+='{"name":"徐汇支队","number":"133","zhanbi":"2.1%"},{"name":"长宁支队","number":"122","zhanbi":"1.6%"},' shuju+='{"name":"静安支队","number":"120","zhanbi":"1.3%"},{"name":"普陀支队","number":"100","zhanbi":"1.1%"},' shuju+='{"name":"虹口支队","number":"95","zhanbi":"1%"},{"name":"杨浦支队","number":"90","zhanbi":"0.9%"},' shuju+='{"name":"闵行支队","number":"88","zhanbi":"0.8%"},{"name":"宝山支队","number":"83","zhanbi":"0.7%"},' shuju+='{"name":"徐汇支队","number":"133","zhanbi":"2.1%"},{"name":"长宁支队","number":"122","zhanbi":"1.6%"},' shuju+='{"name":"嘉定支队","number":"78","zhanbi":"0.6%"},{"name":"松江支队","number":"75","zhanbi":"0.5%"},' shuju+='{"name":"金山支队","number":"65","zhanbi":"0.4%"},{"name":"崇明支队","number":"55","zhanbi":"0.3%"}]' var jsonObj = JSON.parse(shuju); var res = '
'+biaotou+'
' res+='
'; res+=''; res+=''; res+='' res+='' res+='' res+=''; for(var i=0;i' res+='' res+='' } res+='' res+='' res+='
名称数量总占比
'+jsonObj[i].number+''+jsonObj[i].zhanbi+'
总计135619%
' return res } tableTooltip2(biaotou:string){ var shuju='[{"name":"浦东中队","number":"156","zhanbi":"3%"},{"name":"黄浦中队","number":"144","zhanbi":"2.8%"},' shuju+='{"name":"徐汇中队","number":"133","zhanbi":"2.1%"},{"name":"长宁中队","number":"122","zhanbi":"1.6%"},' shuju+='{"name":"静安中队","number":"120","zhanbi":"1.3%"},{"name":"普陀中队","number":"100","zhanbi":"1.1%"},' shuju+='{"name":"虹口中队","number":"95","zhanbi":"1%"},{"name":"杨浦中队","number":"90","zhanbi":"0.9%"},' shuju+='{"name":"闵行中队","number":"88","zhanbi":"0.8%"},{"name":"宝山中队","number":"83","zhanbi":"0.7%"},' shuju+='{"name":"徐汇中队","number":"133","zhanbi":"2.1%"},{"name":"长宁中队","number":"122","zhanbi":"1.6%"},' shuju+='{"name":"嘉定中队","number":"78","zhanbi":"0.6%"},{"name":"松江中队","number":"75","zhanbi":"0.5%"},' shuju+='{"name":"金山中队","number":"65","zhanbi":"0.4%"},{"name":"崇明中队","number":"55","zhanbi":"0.3%"}]' var jsonObj = JSON.parse(shuju); var res = '
'+biaotou+'
' res+='
'; res+=''; res+=''; res+='' res+='' res+='' res+=''; for(var i=0;i' res+='' res+='' } res+='' res+='' res+='
名称数量总占比
'+jsonObj[i].number+''+jsonObj[i].zhanbi+'
总计135619%
' return res } }