陈鹏飞
4 years ago
38 changed files with 2498 additions and 11 deletions
@ -0,0 +1,4 @@
|
||||
<body> |
||||
<!--饼状图 --> |
||||
<div id="indexBzt" style="width: 100%;height: 100%;"></div> |
||||
</body> |
@ -0,0 +1,8 @@
|
||||
.tishi{ |
||||
width: 100%; |
||||
height: 100%; |
||||
span{ |
||||
font-size: 25px; |
||||
text-align: center; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { AddUnitOneComponent } from './add-unit-one.component'; |
||||
|
||||
describe('AddUnitOneComponent', () => { |
||||
let component: AddUnitOneComponent; |
||||
let fixture: ComponentFixture<AddUnitOneComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ AddUnitOneComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(AddUnitOneComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,124 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-add-unit-one', |
||||
templateUrl: './add-unit-one.component.html', |
||||
styleUrls: ['./add-unit-one.component.scss'] |
||||
}) |
||||
export class AddUnitOneComponent implements OnInit { |
||||
|
||||
constructor(private router: Router) { } |
||||
|
||||
ngOnInit(): void { |
||||
window.setTimeout(()=>{ |
||||
this.initCharts() |
||||
},0) |
||||
} |
||||
/* 首页饼状图 */ |
||||
initCharts(){ |
||||
let indexBzt = echarts.init(document.getElementById('indexBzt')); |
||||
let options={ |
||||
title: { |
||||
text: '新增单位统计(8900家)', |
||||
left: 'center', |
||||
top: "7%", |
||||
textStyle: { |
||||
fontSize:31 |
||||
} |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.biaogeTishi(params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
legend: { |
||||
orient: 'vertical', |
||||
right: 150, |
||||
top:80, |
||||
data: ['高层', '地下', '轨道交通', '化工生产', '储罐类' , '厂房','古建筑', '商市场', '医院', '学校', '宾馆' , '娱乐场所','餐饮业', '影剧院', '展览建筑' , '隧道'] |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: '访问来源', |
||||
type: 'pie', |
||||
radius: '60%', |
||||
center: ['50%', '53%'], |
||||
label:{ |
||||
show:true, |
||||
fontSize:13, |
||||
formatter:'{b}{c}家\n{d|({d}%)}', |
||||
rich: { |
||||
d: { |
||||
align: 'center', |
||||
} |
||||
}, |
||||
}, |
||||
data: [ |
||||
{value: 500, name: '高层'}, |
||||
{value: 800, name: '地下'}, |
||||
{value: 900, name: '轨道交通'}, |
||||
{value: 800, name: '化工生产'}, |
||||
{value: 1200, name: '储罐类'}, |
||||
{value: 1500, name: '厂房'}, |
||||
{value: 1400, name: '古建筑'}, |
||||
{value: 600, name: '商市场'}, |
||||
{value: 568, name: '医院'}, |
||||
{value: 888, name: '学校'}, |
||||
{value: 485, name: '宾馆'}, |
||||
{value: 966, name: '娱乐场所'}, |
||||
{value: 789, name: '餐饮业'}, |
||||
{value: 500, name: '影剧院'}, |
||||
{value: 1025, name: '展览建筑'}, |
||||
{value: 600, name: '隧道'} |
||||
], |
||||
emphasis: { |
||||
itemStyle: { |
||||
shadowBlur: 10, |
||||
shadowOffsetX: 0, |
||||
shadowColor: 'rgba(0, 0, 0, 0.5)' |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}; |
||||
indexBzt.on('click', (params) => { |
||||
this.router.navigateByUrl('/statisticanalysis/addUnit_one/addUnit_two_type'); |
||||
}); |
||||
indexBzt.setOption(options); |
||||
} |
||||
biaogeTishi(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 |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
<div class="box"> |
||||
<div class="header"> |
||||
<div class="queryField"> |
||||
<mat-radio-group [(ngModel)]="selectType" (change)="dateChange()"> |
||||
<mat-radio-button value="month">月</mat-radio-button> |
||||
<mat-radio-button value="year" style="margin-left: 10px;">年</mat-radio-button> |
||||
</mat-radio-group> |
||||
</div> |
||||
|
||||
<div class="queryField" *ngIf="selectType=='month'"> |
||||
<form #form="ngForm" (ngSubmit)="monthSubmit(form.value)"> |
||||
<span>开始年份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectOneYear" name='selectOneYear'> |
||||
<mat-option *ngFor="let item of years" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<span>开始月份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectStartMonth" name='selectStartMonth'> |
||||
<mat-option *ngFor="let item of selectMonth" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<span>结束年份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectTwoYear" name='selectTwoYear'> |
||||
<mat-option *ngFor="let item of years" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<span>结束月份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectEndMonth" name='selectEndMonth'> |
||||
<mat-option *ngFor="let item of selectMonth" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<button type="submit" mat-raised-button color="primary">查询</button> |
||||
</form> |
||||
</div> |
||||
|
||||
<div class="queryField" *ngIf="selectType=='year'"> |
||||
<form #form2="ngForm" (ngSubmit)="yearSubmit(form2.value)"> |
||||
<span>开始年份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectStartYear" name='selectStartYear'> |
||||
<mat-option *ngFor="let item of years" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<span>结束年份:</span> |
||||
<mat-form-field> |
||||
<mat-select [(ngModel)]="selectEndYear" name='selectEndYear'> |
||||
<mat-option *ngFor="let item of years" [value]="item">{{item}}</mat-option> |
||||
</mat-select> |
||||
</mat-form-field> |
||||
<button type="submit" mat-raised-button color="primary">查询</button> |
||||
</form> |
||||
</div> |
||||
|
||||
<!-- <div class="fixedCss"> |
||||
<button mat-raised-button color="primary" (click)='toggleTrue()'>横向查询</button> |
||||
<button mat-raised-button color="primary" style="margin-left: 10px;" (click)='toggleFalse()'>纵向查询</button> |
||||
</div> --> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">类型统计</button> |
||||
<button mat-stroked-button (click)="reverse()">区间选择</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="Line"> |
||||
|
||||
</div> |
||||
<div> |
||||
<div class="publicCss" id="gaoceng"></div> |
||||
<div class="publicCss" id="dixia"></div> |
||||
<div class="publicCss" id="guidao"></div> |
||||
<div class="publicCss" id="huagong"></div> |
||||
<div class="publicCss" id="chuguan"></div> |
||||
<div class="publicCss" id="changfang"></div> |
||||
<div class="publicCss" id="gujianzhu"></div> |
||||
<div class="publicCss" id="shichang"></div> |
||||
<div class="publicCss" id="yiyuan"></div> |
||||
<div class="publicCss" id="xuexiao"></div> |
||||
<div class="publicCss" id="binguan"></div> |
||||
<div class="publicCss" id="yule"></div> |
||||
<div class="publicCss" id="canyin"></div> |
||||
<div class="publicCss" id="yingyuan"></div> |
||||
<div class="publicCss" id="zhanlan"></div> |
||||
<div class="publicCss" id="suidao"></div> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,63 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
} |
||||
#Line{ |
||||
width: 50%; |
||||
height: 420px; |
||||
margin: 50px auto; |
||||
} |
||||
} |
||||
.publicCss{ |
||||
height: 350px; |
||||
width: 50%; |
||||
display: inline-block; |
||||
box-sizing: border-box; |
||||
padding: 20px; |
||||
} |
||||
|
||||
//头部搜索栏 |
||||
.header { |
||||
border-bottom: 1px solid #999; |
||||
height: 80px; |
||||
min-height: 81px;; |
||||
box-sizing: border-box; |
||||
// padding: 0 15px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
align-items:center; |
||||
justify-content:center; |
||||
.queryField { |
||||
margin: 0 10px; |
||||
font-size: 14px; |
||||
.mat-form-field { |
||||
width: 130px; |
||||
max-height: 50px;; |
||||
margin: 0 15px 0 10px; |
||||
} |
||||
} |
||||
.btnbox{ |
||||
height: 80px; |
||||
display: flex; |
||||
flex-direction:column; |
||||
justify-content: space-around; |
||||
position: fixed; |
||||
top: 64px; |
||||
right: 4%; |
||||
width: 88px; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { AddUnitTwoTimeComponent } from './add-unit-two-time.component'; |
||||
|
||||
describe('AddUnitTwoTimeComponent', () => { |
||||
let component: AddUnitTwoTimeComponent; |
||||
let fixture: ComponentFixture<AddUnitTwoTimeComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ AddUnitTwoTimeComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(AddUnitTwoTimeComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,296 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; |
||||
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
||||
import { EchartsDataService } from '../../echarts-data.service'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-add-unit-two-time', |
||||
templateUrl: './add-unit-two-time.component.html', |
||||
styleUrls: ['./add-unit-two-time.component.scss'] |
||||
}) |
||||
export class AddUnitTwoTimeComponent implements OnInit { |
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_type']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_time']) |
||||
} |
||||
constructor(private router: Router,public dialog: MatDialog,public snackBar: MatSnackBar,private serviceData: EchartsDataService) { } |
||||
|
||||
ngOnInit(): void { |
||||
this.dateInit () |
||||
setTimeout(() => { |
||||
this.oneInit (this.date,this.dateNum) |
||||
this.twoInit (this.date,this.dateNum,'year') |
||||
}, 0); |
||||
} |
||||
|
||||
selectType:string = 'month'; //选择当前的 查询类型 按月/年
|
||||
|
||||
//查询数据
|
||||
years:any = [] |
||||
selectMonth:any = [1,2,3,4,5,6,7,8,9,10,11,12] |
||||
|
||||
//日期初始化
|
||||
dateInit () { |
||||
let date = (new Date()).getFullYear() |
||||
for (let i=date; i>=date-10;i--) { |
||||
this.years.unshift(i) |
||||
} |
||||
} |
||||
selectOneYear:any = (new Date()).getFullYear() //开始年份
|
||||
selectTwoYear:any = (new Date()).getFullYear() //结束年份
|
||||
selectStartMonth:any = 1 //开始月份
|
||||
selectEndMonth:any = (new Date()).getMonth()+1 //结束月份
|
||||
//按月查询
|
||||
monthSubmit (e) { |
||||
if (e.selectTwoYear > e.selectOneYear) { |
||||
let startTime = e.selectOneYear + '-' + e.selectStartMonth + '-' + 1 + ' ' + 0 + ':' + 0 +':'+ 0 |
||||
let endTime = e.selectTwoYear + '-' + e.selectEndMonth + '-' + 31 + ' ' + 23 + ':' + 59 +':'+ 59 |
||||
console.log(startTime) |
||||
console.log(endTime) |
||||
} else if (e.selectTwoYear === e.selectOneYear) { |
||||
if(e.selectEndMonth >= e.selectStartMonth) { |
||||
let startTime = e.selectOneYear + '-' + e.selectStartMonth + '-' + 1 + ' ' + 0 + ':' + 0 +':'+ 0 |
||||
let endTime = e.selectTwoYear + '-' + e.selectEndMonth + '-' + 31 + ' ' + 23 + ':' + 59 +':'+ 59 |
||||
console.log(startTime) |
||||
console.log(endTime) |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择正确时间区段','确定',config); |
||||
} |
||||
}else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择正确时间区段','确定',config); |
||||
} |
||||
} |
||||
selectStartYear:any = (new Date()).getFullYear() //开始年份
|
||||
selectEndYear:any = (new Date()).getFullYear() //结束年份
|
||||
//按年查询
|
||||
yearSubmit (e) { |
||||
if (e.selectEndYear >= e.selectStartYear) { |
||||
let startTime = e.selectStartYear + '-' + 1 + '-' + 1 + ' ' + 0 + ':' + 0 +':'+ 0 |
||||
let endTime = e.selectEndYear + '-' + 12 + '-' + 31 + ' ' + 23 + ':' + 59 +':'+ 59 |
||||
console.log(startTime) |
||||
console.log(endTime) |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择正确时间区段','确定',config); |
||||
} |
||||
} |
||||
//年或月点击
|
||||
dateChange(){ |
||||
this.forArr.forEach(item => { |
||||
item.echart.dispose() |
||||
}) |
||||
|
||||
if(this.selectType == "year"){ |
||||
this.oneInit(this.date2,this.dateNum2) |
||||
this.twoInit(this.date2,this.dateNum2,'year') |
||||
} |
||||
if(this.selectType == "month"){ |
||||
this.oneInit(this.date,this.dateNum) |
||||
this.twoInit(this.date,this.dateNum,'month') |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
forArr = [{id:'gaoceng',name:'高层',echart:null}, |
||||
{id:'dixia',name:'地下',echart:null}, |
||||
{id:'guidao',name:'轨道交通',echart:null}, |
||||
{id:'huagong',name:'化工生产',echart:null}, |
||||
{id:'chuguan',name:'储罐类',echart:null}, |
||||
{id:'changfang',name:'厂房',echart:null}, |
||||
{id:'gujianzhu',name:'古建筑',echart:null}, |
||||
{id:'shichang',name:'商市场',echart:null}, |
||||
{id:'yiyuan',name:'医院',echart:null}, |
||||
{id:'xuexiao',name:'学校',echart:null}, |
||||
{id:'binguan',name:'宾馆',echart:null}, |
||||
{id:'yule',name:'娱乐场所',echart:null}, |
||||
{id:'canyin',name:'餐饮业',echart:null}, |
||||
{id:'yingyuan',name:'影剧院',echart:null}, |
||||
{id:'zhanlan',name:'展览建筑',echart:null}, |
||||
{id:'suidao',name:'隧道',echart:null}] |
||||
|
||||
|
||||
date = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月','9月'] |
||||
dateNum = [270, 253, 244, 199, 189, 173, 160, 198,200] |
||||
|
||||
date2 = ['2019', '2020'] |
||||
dateNum2 = [220, 180] |
||||
|
||||
//新增数量统计
|
||||
oneInit (date,dateNum) { |
||||
var chartQusj = echarts.init(document.getElementById('Line'), 'skinUpp'); |
||||
var option = { |
||||
grid: { |
||||
top: 70, |
||||
left:40, |
||||
right: 20, |
||||
bottom: 20, |
||||
}, |
||||
// 标题
|
||||
title: { |
||||
text: '新增数量统计', |
||||
top: -4, |
||||
left: 'center', |
||||
textStyle:{ |
||||
//文字颜色
|
||||
color:'#000', |
||||
fontSize: 22, |
||||
} |
||||
}, |
||||
//提示框
|
||||
tooltip: { |
||||
trigger: 'axis', |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0', |
||||
formatter: (params)=>{ |
||||
return this.serviceData.tableTooltip(this.serviceData.buildingType,params[0].name) |
||||
}, |
||||
position:this.serviceData.tableTooltipNoShow |
||||
}, |
||||
// x轴
|
||||
xAxis: { |
||||
type: 'category', |
||||
data: date, |
||||
axisLabel: { |
||||
color: "#000", //刻度线标签颜色
|
||||
}, |
||||
//设置坐标轴字体颜色和宽度
|
||||
axisLine: {
|
||||
lineStyle: { |
||||
color: "#000", |
||||
}, |
||||
}, |
||||
splitLine: {//分割线配置
|
||||
show:true, |
||||
lineStyle: { |
||||
color: '#999', |
||||
} |
||||
} |
||||
}, |
||||
// y轴
|
||||
yAxis: { |
||||
type: 'value', |
||||
name: '个', |
||||
axisLabel: { |
||||
color: "#000" //刻度线标签颜色
|
||||
}, |
||||
//设置坐标轴字体颜色和宽度
|
||||
axisLine: { |
||||
lineStyle: { |
||||
color: "#000", |
||||
} |
||||
} |
||||
}, |
||||
// 数据
|
||||
series: [{ |
||||
name: '新增数量', |
||||
type: 'line', |
||||
data: dateNum, |
||||
} |
||||
], |
||||
} |
||||
chartQusj.setOption(option); |
||||
} |
||||
|
||||
//剩余折线图
|
||||
twoInit (date,dateNum,typeName) { |
||||
this.forArr.forEach((item,key) => { |
||||
let that = this |
||||
item.echart = echarts.init(document.getElementById(item.id), 'skinUpp'); |
||||
var option = { |
||||
grid: { |
||||
top: 50, |
||||
left:40, |
||||
right: 20, |
||||
bottom: 20, |
||||
}, |
||||
// 标题
|
||||
title: { |
||||
text: item.name, |
||||
top: -4, |
||||
left: 'center', |
||||
textStyle:{ |
||||
//文字颜色
|
||||
color:'#000', |
||||
} |
||||
}, |
||||
//提示框
|
||||
tooltip: { |
||||
trigger: 'axis', |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0', |
||||
formatter: (params)=>{ |
||||
return this.serviceData.tableTooltip(this.serviceData.tableDataZhi,params[0].name) |
||||
} |
||||
}, |
||||
// x轴
|
||||
xAxis: { |
||||
type: 'category', |
||||
data: date, |
||||
axisLabel: { |
||||
color: "#000", //刻度线标签颜色
|
||||
}, |
||||
//设置坐标轴字体颜色和宽度
|
||||
axisLine: {
|
||||
lineStyle: { |
||||
color: "#000", |
||||
}, |
||||
}, |
||||
splitLine: {//分割线配置
|
||||
show:true, |
||||
lineStyle: { |
||||
color: '#999', |
||||
} |
||||
} |
||||
}, |
||||
// y轴
|
||||
yAxis: { |
||||
type: 'value', |
||||
name: '个', |
||||
axisLabel: { |
||||
color: "#000" //刻度线标签颜色
|
||||
}, |
||||
//设置坐标轴字体颜色和宽度
|
||||
axisLine: { |
||||
lineStyle: { |
||||
color: "#000", |
||||
} |
||||
} |
||||
}, |
||||
// 数据
|
||||
series: [{ |
||||
name: typeName, |
||||
type: 'line', |
||||
data: dateNum, |
||||
} |
||||
], |
||||
}; |
||||
item.echart.setOption(option,true); |
||||
// item.echart.on('click', (params) => {
|
||||
// console.log(params)
|
||||
// });
|
||||
item.echart.getZr().on('click',params=>{ |
||||
const pointInPixel= [params.offsetX, params.offsetY]; |
||||
if (item.echart.containPixel('grid',pointInPixel)) { |
||||
let xIndex=item.echart.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0]; |
||||
/*事件处理代码书写位置*/ |
||||
console.log(option.series[0].data[xIndex],option.xAxis.data[xIndex]) |
||||
|
||||
} |
||||
}); |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
<div class="box"> |
||||
<div class="topbox"> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">类型查询</button> |
||||
<button mat-stroked-button (click)="reverse()">区间选择</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="barEchart"> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,42 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.topbox{ |
||||
width: 100%; |
||||
height: 80px; |
||||
min-height: 80px; |
||||
border-bottom: 1px gray solid; |
||||
.btnbox{ |
||||
height: 80px; |
||||
display: flex; |
||||
flex-direction:column; |
||||
justify-content: space-around; |
||||
position: fixed; |
||||
top: 64px; |
||||
right: 4%; |
||||
width: 88px; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
|
||||
} |
||||
} |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
#barEchart{ |
||||
width: 100%; |
||||
height: 350px; |
||||
position: absolute; |
||||
left: 50%; |
||||
top: 50%; |
||||
transform: translate(-50%,-50%); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { AddUnitTwoTypeDetailsComponent } from './add-unit-two-type-details.component'; |
||||
|
||||
describe('AddUnitTwoTypeDetailsComponent', () => { |
||||
let component: AddUnitTwoTypeDetailsComponent; |
||||
let fixture: ComponentFixture<AddUnitTwoTypeDetailsComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ AddUnitTwoTypeDetailsComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(AddUnitTwoTypeDetailsComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,111 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
import { ActivatedRoute } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-add-unit-two-type-details', |
||||
templateUrl: './add-unit-two-type-details.component.html', |
||||
styleUrls: ['./add-unit-two-type-details.component.scss'] |
||||
}) |
||||
export class AddUnitTwoTypeDetailsComponent implements OnInit { |
||||
|
||||
constructor(public route: ActivatedRoute,private router: Router) { } |
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_type']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_time']) |
||||
} |
||||
|
||||
organizationName:String |
||||
buildingTypeName:String |
||||
|
||||
ngOnInit(): void { |
||||
this.route.queryParams.subscribe(params => { |
||||
this.organizationName = params['organizationName']; |
||||
this.buildingTypeName = params['buildingTypeName']; |
||||
}); |
||||
window.setTimeout(()=>{ |
||||
this.detailEcharts() |
||||
}) |
||||
} |
||||
topTextlabel = { |
||||
show: true, // 开启显示
|
||||
position: 'top', // 在上方显示
|
||||
distance: 10, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
|
||||
verticalAlign: 'middle', |
||||
textStyle: { // 数值样式
|
||||
color: 'black', |
||||
fontSize: 12 |
||||
} |
||||
}//柱状图数值顶部显示
|
||||
zhongNameData = ["浦东中队","黄埔中队","徐汇中队","长宁中队","静安中队","普陀中队","虹口中队","杨浦中队","闵行中队","宝山中队","嘉定中队"] |
||||
zhongNumData = [200,190,180,170,160,150,140,130,120,110,100] |
||||
detailEcharts(){ |
||||
var detailPlanEchart = echarts.init(document.getElementById('barEchart'));
|
||||
var option = { |
||||
title: { |
||||
text: this.buildingTypeName + '(' +this.organizationName + ')', |
||||
left: "center", |
||||
textStyle: { |
||||
fontSize: 28 |
||||
} |
||||
}, |
||||
xAxis: { |
||||
type: 'category', |
||||
data: this.zhongNameData, |
||||
// axisLabel: this.axisLabel
|
||||
}, |
||||
yAxis: { |
||||
type: 'value' |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(params) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
series: [{ |
||||
data: this.zhongNumData, |
||||
type: 'bar', |
||||
showBackground: true, |
||||
barWidth :'58', |
||||
backgroundStyle: { |
||||
color: 'rgba(220, 220, 220, 0.8)' |
||||
}, |
||||
label: this.topTextlabel |
||||
}] |
||||
}; |
||||
detailPlanEchart.setOption(option); |
||||
} |
||||
|
||||
|
||||
tableTooltip(params:any){ |
||||
var data = [ |
||||
{name:params.name,number:params.value,zhanbi:(params.value/1340 * 100).toFixed(2) + "%"} |
||||
] |
||||
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;">'+params.name+'</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<data.length;i++){ |
||||
res+='<tr>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].name+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].number+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[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 |
||||
} |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
<div class="box"> |
||||
<div class="topbox"> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">类型统计</button> |
||||
<button mat-stroked-button (click)="reverse()">区间选择</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="pie"> |
||||
|
||||
</div> |
||||
<div> |
||||
<div class="publicCss" id="gaoceng"></div> |
||||
<div class="publicCss" id="dixia"></div> |
||||
<div class="publicCss" id="guidao"></div> |
||||
<div class="publicCss" id="huagong"></div> |
||||
<div class="publicCss" id="chuguan"></div> |
||||
<div class="publicCss" id="changfang"></div> |
||||
<div class="publicCss" id="gujianzhu"></div> |
||||
<div class="publicCss" id="shichang"></div> |
||||
<div class="publicCss" id="yiyuan"></div> |
||||
<div class="publicCss" id="xuexiao"></div> |
||||
<div class="publicCss" id="binguan"></div> |
||||
<div class="publicCss" id="yule"></div> |
||||
<div class="publicCss" id="canyin"></div> |
||||
<div class="publicCss" id="yingyuan"></div> |
||||
<div class="publicCss" id="zhanlan"></div> |
||||
<div class="publicCss" id="suidao"></div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
@ -0,0 +1,45 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.topbox{ |
||||
width: 100%; |
||||
height: 80px; |
||||
min-height: 80px; |
||||
border-bottom: 1px gray solid; |
||||
.btnbox{ |
||||
height: 80px; |
||||
display: flex; |
||||
flex-direction:column; |
||||
justify-content: space-around; |
||||
position: fixed; |
||||
top: 64px; |
||||
right: 4%; |
||||
width: 88px; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
|
||||
} |
||||
} |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
} |
||||
#pie{ |
||||
width: 100%; |
||||
height: 450px; |
||||
} |
||||
} |
||||
.publicCss{ |
||||
height: 350px; |
||||
width: 50%; |
||||
display: inline-block; |
||||
box-sizing: border-box; |
||||
padding: 20px; |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { AddUnitTwoTypeStatisticsComponent } from './add-unit-two-type-statistics.component'; |
||||
|
||||
describe('AddUnitTwoTypeStatisticsComponent', () => { |
||||
let component: AddUnitTwoTypeStatisticsComponent; |
||||
let fixture: ComponentFixture<AddUnitTwoTypeStatisticsComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ AddUnitTwoTypeStatisticsComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(AddUnitTwoTypeStatisticsComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,297 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-add-unit-two-type-statistics', |
||||
templateUrl: './add-unit-two-type-statistics.component.html', |
||||
styleUrls: ['./add-unit-two-type-statistics.component.scss'] |
||||
}) |
||||
export class AddUnitTwoTypeStatisticsComponent implements OnInit { |
||||
|
||||
constructor(private router: Router) { } |
||||
|
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_type']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_time']) |
||||
} |
||||
ngOnInit(): void { |
||||
window.setTimeout(()=>{ |
||||
this.initCharts() |
||||
this.barEcharts() |
||||
},0) |
||||
} |
||||
|
||||
axisLabel = { |
||||
interval: 0,
|
||||
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 |
||||
} |
||||
}//柱状图数值顶部显示
|
||||
|
||||
tableDataZhi = [ {name:"浦东支队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔支队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安支队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀支队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口支队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦支队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行支队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山支队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定支队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江支队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山支队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明支队",number:"55",zhanbi:"0.3%"} ] |
||||
tableDataZhong = [ {name:"浦东中队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔中队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安中队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀中队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口中队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦中队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行中队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山中队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定中队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江中队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山中队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明中队",number:"55",zhanbi:"0.3%"} ] |
||||
zhiNameData = ["浦东支队","黄埔支队","徐汇支队","长宁支队","静安支队","普陀支队","虹口支队","杨浦支队","闵行支队","宝山支队","嘉定支队","松江支队","金山支队","崇明支队"] |
||||
zhiNumData = [200,190,180,170,160,150,140,130,120,110,100,90,80,70] |
||||
forArr = [{id:'gaoceng',name:'高层'}, |
||||
{id:'dixia',name:'地下'}, |
||||
{id:'guidao',name:'轨道交通'}, |
||||
{id:'huagong',name:'化工生产'}, |
||||
{id:'chuguan',name:'储罐类'}, |
||||
{id:'changfang',name:'厂房'}, |
||||
{id:'gujianzhu',name:'古建筑'}, |
||||
{id:'shichang',name:'商市场'}, |
||||
{id:'yiyuan',name:'医院'}, |
||||
{id:'xuexiao',name:'学校'}, |
||||
{id:'binguan',name:'宾馆'}, |
||||
{id:'yule',name:'娱乐场所'}, |
||||
{id:'canyin',name:'餐饮业'}, |
||||
{id:'yingyuan',name:'影剧院'}, |
||||
{id:'zhanlan',name:'展览建筑'}, |
||||
{id:'suidao',name:'隧道'}] |
||||
|
||||
/* 顶部饼状图 */ |
||||
initCharts(){ |
||||
let indexBzt = echarts.init(document.getElementById('pie')); |
||||
let options={ |
||||
title: { |
||||
text: '新增单位统计(8900家)', |
||||
left: 'center', |
||||
top: "7%", |
||||
textStyle: { |
||||
fontSize:26 |
||||
} |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhi,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0', |
||||
position: function (point, params, dom, rect, size) { |
||||
// 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
|
||||
// 提示框位置
|
||||
var x = 0; // x坐标位置
|
||||
var y = 0; // y坐标位置
|
||||
|
||||
// 当前鼠标位置
|
||||
var pointX = point[0]; |
||||
var pointY = point[1]; |
||||
|
||||
// 外层div大小
|
||||
// var viewWidth = size.viewSize[0];
|
||||
// var viewHeight = size.viewSize[1];
|
||||
|
||||
// 提示框大小
|
||||
var boxWidth = size.contentSize[0]; |
||||
var boxHeight = size.contentSize[1]; |
||||
|
||||
// boxWidth > pointX 说明鼠标左边放不下提示框
|
||||
if (boxWidth > pointX) { |
||||
x = 35; |
||||
} else { // 左边放的下
|
||||
x = pointX + 80; |
||||
} |
||||
|
||||
// boxHeight > pointY 说明鼠标上边放不下提示框
|
||||
if (boxHeight > pointY) { |
||||
y = 65; |
||||
} else { // 上边放得下
|
||||
y = pointY - boxHeight; |
||||
} |
||||
|
||||
return [pointX, pointY]; |
||||
} |
||||
}, |
||||
legend: { |
||||
orient: 'vertical', |
||||
right: 150, |
||||
top:80, |
||||
data: ['高层', '地下', '轨道交通', '化工生产', '储罐类' , '厂房','古建筑', '商市场', '医院', '学校', '宾馆' , '娱乐场所','餐饮业', '影剧院', '展览建筑' , '隧道'] |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: '访问来源', |
||||
type: 'pie', |
||||
radius: '60%', |
||||
center: ['50%', '60%'], |
||||
label:{ |
||||
show:true, |
||||
fontSize:13, |
||||
formatter:'{b}{c}家\n{d|({d}%)}', |
||||
rich: { |
||||
d: { |
||||
align: 'center', |
||||
} |
||||
}, |
||||
}, |
||||
data: [ |
||||
{value: 500, name: '高层'}, |
||||
{value: 800, name: '地下'}, |
||||
{value: 900, name: '轨道交通'}, |
||||
{value: 800, name: '化工生产'}, |
||||
{value: 1200, name: '储罐类'}, |
||||
{value: 1500, name: '厂房'}, |
||||
{value: 1400, name: '古建筑'}, |
||||
{value: 600, name: '商市场'}, |
||||
{value: 568, name: '医院'}, |
||||
{value: 888, name: '学校'}, |
||||
{value: 485, name: '宾馆'}, |
||||
{value: 966, name: '娱乐场所'}, |
||||
{value: 789, name: '餐饮业'}, |
||||
{value: 500, name: '影剧院'}, |
||||
{value: 1025, name: '展览建筑'}, |
||||
{value: 600, name: '隧道'} |
||||
], |
||||
emphasis: { |
||||
itemStyle: { |
||||
shadowBlur: 10, |
||||
shadowOffsetX: 0, |
||||
shadowColor: 'rgba(0, 0, 0, 0.5)' |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}; |
||||
indexBzt.on('click', (params) => { |
||||
// this.router.navigateByUrl('/statisticanalysis/buildingType_two_forward');
|
||||
}); |
||||
indexBzt.setOption(options); |
||||
} |
||||
//柱状图
|
||||
barEcharts(){ |
||||
this.forArr.forEach(item=>{ |
||||
let _this = this |
||||
let addEchart = echarts.init(document.getElementById(item.id)); |
||||
let option = { |
||||
title: { |
||||
text: item.name, |
||||
left: "center", |
||||
top: "15", |
||||
textStyle: { |
||||
fontSize: 23 |
||||
} |
||||
}, |
||||
xAxis: { |
||||
type: 'category', |
||||
data: this.zhiNameData, |
||||
axisLabel: this.axisLabel |
||||
}, |
||||
yAxis: { |
||||
type: 'value' |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhong,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
series: [{ |
||||
data: this.zhiNumData, |
||||
type: 'bar', |
||||
showBackground: true, |
||||
backgroundStyle: { |
||||
color: 'rgba(220, 220, 220, 0.8)' |
||||
}, |
||||
barWidth :'28', |
||||
label: this.topTextlabel |
||||
}] |
||||
}; |
||||
addEchart.setOption(option); |
||||
addEchart.on('click', (params) => { |
||||
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_typeDetails'],{queryParams:{'organizationName':params.name,'buildingTypeName':item.name}}) |
||||
}); |
||||
}) |
||||
|
||||
} |
||||
//提示框表格
|
||||
tableTooltip(dataArr,title:string){ |
||||
let data = dataArr |
||||
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:26px;text-align: center;display:block;">'+title+'</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<data.length;i++){ |
||||
res+='<tr>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].name+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].number+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[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 |
||||
} |
||||
|
||||
} |
@ -1 +1,4 @@
|
||||
<p>building-type-one works!</p> |
||||
<body> |
||||
<!--饼状图 --> |
||||
<div id="indexBzt" style="width: 100%;height: 100%;"></div> |
||||
</body> |
@ -0,0 +1,8 @@
|
||||
.tishi{ |
||||
width: 100%; |
||||
height: 100%; |
||||
span{ |
||||
font-size: 25px; |
||||
text-align: center; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
<div class="box"> |
||||
<div class="topbox"> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">正向查询</button> |
||||
<button mat-stroked-button (click)="reverse()">反向查询</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="barEchart"> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,38 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.topbox{ |
||||
width: 100%; |
||||
height: 80px; |
||||
border-bottom: 1px gray solid; |
||||
.btnbox{ |
||||
display: flex; |
||||
flex-direction:column; |
||||
float: right; |
||||
justify-content: space-around; |
||||
height: 100%; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
margin-right:4%; |
||||
} |
||||
} |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
#barEchart{ |
||||
width: 100%; |
||||
height: 350px; |
||||
position: absolute; |
||||
left: 50%; |
||||
top: 50%; |
||||
transform: translate(-50%,-50%); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { BuildingTypeThreeDetailsComponent } from './building-type-three-details.component'; |
||||
|
||||
describe('BuildingTypeThreeDetailsComponent', () => { |
||||
let component: BuildingTypeThreeDetailsComponent; |
||||
let fixture: ComponentFixture<BuildingTypeThreeDetailsComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ BuildingTypeThreeDetailsComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(BuildingTypeThreeDetailsComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,110 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
import { ActivatedRoute } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-building-type-three-details', |
||||
templateUrl: './building-type-three-details.component.html', |
||||
styleUrls: ['./building-type-three-details.component.scss'] |
||||
}) |
||||
export class BuildingTypeThreeDetailsComponent implements OnInit { |
||||
|
||||
constructor(public route: ActivatedRoute,private router: Router) { } |
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_forward']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_reverse']) |
||||
} |
||||
|
||||
organizationName:String |
||||
buildingTypeName:String |
||||
|
||||
ngOnInit(): void { |
||||
this.route.queryParams.subscribe(params => { |
||||
this.organizationName = params['organizationName']; |
||||
this.buildingTypeName = params['buildingTypeName']; |
||||
}); |
||||
window.setTimeout(()=>{ |
||||
this.detailEcharts() |
||||
}) |
||||
} |
||||
topTextlabel = { |
||||
show: true, // 开启显示
|
||||
position: 'top', // 在上方显示
|
||||
distance: 10, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
|
||||
verticalAlign: 'middle', |
||||
textStyle: { // 数值样式
|
||||
color: 'black', |
||||
fontSize: 12 |
||||
} |
||||
}//柱状图数值顶部显示
|
||||
zhongNameData = ["浦东中队","黄埔中队","徐汇中队","长宁中队","静安中队","普陀中队","虹口中队","杨浦中队","闵行中队","宝山中队","嘉定中队"] |
||||
zhongNumData = [200,190,180,170,160,150,140,130,120,110,100] |
||||
detailEcharts(){ |
||||
var detailPlanEchart = echarts.init(document.getElementById('barEchart'));
|
||||
var option = { |
||||
title: { |
||||
text: this.buildingTypeName + '(' +this.organizationName + ')', |
||||
left: "center", |
||||
textStyle: { |
||||
fontSize: 28 |
||||
} |
||||
}, |
||||
xAxis: { |
||||
type: 'category', |
||||
data: this.zhongNameData, |
||||
// axisLabel: this.axisLabel
|
||||
}, |
||||
yAxis: { |
||||
type: 'value' |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(params) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
series: [{ |
||||
data: this.zhongNumData, |
||||
type: 'bar', |
||||
showBackground: true, |
||||
barWidth :'58', |
||||
backgroundStyle: { |
||||
color: 'rgba(220, 220, 220, 0.8)' |
||||
}, |
||||
label: this.topTextlabel |
||||
}] |
||||
}; |
||||
detailPlanEchart.setOption(option); |
||||
} |
||||
|
||||
|
||||
tableTooltip(params:any){ |
||||
var data = [ |
||||
{name:params.name,number:params.value,zhanbi:(params.value/1340 * 100).toFixed(2) + "%"} |
||||
] |
||||
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;">'+params.name+'</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<data.length;i++){ |
||||
res+='<tr>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].name+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].number+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[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 |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
<div class="box"> |
||||
<div class="topbox"> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">正向查询</button> |
||||
<button mat-stroked-button (click)="reverse()">反向查询</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="pie"> |
||||
|
||||
</div> |
||||
<div> |
||||
<div class="publicCss" id="gaoceng"></div> |
||||
<div class="publicCss" id="dixia"></div> |
||||
<div class="publicCss" id="guidao"></div> |
||||
<div class="publicCss" id="huagong"></div> |
||||
<div class="publicCss" id="chuguan"></div> |
||||
<div class="publicCss" id="changfang"></div> |
||||
<div class="publicCss" id="gujianzhu"></div> |
||||
<div class="publicCss" id="shichang"></div> |
||||
<div class="publicCss" id="yiyuan"></div> |
||||
<div class="publicCss" id="xuexiao"></div> |
||||
<div class="publicCss" id="binguan"></div> |
||||
<div class="publicCss" id="yule"></div> |
||||
<div class="publicCss" id="canyin"></div> |
||||
<div class="publicCss" id="yingyuan"></div> |
||||
<div class="publicCss" id="zhanlan"></div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
@ -0,0 +1,41 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.topbox{ |
||||
width: 100%; |
||||
height: 80px; |
||||
border-bottom: 1px gray solid; |
||||
.btnbox{ |
||||
display: flex; |
||||
flex-direction:column; |
||||
float: right; |
||||
justify-content: space-around; |
||||
height: 100%; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
margin-right:4%; |
||||
} |
||||
} |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
} |
||||
#pie{ |
||||
width: 100%; |
||||
height: 450px; |
||||
} |
||||
} |
||||
.publicCss{ |
||||
height: 350px; |
||||
width: 50%; |
||||
display: inline-block; |
||||
box-sizing: border-box; |
||||
padding: 20px; |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { BuildingTypeTwoForwardComponent } from './building-type-two-forward.component'; |
||||
|
||||
describe('BuildingTypeTwoForwardComponent', () => { |
||||
let component: BuildingTypeTwoForwardComponent; |
||||
let fixture: ComponentFixture<BuildingTypeTwoForwardComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ BuildingTypeTwoForwardComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(BuildingTypeTwoForwardComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,298 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-building-type-two-forward', |
||||
templateUrl: './building-type-two-forward.component.html', |
||||
styleUrls: ['./building-type-two-forward.component.scss'] |
||||
}) |
||||
export class BuildingTypeTwoForwardComponent implements OnInit { |
||||
|
||||
constructor(private router: Router) { } |
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_forward']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_reverse']) |
||||
} |
||||
ngOnInit(): void { |
||||
window.setTimeout(()=>{ |
||||
this.initCharts() |
||||
this.barEcharts() |
||||
},0) |
||||
} |
||||
axisLabel = { |
||||
interval: 0,
|
||||
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 |
||||
} |
||||
}//柱状图数值顶部显示
|
||||
|
||||
tableDataZhi = [ {name:"浦东支队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔支队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安支队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀支队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口支队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦支队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行支队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山支队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定支队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江支队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山支队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明支队",number:"55",zhanbi:"0.3%"} ] |
||||
tableDataZhong = [ {name:"浦东中队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔中队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安中队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀中队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口中队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦中队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行中队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山中队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定中队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江中队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山中队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明中队",number:"55",zhanbi:"0.3%"} ] |
||||
zhiNameData = ["浦东支队","黄埔支队","徐汇支队","长宁支队","静安支队","普陀支队","虹口支队","杨浦支队","闵行支队","宝山支队","嘉定支队","松江支队","金山支队","崇明支队",'青浦支队'] |
||||
zhiNumData = [200,190,180,170,160,150,140,130,120,110,100,90,80,70,60] |
||||
pieData = [ |
||||
{value: 500, name: '浦东支队'}, |
||||
{value: 800, name: '黄埔支队'}, |
||||
{value: 900, name: '徐汇支队'}, |
||||
{value: 800, name: '长宁支队'}, |
||||
{value: 1200, name: '静安支队'}, |
||||
{value: 1500, name: '普陀支队'}, |
||||
{value: 1400, name: '虹口支队'}, |
||||
{value: 600, name: '杨浦支队'}, |
||||
{value: 568, name: '闵行支队'}, |
||||
{value: 888, name: '宝山支队'}, |
||||
{value: 485, name: '嘉定支队'}, |
||||
{value: 966, name: '松江支队'}, |
||||
{value: 789, name: '金山支队'}, |
||||
{value: 500, name: '崇明支队'}, |
||||
{value: 1025, name: '展览建筑'}, |
||||
{value: 600, name: '青浦支队'} |
||||
] |
||||
buildingTypeName = ['高层','地下','轨道交通','化工生产','储罐类','厂房','古建筑','商市场','医院','学校','宾馆','娱乐场所','餐饮业','影剧院','展览建筑','隧道'] |
||||
buildingTypeNum = [200,190,180,170,160,150,140,130,120,110,100,90,80,70,60,50] |
||||
forArr = [{id:'gaoceng',name:'浦东支队'}, |
||||
{id:'dixia',name:'黄埔支队'}, |
||||
{id:'guidao',name:'徐汇支队'}, |
||||
{id:'huagong',name:'长宁支队'}, |
||||
{id:'chuguan',name:'静安支队'}, |
||||
{id:'changfang',name:'普陀支队'}, |
||||
{id:'gujianzhu',name:'虹口支队'}, |
||||
{id:'shichang',name:'杨浦支队'}, |
||||
{id:'yiyuan',name:'闵行支队'}, |
||||
{id:'xuexiao',name:'宝山支队'}, |
||||
{id:'binguan',name:'嘉定支队'}, |
||||
{id:'yule',name:'松江支队'}, |
||||
{id:'canyin',name:'金山支队'}, |
||||
{id:'yingyuan',name:'崇明支队'}, |
||||
{id:'zhanlan',name:'青浦支队'}, |
||||
] |
||||
|
||||
/* 顶部饼状图 */ |
||||
initCharts(){ |
||||
let indexBzt = echarts.init(document.getElementById('pie')); |
||||
let options={ |
||||
title: { |
||||
text: '组织机构统计(5500家)', |
||||
left: 'center', |
||||
top: "7%", |
||||
textStyle: { |
||||
fontSize:26 |
||||
} |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhi,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0', |
||||
position: function (point, params, dom, rect, size) { |
||||
// 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
|
||||
// 提示框位置
|
||||
var x = 0; // x坐标位置
|
||||
var y = 0; // y坐标位置
|
||||
|
||||
// 当前鼠标位置
|
||||
var pointX = point[0]; |
||||
var pointY = point[1]; |
||||
|
||||
// 外层div大小
|
||||
// var viewWidth = size.viewSize[0];
|
||||
// var viewHeight = size.viewSize[1];
|
||||
|
||||
// 提示框大小
|
||||
var boxWidth = size.contentSize[0]; |
||||
var boxHeight = size.contentSize[1]; |
||||
|
||||
// boxWidth > pointX 说明鼠标左边放不下提示框
|
||||
if (boxWidth > pointX) { |
||||
x = 35; |
||||
} else { // 左边放的下
|
||||
x = pointX + 80; |
||||
} |
||||
|
||||
// boxHeight > pointY 说明鼠标上边放不下提示框
|
||||
if (boxHeight > pointY) { |
||||
y = 65; |
||||
} else { // 上边放得下
|
||||
y = pointY - boxHeight; |
||||
} |
||||
|
||||
return [pointX, pointY]; |
||||
} |
||||
}, |
||||
legend: { |
||||
orient: 'vertical', |
||||
right: 150, |
||||
top:80, |
||||
data:this.zhiNameData |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: '访问来源', |
||||
type: 'pie', |
||||
radius: '60%', |
||||
center: ['50%', '60%'], |
||||
label:{ |
||||
show:true, |
||||
fontSize:13, |
||||
formatter:'{b}{c}家\n{d|({d}%)}', |
||||
rich: { |
||||
d: { |
||||
align: 'center', |
||||
} |
||||
}, |
||||
}, |
||||
data: this.pieData, |
||||
emphasis: { |
||||
itemStyle: { |
||||
shadowBlur: 10, |
||||
shadowOffsetX: 0, |
||||
shadowColor: 'rgba(0, 0, 0, 0.5)' |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}; |
||||
indexBzt.on('click', (params) => { |
||||
// this.router.navigateByUrl('/statisticanalysis/buildingType_two_forward');
|
||||
}); |
||||
indexBzt.setOption(options); |
||||
} |
||||
//柱状图
|
||||
barEcharts(){ |
||||
this.forArr.forEach(item=>{ |
||||
let _this = this |
||||
let Echart = echarts.init(document.getElementById(item.id)); |
||||
let option = { |
||||
color: ['#3398DB'], |
||||
title: { |
||||
text: item.name, |
||||
left: "center", |
||||
top: "15", |
||||
textStyle: { |
||||
fontSize: 23 |
||||
} |
||||
}, |
||||
xAxis: { |
||||
type: 'category', |
||||
data: this.buildingTypeName, |
||||
axisLabel: this.axisLabel |
||||
}, |
||||
yAxis: { |
||||
type: 'value' |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhong,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
series: [{ |
||||
data: this.buildingTypeNum, |
||||
type: 'bar', |
||||
showBackground: true, |
||||
backgroundStyle: { |
||||
color: 'rgba(220, 220, 220, 0.8)' |
||||
}, |
||||
barWidth :'28', |
||||
label: this.topTextlabel |
||||
}] |
||||
}; |
||||
Echart.setOption(option); |
||||
Echart.on('click', (params) => { |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_three_details'],{queryParams:{'organizationName':item.name,'buildingTypeName':params.name}}) |
||||
}); |
||||
}) |
||||
|
||||
} |
||||
//提示框表格
|
||||
tableTooltip(dataArr,title:string){ |
||||
let data = dataArr |
||||
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:26px;text-align: center;display:block;">'+title+'</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<data.length;i++){ |
||||
res+='<tr>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].name+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].number+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[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 |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
<div class="box"> |
||||
<div class="topbox"> |
||||
<div class="btnbox"> |
||||
<button mat-stroked-button (click)="forward()">正向查询</button> |
||||
<button mat-stroked-button (click)="reverse()">反向查询</button> |
||||
</div> |
||||
</div> |
||||
<div class="echartsbox"> |
||||
<div id="pie"> |
||||
|
||||
</div> |
||||
<div> |
||||
<div class="publicCss" id="gaoceng"></div> |
||||
<div class="publicCss" id="dixia"></div> |
||||
<div class="publicCss" id="guidao"></div> |
||||
<div class="publicCss" id="huagong"></div> |
||||
<div class="publicCss" id="chuguan"></div> |
||||
<div class="publicCss" id="changfang"></div> |
||||
<div class="publicCss" id="gujianzhu"></div> |
||||
<div class="publicCss" id="shichang"></div> |
||||
<div class="publicCss" id="yiyuan"></div> |
||||
<div class="publicCss" id="xuexiao"></div> |
||||
<div class="publicCss" id="binguan"></div> |
||||
<div class="publicCss" id="yule"></div> |
||||
<div class="publicCss" id="canyin"></div> |
||||
<div class="publicCss" id="yingyuan"></div> |
||||
<div class="publicCss" id="zhanlan"></div> |
||||
<div class="publicCss" id="suidao"></div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
@ -0,0 +1,41 @@
|
||||
.box{ |
||||
width: 100%; |
||||
height: 92%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
overflow: hidden; |
||||
position: relative; |
||||
.topbox{ |
||||
width: 100%; |
||||
height: 80px; |
||||
border-bottom: 1px gray solid; |
||||
.btnbox{ |
||||
display: flex; |
||||
flex-direction:column; |
||||
float: right; |
||||
justify-content: space-around; |
||||
height: 100%; |
||||
button{ |
||||
width: 88px; |
||||
height: 36px; |
||||
} |
||||
margin-right:4%; |
||||
} |
||||
} |
||||
.echartsbox{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow: auto; |
||||
} |
||||
#pie{ |
||||
width: 100%; |
||||
height: 450px; |
||||
} |
||||
} |
||||
.publicCss{ |
||||
height: 350px; |
||||
width: 50%; |
||||
display: inline-block; |
||||
box-sizing: border-box; |
||||
padding: 20px; |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { BuildingTypeTwoReverseComponent } from './building-type-two-reverse.component'; |
||||
|
||||
describe('BuildingTypeTwoReverseComponent', () => { |
||||
let component: BuildingTypeTwoReverseComponent; |
||||
let fixture: ComponentFixture<BuildingTypeTwoReverseComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ BuildingTypeTwoReverseComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(BuildingTypeTwoReverseComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,296 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { Router } from '@angular/router'; |
||||
declare var echarts: any; |
||||
@Component({ |
||||
selector: 'app-building-type-two-reverse', |
||||
templateUrl: './building-type-two-reverse.component.html', |
||||
styleUrls: ['./building-type-two-reverse.component.scss'] |
||||
}) |
||||
export class BuildingTypeTwoReverseComponent implements OnInit { |
||||
|
||||
constructor(private router: Router) { } |
||||
|
||||
forward(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_forward']) |
||||
} |
||||
reverse(){ |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_two_reverse']) |
||||
} |
||||
ngOnInit(): void { |
||||
window.setTimeout(()=>{ |
||||
this.initCharts() |
||||
this.barEcharts() |
||||
},0) |
||||
} |
||||
|
||||
axisLabel = { |
||||
interval: 0,
|
||||
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 |
||||
} |
||||
}//柱状图数值顶部显示
|
||||
|
||||
tableDataZhi = [ {name:"浦东支队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔支队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安支队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀支队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口支队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦支队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行支队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山支队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇支队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁支队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定支队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江支队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山支队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明支队",number:"55",zhanbi:"0.3%"} ] |
||||
tableDataZhong = [ {name:"浦东中队",number:"156",zhanbi:"3%"}, |
||||
{name:"黄埔中队",number:"144",zhanbi:"2.8%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"静安中队",number:"120",zhanbi:"1.3%"}, |
||||
{name:"普陀中队",number:"100",zhanbi:"1.1%"}, |
||||
{name:"虹口中队",number:"95",zhanbi:"1%"}, |
||||
{name:"杨浦中队",number:"90",zhanbi:"0.9%"}, |
||||
{name:"闵行中队",number:"88",zhanbi:"0.8%"}, |
||||
{name:"宝山中队",number:"83",zhanbi:"0.7%"}, |
||||
{name:"徐汇中队",number:"133",zhanbi:"2.1%"}, |
||||
{name:"长宁中队",number:"122",zhanbi:"1.6%"}, |
||||
{name:"嘉定中队",number:"78",zhanbi:"0.6%"}, |
||||
{name:"松江中队",number:"75",zhanbi:"0.5%"}, |
||||
{name:"金山中队",number:"65",zhanbi:"0.4%"}, |
||||
{name:"崇明中队",number:"55",zhanbi:"0.3%"} ] |
||||
zhiNameData = ["浦东支队","黄埔支队","徐汇支队","长宁支队","静安支队","普陀支队","虹口支队","杨浦支队","闵行支队","宝山支队","嘉定支队","松江支队","金山支队","崇明支队"] |
||||
zhiNumData = [200,190,180,170,160,150,140,130,120,110,100,90,80,70] |
||||
forArr = [{id:'gaoceng',name:'高层'}, |
||||
{id:'dixia',name:'地下'}, |
||||
{id:'guidao',name:'轨道交通'}, |
||||
{id:'huagong',name:'化工生产'}, |
||||
{id:'chuguan',name:'储罐类'}, |
||||
{id:'changfang',name:'厂房'}, |
||||
{id:'gujianzhu',name:'古建筑'}, |
||||
{id:'shichang',name:'商市场'}, |
||||
{id:'yiyuan',name:'医院'}, |
||||
{id:'xuexiao',name:'学校'}, |
||||
{id:'binguan',name:'宾馆'}, |
||||
{id:'yule',name:'娱乐场所'}, |
||||
{id:'canyin',name:'餐饮业'}, |
||||
{id:'yingyuan',name:'影剧院'}, |
||||
{id:'zhanlan',name:'展览建筑'}, |
||||
{id:'suidao',name:'隧道'}] |
||||
|
||||
/* 顶部饼状图 */ |
||||
initCharts(){ |
||||
let indexBzt = echarts.init(document.getElementById('pie')); |
||||
let options={ |
||||
title: { |
||||
text: '建筑类型统计(8900家)', |
||||
left: 'center', |
||||
top: "7%", |
||||
textStyle: { |
||||
fontSize:26 |
||||
} |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhi,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0', |
||||
position: function (point, params, dom, rect, size) { |
||||
// 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
|
||||
// 提示框位置
|
||||
var x = 0; // x坐标位置
|
||||
var y = 0; // y坐标位置
|
||||
|
||||
// 当前鼠标位置
|
||||
var pointX = point[0]; |
||||
var pointY = point[1]; |
||||
|
||||
// 外层div大小
|
||||
// var viewWidth = size.viewSize[0];
|
||||
// var viewHeight = size.viewSize[1];
|
||||
|
||||
// 提示框大小
|
||||
var boxWidth = size.contentSize[0]; |
||||
var boxHeight = size.contentSize[1]; |
||||
|
||||
// boxWidth > pointX 说明鼠标左边放不下提示框
|
||||
if (boxWidth > pointX) { |
||||
x = 35; |
||||
} else { // 左边放的下
|
||||
x = pointX + 80; |
||||
} |
||||
|
||||
// boxHeight > pointY 说明鼠标上边放不下提示框
|
||||
if (boxHeight > pointY) { |
||||
y = 65; |
||||
} else { // 上边放得下
|
||||
y = pointY - boxHeight; |
||||
} |
||||
|
||||
return [pointX, pointY]; |
||||
} |
||||
}, |
||||
legend: { |
||||
orient: 'vertical', |
||||
right: 150, |
||||
top:80, |
||||
data: ['高层', '地下', '轨道交通', '化工生产', '储罐类' , '厂房','古建筑', '商市场', '医院', '学校', '宾馆' , '娱乐场所','餐饮业', '影剧院', '展览建筑' , '隧道'] |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: '访问来源', |
||||
type: 'pie', |
||||
radius: '60%', |
||||
center: ['50%', '60%'], |
||||
label:{ |
||||
show:true, |
||||
fontSize:13, |
||||
formatter:'{b}{c}家\n{d|({d}%)}', |
||||
rich: { |
||||
d: { |
||||
align: 'center', |
||||
} |
||||
}, |
||||
}, |
||||
data: [ |
||||
{value: 500, name: '高层'}, |
||||
{value: 800, name: '地下'}, |
||||
{value: 900, name: '轨道交通'}, |
||||
{value: 800, name: '化工生产'}, |
||||
{value: 1200, name: '储罐类'}, |
||||
{value: 1500, name: '厂房'}, |
||||
{value: 1400, name: '古建筑'}, |
||||
{value: 600, name: '商市场'}, |
||||
{value: 568, name: '医院'}, |
||||
{value: 888, name: '学校'}, |
||||
{value: 485, name: '宾馆'}, |
||||
{value: 966, name: '娱乐场所'}, |
||||
{value: 789, name: '餐饮业'}, |
||||
{value: 500, name: '影剧院'}, |
||||
{value: 1025, name: '展览建筑'}, |
||||
{value: 600, name: '隧道'} |
||||
], |
||||
emphasis: { |
||||
itemStyle: { |
||||
shadowBlur: 10, |
||||
shadowOffsetX: 0, |
||||
shadowColor: 'rgba(0, 0, 0, 0.5)' |
||||
} |
||||
} |
||||
} |
||||
] |
||||
}; |
||||
indexBzt.on('click', (params) => { |
||||
// this.router.navigateByUrl('/statisticanalysis/buildingType_two_forward');
|
||||
}); |
||||
indexBzt.setOption(options); |
||||
} |
||||
//柱状图
|
||||
barEcharts(){ |
||||
this.forArr.forEach(item=>{ |
||||
let _this = this |
||||
let addEchart = echarts.init(document.getElementById(item.id)); |
||||
let option = { |
||||
title: { |
||||
text: item.name, |
||||
left: "center", |
||||
top: "15", |
||||
textStyle: { |
||||
fontSize: 23 |
||||
} |
||||
}, |
||||
xAxis: { |
||||
type: 'category', |
||||
data: this.zhiNameData, |
||||
axisLabel: this.axisLabel |
||||
}, |
||||
yAxis: { |
||||
type: 'value' |
||||
}, |
||||
tooltip: { |
||||
trigger: 'item', |
||||
formatter: (params)=>{ |
||||
return this.tableTooltip(this.tableDataZhong,params.name) |
||||
}, |
||||
backgroundColor:'rgba(255,255,255,1)',//通过设置rgba调节背景颜色与透明度
|
||||
borderWidth:'1', |
||||
borderRadius :'0' |
||||
}, |
||||
series: [{ |
||||
data: this.zhiNumData, |
||||
type: 'bar', |
||||
showBackground: true, |
||||
backgroundStyle: { |
||||
color: 'rgba(220, 220, 220, 0.8)' |
||||
}, |
||||
barWidth :'28', |
||||
label: this.topTextlabel |
||||
}] |
||||
}; |
||||
addEchart.setOption(option); |
||||
addEchart.on('click', (params) => { |
||||
this.router.navigate(['/statisticanalysis/buildingType_one/buildingType_three_details'],{queryParams:{'organizationName':params.name,'buildingTypeName':item.name}}) |
||||
}); |
||||
}) |
||||
|
||||
} |
||||
//提示框表格
|
||||
tableTooltip(dataArr,title:string){ |
||||
let data = dataArr |
||||
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:26px;text-align: center;display:block;">'+title+'</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<data.length;i++){ |
||||
res+='<tr>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].name+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[i].number+'</td>' |
||||
res+='<td style="text-align:center;border:1px solid #000000">'+data[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 |
||||
} |
||||
} |
Loading…
Reference in new issue