@@ -32,6 +32,7 @@ export class StatusComponent implements OnInit, OnDestroy {
32
32
public latencyGraphData = [ ] ;
33
33
public inputGraphData = [ ] ;
34
34
public outputGraphData = [ ] ;
35
+ public utcForm : UntypedFormGroup ;
35
36
public rangeForm : UntypedFormGroup ;
36
37
public readonly ranges = {
37
38
1 : 'last 1 minute' ,
@@ -42,7 +43,7 @@ export class StatusComponent implements OnInit, OnDestroy {
42
43
} ;
43
44
public rangesKeys = Object . keys ( this . ranges ) . map ( n => + n ) ;
44
45
public readonly colorScheme = {
45
- domain : [ '#5AA454' , '#E44D25' , '#1e59cf' , '#7aa3e5' , '#a8385d' , '#d0bd00' ]
46
+ domain : [ '#5AA454' , '#E44D25' , '#1e59cf' , '#7aa3e5' , '#a8385d' , '#d0bd00' ] ,
46
47
} ;
47
48
private readonly samples = 60 ; // Number of samples in the series
48
49
private refreshTimer : Observable < number > ;
@@ -55,6 +56,9 @@ export class StatusComponent implements OnInit, OnDestroy {
55
56
) { }
56
57
57
58
ngOnInit ( ) : void {
59
+ this . utcForm = this . formBuilder . group ( {
60
+ isUTC : false , // Default show in local timezone
61
+ } ) ;
58
62
this . rangeForm = this . formBuilder . group ( {
59
63
rangeMinutes : [ 10 ] , // Default range to 10 min window
60
64
} ) ;
@@ -162,9 +166,19 @@ export class StatusComponent implements OnInit, OnDestroy {
162
166
163
167
public setRange ( event ) : void {
164
168
this . rangeForm . reset ( { rangeMinutes : + event . target . value } ) ;
169
+ }
170
+
171
+ public setIsUTC ( event ) : void {
172
+ this . utcForm . reset ( { isUTC : event . target . checked } ) ;
165
173
this . reset ( ) ;
166
174
}
167
175
176
+ private formatDateLocal = new Intl . DateTimeFormat ( navigator . languages . slice ( ) , { hour : "2-digit" , minute : "2-digit" } ) ;
177
+ private formatDateUTC = new Intl . DateTimeFormat ( navigator . languages . slice ( ) , { hour : "2-digit" , minute : "2-digit" , timeZone : "UTC" } ) ;
178
+
179
+ // Declared as fat arrow to avoid having to bind it in xAxisTickFormatting (see https://github.com/swimlane/ngx-charts/issues/261)
180
+ xAxisFormatFn = ( value ) => this . utcForm ?. value . isUTC ? this . formatDateUTC . format ( value ) : this . formatDateLocal . format ( value ) ;
181
+
168
182
private reset ( ) : void {
169
183
this . consoleService . getStatus ( '' ) . subscribe ( data => {
170
184
this . initData ( data . nodes . map ( n => n . name ) ) ;
0 commit comments