|
|
|
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<this.tabledata[0].organizations.length;i++){
|
|
|
|
this.zhiNameData.push(this.tabledata[0].organizations[i].organizationName)
|
|
|
|
this.zhiNumData.push(this.tabledata[0].organizations[i].count)
|
|
|
|
this.organizationId.push(this.tabledata[0].organizations[i].organizationId)
|
|
|
|
}
|
|
|
|
this.tiaoshiPao=this.data.qipao(this.tiaoshiPao,this.zhiNumData,this.zhiNameData)
|
|
|
|
this.planAdd()
|
|
|
|
}
|
|
|
|
pieonetype//判断是级别还是类型,上个页面传过来的参数
|
|
|
|
planType//预案类型
|
|
|
|
tid//上个页面点的第几个饼状图
|
|
|
|
padHw
|
|
|
|
headname//标题
|
|
|
|
type//预案类型
|
|
|
|
axisLabel = {
|
|
|
|
interval: 0,
|
|
|
|
textStyle:{
|
|
|
|
fontSize :16,
|
|
|
|
color:'#000000'
|
|
|
|
},
|
|
|
|
formatter:function(value)
|
|
|
|
{
|
|
|
|
var ret = "";//拼接加\n返回的类目项
|
|
|
|
var maxLength = 2;//每项显示文字个数
|
|
|
|
var valLength = value.length;//X轴类目项的文字个数
|
|
|
|
var rowN = Math.ceil(valLength / maxLength); //类目项需要换行的行数
|
|
|
|
if (rowN > 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<this.zhiNumData.length;i++){
|
|
|
|
arrshuzu+='{"value":'+this.zhiNumData[i]+',"coord":['+i+','+this.zhiNumData[i]+'],"name":'+'"'+this.zhiNameData[i]+'"'+'},'
|
|
|
|
}
|
|
|
|
arrshuzu=arrshuzu.substring(0,arrshuzu.length-1)
|
|
|
|
arrshuzu+=']'
|
|
|
|
this.tiaoshiPao=JSON.parse(arrshuzu)
|
|
|
|
//return tishiPao
|
|
|
|
}
|
|
|
|
addEchart
|
|
|
|
tabledata
|
|
|
|
organizationId=[]
|
|
|
|
|
|
|
|
//预案新增统计
|
|
|
|
planAdd () {
|
|
|
|
let _this = this
|
|
|
|
this.addEchart = echarts.init(document.getElementById('pie'),'walden');
|
|
|
|
var option = {
|
|
|
|
title: {
|
|
|
|
text: _this.headname+`总数(${this.tabledata[0].totalCount})`,
|
|
|
|
left: "center",
|
|
|
|
top: 0,
|
|
|
|
textStyle: {
|
|
|
|
fontSize: 30
|
|
|
|
}
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
containLabel:true,
|
|
|
|
top:this.padHw?100: 80,
|
|
|
|
//bottom: 10
|
|
|
|
},
|
|
|
|
xAxis: {
|
|
|
|
id:this.organizationId,
|
|
|
|
type: 'category',
|
|
|
|
data: this.zhiNameData,
|
|
|
|
axisLabel:this.padHw?this.axisLabel:{
|
|
|
|
//this.axisLabel,
|
|
|
|
textStyle:{
|
|
|
|
fontSize :14,
|
|
|
|
color:'#000000'
|
|
|
|
},
|
|
|
|
interval: 0,
|
|
|
|
rotate:38,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
yAxis: {
|
|
|
|
type: 'value',
|
|
|
|
axisLabel:{
|
|
|
|
//this.axisLabel,
|
|
|
|
textStyle:{
|
|
|
|
fontSize :16,
|
|
|
|
color:'#000000'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
trigger: 'item',
|
|
|
|
formatter: (params)=>{
|
|
|
|
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 = '<div class="tishi" style=" backgroundColor:rgba(255,255,255,1);width:100%;height:100%;"><div style="padding:10px 0 5px 0"><span style="color:#000000;font-size:30px;text-align: center;display:block;">'+biaotou+'</span></div>'
|
|
|
|
res+='</br><div style="width:300px;height:100%;padding:0 20px 15px 20px"><table style="width:300px; background:#FFFFFF; color:#000000;border-collapse:collapse;"cellspacing="0"; >';
|
|
|
|
res+='<thead><tr>';
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">名称</td>';
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">数量</td>'
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">总占比</td>'
|
|
|
|
res+='</tr></thead>'
|
|
|
|
res+='<tbody>';
|
|
|
|
for(var i=0;i<jsonObj.length;i++){
|
|
|
|
res+='<tr>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].name+'</td>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].number+'</td>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].zhanbi+'</td></tr>'
|
|
|
|
}
|
|
|
|
|
|
|
|
res+='</tbody>'
|
|
|
|
res+='<tfoot><td style="text-align:center;border:1px solid #000000">总计</td><td style="text-align:center;border:1px solid #000000">1356</td><td style="text-align:center;border:1px solid #000000">19%</td></tfoot>'
|
|
|
|
res+='</table></div></div>'
|
|
|
|
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 = '<div class="tishi" style=" backgroundColor:rgba(255,255,255,1);width:100%;height:100%;"><div style="padding:10px 0 5px 0"><span style="color:#000000;font-size:30px;text-align: center;display:block;">'+biaotou+'</span></div>'
|
|
|
|
res+='</br><div style="width:300px;height:100%;padding:0 20px 15px 20px"><table style="width:300px; background:#FFFFFF; color:#000000;border-collapse:collapse;"cellspacing="0"; >';
|
|
|
|
res+='<thead><tr>';
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">名称</td>';
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">数量</td>'
|
|
|
|
res+='<td style="text-align:center;width:30%;border:1px solid #000000">总占比</td>'
|
|
|
|
res+='</tr></thead>'
|
|
|
|
res+='<tbody>';
|
|
|
|
for(var i=0;i<jsonObj.length;i++){
|
|
|
|
res+='<tr>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].name+'</td>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].number+'</td>'
|
|
|
|
res+='<td style="text-align:center;border:1px solid #000000">'+jsonObj[i].zhanbi+'</td></tr>'
|
|
|
|
}
|
|
|
|
|
|
|
|
res+='</tbody>'
|
|
|
|
res+='<tfoot><td style="text-align:center;border:1px solid #000000">总计</td><td style="text-align:center;border:1px solid #000000">1356</td><td style="text-align:center;border:1px solid #000000">19%</td></tfoot>'
|
|
|
|
res+='</table></div></div>'
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
}
|