Commit 58553072 authored by wangqinghua's avatar wangqinghua

update

parent 1a1c0355
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</nz-select> </nz-select>
</div> </div>
<div nz-col nzSpan="3"> <div nz-col nzSpan="3">
<nz-select style="width: 100%;" nzPlaceHolder="选择资源" [(ngModel)]="obj.hostid" (ngModelChange)="getListIO()"> <nz-select style="width: 100%;" nzPlaceHolder="选择主机资源" [(ngModel)]="obj.hostid" (ngModelChange)="getListIO()">
<ng-container *ngFor="let item of hostList;"> <ng-container *ngFor="let item of hostList;">
<nz-option nzLabel="{{item.name}}" nzValue="{{item.hostid}}"></nz-option> <nz-option nzLabel="{{item.name}}" nzValue="{{item.hostid}}"></nz-option>
</ng-container> </ng-container>
......
...@@ -42,6 +42,8 @@ export class FlowTrendComponent implements OnInit { ...@@ -42,6 +42,8 @@ export class FlowTrendComponent implements OnInit {
//图表 //图表
chartOption; chartOption;
inEchartData;
outEchartData;
constructor(private topologySer: TopologyService, private overAllSer: OverAllService, constructor(private topologySer: TopologyService, private overAllSer: OverAllService,
private message: NzMessageService,private datePipe:DatePipe) { private message: NzMessageService,private datePipe:DatePipe) {
...@@ -51,6 +53,7 @@ export class FlowTrendComponent implements OnInit { ...@@ -51,6 +53,7 @@ export class FlowTrendComponent implements OnInit {
const today = new Date().getTime(); const today = new Date().getTime();
this.obj.startTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 00:00:00"; this.obj.startTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 00:00:00";
this.obj.endTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 23:59:59"; this.obj.endTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 23:59:59";
this.getGroup();
} }
//获取分组 //获取分组
...@@ -59,6 +62,8 @@ export class FlowTrendComponent implements OnInit { ...@@ -59,6 +62,8 @@ export class FlowTrendComponent implements OnInit {
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.groupList = res.data; this.groupList = res.data;
this.obj.groupid = this.groupList[0].groupid +"";
this.onchange();
} }
} }
); );
...@@ -76,7 +81,7 @@ export class FlowTrendComponent implements OnInit { ...@@ -76,7 +81,7 @@ export class FlowTrendComponent implements OnInit {
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.hostList = res.data; this.hostList = res.data;
this.obj.hostid = this.hostList[0].hostList; this.obj.hostid = this.hostList[0].hostid +"";
this.getEcharts(null); this.getEcharts(null);
} }
} }
...@@ -96,9 +101,19 @@ export class FlowTrendComponent implements OnInit { ...@@ -96,9 +101,19 @@ export class FlowTrendComponent implements OnInit {
this.topologySer.findTrendData(data).subscribe( this.topologySer.findTrendData(data).subscribe(
(res) => { (res) => {
if(res.errCode == 10000){ if(res.errCode == 10000){
if(res.data){
this.inEchartData = res.data;
}else{
this.message.info("图表暂无数据");
}
data.type = "out"; data.type = "out";
this.topologySer.findTrendData(data).subscribe( this.topologySer.findTrendData(data).subscribe(
(res)=>{ (res)=>{
if(res.data){
this.outEchartData = res.data;
}else{
this.message.info("图表暂无数据");
}
this.setEacharts(); this.setEacharts();
} }
) )
...@@ -109,23 +124,7 @@ export class FlowTrendComponent implements OnInit { ...@@ -109,23 +124,7 @@ export class FlowTrendComponent implements OnInit {
); );
} }
//
setEacharts(){ setEacharts(){
let xAxisData = [];
let data1 = [];
let data2 = [];
let data3 = [];
let data4 = [];
for (let i = 0; i < 10; i++) {
xAxisData.push('Class' + i);
data1.push((Math.random() * 2).toFixed(2));
data2.push(-Math.random().toFixed(2));
data3.push((Math.random() * 5).toFixed(2));
data4.push((Math.random() + 0.3).toFixed(2));
}
let itemStyle = { let itemStyle = {
normal: { normal: {
}, },
...@@ -142,53 +141,62 @@ export class FlowTrendComponent implements OnInit { ...@@ -142,53 +141,62 @@ export class FlowTrendComponent implements OnInit {
backgroundColor: '#eee', backgroundColor: '#eee',
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
data: xAxisData, data: this.inEchartData.map(e=>{
name: 'X Axis', return e.clockDate;
}),
name: '时间',
silent: false, silent: false,
axisLine: {onZero: true}, axisLine: {onZero: true},
splitLine: {show: false}, splitLine: {show: false},
splitArea: {show: false} splitArea: {show: false},
axisLabel:{
margin: 10,
interval: 100000,
showMinLabel: true,
showMaxLabel: true,
textStyle: {
color: '#999',
fontSize: 12,
}
}
}, },
yAxis: { yAxis: {
inverse: true, inverse: true,
splitArea: {show: false} splitArea: {show: false},
type : 'value',
axisLabel:{ //Y轴数据
formatter:function(value){
return Math.abs(value)/10000; //负数取绝对值变正数
},
textStyle: {
color: '#666'
}
},
}, },
grid: { grid: {
left: 100 left: 100
}, },
series: [ series: [
{ {
name: 'bar', name: 'bar3',
type: 'bar',
stack: 'one',
itemStyle: itemStyle,
data: data1
},
{
name: 'bar2',
type: 'bar', type: 'bar',
stack: 'one', stack: 'one',
itemStyle: itemStyle, itemStyle: itemStyle,
data: data2 data: this.inEchartData.map(e=>{
return e.value_avg;
})
}, },
{ {
name: 'bar3', name: 'bar3',
type: 'bar', type: 'bar',
stack: 'two', stack: 'two',
itemStyle: itemStyle, itemStyle: itemStyle,
data: data3 data: this.outEchartData.map(e=>{
}, return -e.value_avg;
{ })
name: 'bar4',
type: 'bar',
stack: 'two',
itemStyle: itemStyle,
data: data4
} }
] ]
}; };
console.log(this.chartOption);
} }
//获取流量 //获取流量
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment