mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-06-08 15:19:26 +02:00
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:
parent
952a28eb6d
commit
2adb33a4f5
@ -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,31 +122,34 @@ 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.dataLabel.push(new Date().getTime());
|
||||||
|
|
||||||
this.dataData.push(info.hashRate * 1000000000);
|
if (this.dataData.length >= 500) {
|
||||||
this.dataLabel.push(new Date().getTime());
|
this.dataData.shift();
|
||||||
|
this.dataLabel.shift();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.dataData.length >= 1000) {
|
this.chartData.labels = this.dataLabel;
|
||||||
this.dataData.shift();
|
this.chartData.datasets[0].data = this.dataData;
|
||||||
this.dataLabel.shift();
|
|
||||||
|
// Calculate average hashrate and push to chart data
|
||||||
|
this.dataDataAverage.push(this.calculateAverage(this.dataData));
|
||||||
|
this.chartData.datasets[1].data = this.dataDataAverage;
|
||||||
|
|
||||||
|
this.chartData = {
|
||||||
|
...this.chartData
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chartData.labels = this.dataLabel;
|
this.dataCounter++;
|
||||||
this.chartData.datasets[0].data = this.dataData;
|
|
||||||
|
|
||||||
// Calculate average hashrate and push to chart data
|
|
||||||
this.dataDataAverage.push(this.calculateAverage(this.dataData));
|
|
||||||
this.chartData.datasets[1].data = this.dataDataAverage;
|
|
||||||
|
|
||||||
this.chartData = {
|
|
||||||
...this.chartData
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user