未验证 提交 56c79bc9 编写于 作者: S Sebastian Florek 提交者: GitHub

Disable graph refresh when it is not visible (#5198)

上级 4343d44c
...@@ -11930,9 +11930,9 @@ ...@@ -11930,9 +11930,9 @@
"integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q=" "integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q="
}, },
"http-proxy": { "http-proxy": {
"version": "1.18.0", "version": "1.18.1",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
"integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==", "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"eventemitter3": "^4.0.0", "eventemitter3": "^4.0.0",
...@@ -12375,6 +12375,11 @@ ...@@ -12375,6 +12375,11 @@
"integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==",
"dev": true "dev": true
}, },
"intersection-observer": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/intersection-observer/-/intersection-observer-0.10.0.tgz",
"integrity": "sha512-fn4bQ0Xq8FTej09YC/jqKZwtijpvARlRp6wxL5WTA6yPe2YWSJ5RJh7Nm79rK2qB0wr6iDQzH60XGq5V/7u8YQ=="
},
"invariant": { "invariant": {
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
...@@ -15861,6 +15866,15 @@ ...@@ -15861,6 +15866,15 @@
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
"dev": true "dev": true
}, },
"ng-in-viewport": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ng-in-viewport/-/ng-in-viewport-6.1.0.tgz",
"integrity": "sha512-mJlsiGBhOLiqgM4S36zg9IWjv0YsOPuoVB1T4mKaq4NZ2aHB/8t5n5pB+pP93k1mmSUhp+cPscGua5o7gJrURg==",
"requires": {
"intersection-observer": ">=0.5.1",
"tslib": ">=1.9.0"
}
},
"ngx-cookie-service": { "ngx-cookie-service": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-2.4.0.tgz", "resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-2.4.0.tgz",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {DataPoint, Metric} from '@api/backendapi'; import {DataPoint, Metric} from '@api/backendapi';
import {ViewportMetadata} from '@api/frontendapi';
import {curveMonotoneX, timeFormat} from 'd3'; import {curveMonotoneX, timeFormat} from 'd3';
import {FormattedValue} from './helper'; import {FormattedValue} from './helper';
...@@ -38,6 +39,7 @@ export class GraphComponent implements OnInit, OnChanges { ...@@ -38,6 +39,7 @@ export class GraphComponent implements OnInit, OnChanges {
private suffixMap_: Map<number, string> = new Map<number, string>(); private suffixMap_: Map<number, string> = new Map<number, string>();
private yAxisSuffix_ = ''; private yAxisSuffix_ = '';
private visible_ = false;
ngOnInit(): void { ngOnInit(): void {
if (!this.graphType) { if (!this.graphType) {
...@@ -50,8 +52,14 @@ export class GraphComponent implements OnInit, OnChanges { ...@@ -50,8 +52,14 @@ export class GraphComponent implements OnInit, OnChanges {
} }
ngOnChanges(_: SimpleChanges): void { ngOnChanges(_: SimpleChanges): void {
this.suffixMap_.clear(); if (this.visible_) {
this.series = this.generateSeries_(); this.suffixMap_.clear();
this.series = this.generateSeries_();
}
}
changeState(isInViewPort: ViewportMetadata): void {
this.visible_ = isInViewPort.visible;
} }
getTooltipValue(value: number): string { getTooltipValue(value: number): string {
......
...@@ -15,6 +15,9 @@ limitations under the License. ...@@ -15,6 +15,9 @@ limitations under the License.
--> -->
<ngx-charts-area-chart fxFlex <ngx-charts-area-chart fxFlex
inViewport
[inViewportOptions]="{partial: false}"
(inViewportAction)="changeState($event)"
[xAxis]="true" [xAxis]="true"
[yAxis]="true" [yAxis]="true"
[showYAxisLabel]="true" [showYAxisLabel]="true"
......
...@@ -43,6 +43,7 @@ import {MatTabsModule} from '@angular/material/tabs'; ...@@ -43,6 +43,7 @@ import {MatTabsModule} from '@angular/material/tabs';
import {MatToolbarModule} from '@angular/material/toolbar'; import {MatToolbarModule} from '@angular/material/toolbar';
import {MAT_TOOLTIP_DEFAULT_OPTIONS, MatTooltipModule} from '@angular/material/tooltip'; import {MAT_TOOLTIP_DEFAULT_OPTIONS, MatTooltipModule} from '@angular/material/tooltip';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {InViewportModule} from 'ng-in-viewport';
import {FilterPipeModule} from 'ngx-filter-pipe'; import {FilterPipeModule} from 'ngx-filter-pipe';
import {PipesModule} from './common/pipes/module'; import {PipesModule} from './common/pipes/module';
...@@ -88,6 +89,7 @@ const SHARED_DEPENDENCIES = [ ...@@ -88,6 +89,7 @@ const SHARED_DEPENDENCIES = [
RouterModule, RouterModule,
FilterPipeModule, FilterPipeModule,
NgxChartsModule, NgxChartsModule,
InViewportModule,
// Custom application modules // Custom application modules
PipesModule, PipesModule,
......
...@@ -134,3 +134,8 @@ export interface PluginsConfig { ...@@ -134,3 +134,8 @@ export interface PluginsConfig {
plugins: PluginMetadata[]; plugins: PluginMetadata[];
errors?: object[]; errors?: object[];
} }
export interface ViewportMetadata {
target: HTMLElement;
visible: boolean;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册