fix: Update chart less often while updating info more often

Chart gets crowded, so update a little less often, while we can update other info more often.

Can go back to trying dots again on average
This commit is contained in:
mrv777 2024-09-29 08:20:43 -05:00
parent 952a28eb6d
commit 2adb33a4f5

View File

@ -28,6 +28,8 @@ export class HomeComponent {
public maxTemp: number = 75; public maxTemp: number = 75;
public maxFrequency: number = 800; public maxFrequency: number = 800;
private dataCounter: number = 0;
constructor( constructor(
private systemService: SystemService private systemService: SystemService
) { ) {
@ -62,10 +64,9 @@ export class HomeComponent {
backgroundColor: textColorSecondary, backgroundColor: textColorSecondary,
borderColor: textColorSecondary, borderColor: textColorSecondary,
tension: 0.2, tension: 0.2,
pointRadius: 0, pointRadius: 1,
pointHoverRadius: 5, pointHoverRadius: 5,
borderWidth: 2, borderWidth: 2,
borderDash: [5, 5]
} }
] ]
}; };
@ -121,17 +122,17 @@ export class HomeComponent {
}; };
this.info$ = interval(5000).pipe( this.info$ = interval(2000).pipe(
startWith(() => this.systemService.getInfo()), startWith(() => this.systemService.getInfo()),
switchMap(() => { switchMap(() => {
return this.systemService.getInfo() return this.systemService.getInfo()
}), }),
tap(info => { tap(info => {
if (this.dataCounter % 5 === 0) {
this.dataData.push(info.hashRate * 1000000000); this.dataData.push(info.hashRate * 1000000000);
this.dataLabel.push(new Date().getTime()); this.dataLabel.push(new Date().getTime());
if (this.dataData.length >= 1000) { if (this.dataData.length >= 500) {
this.dataData.shift(); this.dataData.shift();
this.dataLabel.shift(); this.dataLabel.shift();
} }
@ -146,6 +147,9 @@ export class HomeComponent {
this.chartData = { this.chartData = {
...this.chartData ...this.chartData
}; };
}
this.dataCounter++;
this.maxPower = Math.max(50, info.power); this.maxPower = Math.max(50, info.power);
this.maxTemp = Math.max(75, info.temp); this.maxTemp = Math.max(75, info.temp);