-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from BennieMeng/feature/node-resource-usage
node resource usage ui optimize
- Loading branch information
Showing
9 changed files
with
150 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { EcharsGaugeComponent } from './gauge/gauge.component'; | ||
import { EchartsGaugeComponent } from './gauge/gauge.component'; | ||
import { EchartsPieComponent } from './pie/pie.component'; | ||
@NgModule({ | ||
imports: [], | ||
exports: [ | ||
EcharsGaugeComponent | ||
EchartsGaugeComponent, | ||
EchartsPieComponent | ||
], | ||
declarations: [ | ||
EcharsGaugeComponent | ||
EchartsGaugeComponent, | ||
EchartsPieComponent | ||
] | ||
}) | ||
export class EchartsModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div #view class="box"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:host { | ||
height:300px; | ||
width: 300px; | ||
} | ||
.box{ | ||
width: 100%; | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { Component, ViewChild, AfterViewInit, Input } from '@angular/core'; | ||
import * as echarts from 'echarts'; | ||
import ECharts = echarts.ECharts; | ||
import EChartOption = echarts.EChartOption; | ||
import { Data } from './pie'; | ||
|
||
@Component({ | ||
selector: 'echarts-pie', | ||
templateUrl: './pie.component.html', | ||
styleUrls: ['./pie.component.scss'] | ||
}) | ||
export class EchartsPieComponent implements AfterViewInit { | ||
@ViewChild('view') view; | ||
chart: ECharts; | ||
_title: string; | ||
_data: Data[]; | ||
@Input('title') | ||
set title(value) { | ||
this._title = value; | ||
this.initOption(); | ||
} | ||
@Input('data') | ||
set data(value: Data[]) { | ||
this._data = value; | ||
this.initOption(); | ||
} | ||
get option() { | ||
const option = { | ||
title: { | ||
text: this._title, | ||
left: 'center', | ||
top: '15px', | ||
textStyle: { | ||
color: '#333', | ||
fontSize: 20, | ||
letterSpacing: '2px' | ||
} | ||
}, | ||
tooltip: { | ||
trigger: 'item', | ||
formatter: '{b} : {c} ({d}%)' | ||
}, | ||
toolbox: { | ||
show: true, | ||
feature: { | ||
} | ||
}, | ||
calculable: false, | ||
series: [] | ||
}; | ||
option.series = this._data.map((item, index) => { | ||
return { | ||
center: ['50%', '60%'], | ||
name: item.title, | ||
type: 'pie', | ||
selectedMode: 'single', | ||
radius: index ? [55 + 15 * index, 75 + 15 * index] : [0, 55], | ||
itemStyle: { | ||
normal: { | ||
label: { | ||
position: 'inner' | ||
}, | ||
labelLine: { | ||
show: false | ||
} | ||
} | ||
}, | ||
data: item.data | ||
}; | ||
}); | ||
return option; | ||
} | ||
ngAfterViewInit() { | ||
this.chart = echarts.init(this.view.nativeElement); | ||
this.chart.setOption(this.option, true); | ||
} | ||
initOption() { | ||
if (this.chart) { | ||
this.chart.setOption(this.option, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface Data { | ||
title: string; | ||
data: PieData[]; | ||
} | ||
|
||
interface PieData { | ||
name: string; | ||
value: number; | ||
} |