进一步优化
This commit is contained in:
@@ -64,8 +64,8 @@ class AreaChart {
|
||||
// Smoothly transition max value context too
|
||||
this.prevMaxVal = this.currentMaxVal || 0;
|
||||
|
||||
// Downsample if data is too dense (target ~1500 points for performance)
|
||||
const MAX_POINTS = 1500;
|
||||
// Downsample if data is too dense (target ~500 points for GPU performance)
|
||||
const MAX_POINTS = 500;
|
||||
if (data.timestamps.length > MAX_POINTS) {
|
||||
const skip = Math.ceil(data.timestamps.length / MAX_POINTS);
|
||||
const downsampled = { timestamps: [], rx: [], tx: [] };
|
||||
@@ -112,7 +112,7 @@ class AreaChart {
|
||||
animate() {
|
||||
if (this.animFrame) cancelAnimationFrame(this.animFrame);
|
||||
const start = performance.now();
|
||||
const duration = 800;
|
||||
const duration = 400; // Shorter animation = less GPU time
|
||||
|
||||
const step = (now) => {
|
||||
const elapsed = now - start;
|
||||
@@ -277,7 +277,7 @@ class AreaChart {
|
||||
drawArea(ctx, values, prevValues, getX, getY, chartH, p, fillColorTop, fillColorBottom, strokeColor, len) {
|
||||
if (!values || values.length === 0) return;
|
||||
|
||||
const useSimple = len > 250;
|
||||
const useSimple = len > 80;
|
||||
const getPVal = (i) => (prevValues && i < prevValues.length) ? prevValues[i] : 0;
|
||||
|
||||
// Fill
|
||||
@@ -407,7 +407,7 @@ class MetricChart {
|
||||
animate() {
|
||||
if (this.animFrame) cancelAnimationFrame(this.animFrame);
|
||||
const start = performance.now();
|
||||
const duration = 500;
|
||||
const duration = 300; // Snappier and lighter on GPU
|
||||
const step = (now) => {
|
||||
const elapsed = now - start;
|
||||
this.animProgress = Math.min(elapsed / duration, 1);
|
||||
@@ -560,7 +560,7 @@ class MetricChart {
|
||||
});
|
||||
|
||||
} else {
|
||||
const useSimple = len > 250;
|
||||
const useSimple = len > 100;
|
||||
const prevVals = this.prevData ? this.prevData.values : null;
|
||||
const getPVal = (i) => (prevVals && i < prevVals.length) ? prevVals[i] : 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user