File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/app/frontend/common/components/graph Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export class GraphComponent implements OnInit, OnChanges {
34
34
customColors = { } ;
35
35
yAxisLabel = '' ;
36
36
yAxisTickFormatting = ( value : number ) => `${ value } ${ this . yAxisSuffix_ } ` ;
37
+ yScaleMax = 0 ;
37
38
38
39
private suffixMap_ : Map < number , string > = new Map < number , string > ( ) ;
39
40
private yAxisSuffix_ = '' ;
@@ -62,6 +63,7 @@ export class GraphComponent implements OnInit, OnChanges {
62
63
let series : FormattedValue [ ] ;
63
64
let highestSuffixPower = 0 ;
64
65
let highestSuffix = '' ;
66
+ let maxValue = 0 ;
65
67
66
68
switch ( this . graphType ) {
67
69
case GraphType . Memory :
@@ -99,17 +101,35 @@ export class GraphComponent implements OnInit, OnChanges {
99
101
} as DataPoint ) ;
100
102
} ) ;
101
103
102
- return [
104
+ const result = [
103
105
{
104
106
name : this . id ,
105
107
series : points . reduce ( this . _average . bind ( this ) , [ ] ) . map ( point => {
108
+ if ( maxValue < point . y ) {
109
+ maxValue = point . y ;
110
+ }
111
+
106
112
return {
107
113
value : point . y ,
108
114
name : timeFormat ( '%H:%M' ) ( new Date ( 1000 * point . x ) ) ,
109
115
} ;
110
116
} ) ,
111
117
} ,
112
118
] ;
119
+
120
+ // This way if max value is very small i.e. 0.0001 graph will be scaled to the more significant
121
+ // value.
122
+ switch ( this . graphType ) {
123
+ case GraphType . CPU :
124
+ this . yScaleMax = maxValue + 0.01 ;
125
+ break ;
126
+ case GraphType . Memory :
127
+ this . yScaleMax = maxValue + 10 ;
128
+ break ;
129
+ default :
130
+ }
131
+
132
+ return result ;
113
133
}
114
134
115
135
// Calculate the average usage based on minute intervals. If there are more data points within
Original file line number Diff line number Diff line change 20
20
[showYAxisLabel] ="true "
21
21
[yAxisLabel] ="yAxisLabel "
22
22
[yAxisTickFormatting] ="yAxisTickFormatting "
23
+ [yScaleMax] ="yScaleMax "
23
24
[results] ="series "
24
25
[showGridLines] ="true "
25
26
[curve] ="curve "
You can’t perform that action at this time.
0 commit comments