Browse Source

[完善]首页echarts数据显示

tianjin
邵佳豪 2 years ago
parent
commit
944b176d47
  1. 30
      src/app/statistic-analysis/addUnit/add-unit-two-type-statistics/add-unit-two-type-statistics.component.ts
  2. 22
      src/app/statistic-analysis/home/home.component.html
  3. 26
      src/app/statistic-analysis/home/home.component.scss
  4. 28
      src/app/statistic-analysis/home/home.component.ts

30
src/app/statistic-analysis/addUnit/add-unit-two-type-statistics/add-unit-two-type-statistics.component.ts

@ -527,10 +527,20 @@ export class AddUnitTwoTypeStatisticsComponent implements OnInit {
params.offsetY, params.offsetY,
])[0]; ])[0];
if (this.zhiorbuild == "zhi") { if (this.zhiorbuild == "zhi") {
if ( if (
(this.data.level == "0" || this.data.level == "1") && (this.data.level == "0" || this.data.level == "1") &&
this.tabledata[0].buildingTypes[xIndex].organizations.length >= 1 this.tabledata[0].buildingTypes[xIndex].organizations.length >= 1
) { ) {
this.router.navigate(["/statisticanalysis/CompangInfo"], {
queryParams: {
name: option.xAxis.data[xIndex],
type: 1,
jsid: this.lastId,
buildid: option.xAxis.id[xIndex],
},
});
return;
// 总队,支队跳转 // 总队,支队跳转
this.router.navigate( this.router.navigate(
["/statisticanalysis/addUnit_one/addUnit_two_typeDetails"], ["/statisticanalysis/addUnit_one/addUnit_two_typeDetails"],
@ -555,21 +565,19 @@ export class AddUnitTwoTypeStatisticsComponent implements OnInit {
}); });
} }
} else { } else {
// console.log(this.data.level)
// console.log(this.tabledata[0].organizations[xIndex].subOrganizations)
this.router.navigate(["/statisticanalysis/CompangInfo"], {
queryParams: {
name: option.xAxis.data[xIndex],
type: 1,
jsid: option.xAxis.id[xIndex],
buildid: this.lastId,
},
});
return
if ( if (
(this.data.level == "0" || this.data.level == "1") && (this.data.level == "0" || this.data.level == "1") &&
this.tabledata[0].organizations[xIndex].subOrganizations.length >= 1 this.tabledata[0].organizations[xIndex].subOrganizations.length >= 1
) { ) {
this.router.navigate(["/statisticanalysis/CompangInfo"], {
queryParams: {
name: option.xAxis.data[xIndex],
type: 1,
jsid: option.xAxis.id[xIndex],
buildid: this.lastId,
},
});
return;
//总队,支队跳转 //总队,支队跳转
this.router.navigate( this.router.navigate(
["/statisticanalysis/addUnit_one/addUnit_two_typeDetails"], ["/statisticanalysis/addUnit_one/addUnit_two_typeDetails"],

22
src/app/statistic-analysis/home/home.component.html

@ -15,7 +15,27 @@
<div id="tooltip" [hidden]="!isTooltip" [style.left]="mouseX" [style.top]="mouseY"> <div id="tooltip" [hidden]="!isTooltip" [style.left]="mouseX" [style.top]="mouseY">
<!-- 这里是浮窗的内容 --> <!-- 这里是浮窗的内容 -->
<div class="content"> <div class="content">
<span (click)="close()">x</span> <div class="countbox">
<div>
<span>区域名称:</span>
<span>
{{itemData.name}}
</span>
</div>
<div>
<span>单位数量:</span>
<span>
{{itemData.companyCount}}
</span>
</div>
<div>
<span>预案数量:</span>
<span>
{{itemData.planCount}}
</span>
</div>
</div>
<span class="close" (click)="close()">x</span>
</div> </div>
</div> </div>
<div class="number-area" id="number-area" style="z-index: 100;height: 125px;width: 185px;"> <div class="number-area" id="number-area" style="z-index: 100;height: 125px;width: 185px;">

26
src/app/statistic-analysis/home/home.component.scss

@ -28,19 +28,29 @@
} }
#tooltip { #tooltip {
width: 200px; width: 170px;
height: 100px; height: 90px;
position: fixed; position: fixed;
padding: 10px; background-color: rgba(0, 0, 0, 0.8);
background-color: pink; border-radius: 8px;
border: 1px solid #ccc;
z-index: 999; z-index: 999;
.content { .content {
width: 100%;
height: 100%;
position: relative; position: relative;
span { color: #fff;
font-size: 14px;
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
padding-left: 12px;
.close {
position: absolute; position: absolute;
right: 0; right: 8px;
top: 0; top: 3px;
cursor: pointer;
} }
} }
} }

28
src/app/statistic-analysis/home/home.component.ts

@ -36,6 +36,7 @@ export class HomeComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getechartsdata(); this.getechartsdata();
// this.getYearlyCompleteProgress(); // this.getYearlyCompleteProgress();
this.getEchartsItemData();
} }
ngAfterViewInit() { ngAfterViewInit() {
setTimeout(() => { setTimeout(() => {
@ -46,11 +47,27 @@ export class HomeComponent implements OnInit {
}, 0); }, 0);
} }
etEchartsItemData = [];
getEchartsItemData() {
this.http
.get("/api/StatisticsAnalysis/GetCountByOrg")
.subscribe((data: any) => {
console.log("统计数据", data);
this.etEchartsItemData = data;
});
}
myChart: any; myChart: any;
isTooltip = false; isTooltip = false;
mouseX; mouseX;
mouseY; mouseY;
itemData = {
name: "",
companyCount: 0,
planCount: 0,
};
echartsMap() { echartsMap() {
this.myChart = echarts.init(document.getElementById("chartMap")); this.myChart = echarts.init(document.getElementById("chartMap"));
let option: any = { let option: any = {
@ -89,10 +106,21 @@ export class HomeComponent implements OnInit {
series: [], series: [],
}; };
this.myChart.on("click", (params) => { this.myChart.on("click", (params) => {
if (this.etEchartsItemData.length === 0) {
alert("请数据加载完成后重试!");
return;
}
console.log("点击区域", params); console.log("点击区域", params);
this.isTooltip = true; this.isTooltip = true;
this.mouseX = params.event.event.clientX + "px"; this.mouseX = params.event.event.clientX + "px";
this.mouseY = params.event.event.clientY + "px"; this.mouseY = params.event.event.clientY + "px";
let name = params.name.substring(0, 2);
console.log("点击区域name", name);
let item = this.etEchartsItemData.find(
(v) => v.name.indexOf(name) !== -1
);
item ? (this.itemData = item) : null;
this.itemData.name = params.name;
}); });
echarts.registerMap("tianjin", this.mapData); echarts.registerMap("tianjin", this.mapData);
this.myChart.setOption(option); this.myChart.setOption(option);

Loading…
Cancel
Save