fix(traefik): request chart redraws once the dashboard has placed it, and refreshes every 5 min (#5214)
A chart built while its cell was still being laid out could stay blank until a window resize; it now measures and draws again after layout settles. Each refresh rebuilds the chart (the flash), and its buckets are minutes wide, so the widget refreshes every 5 minutes instead of every poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
var hhmm = function (ms) {
|
var hhmm = function (ms) {
|
||||||
return new Date(ms).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
return new Date(ms).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
||||||
};
|
};
|
||||||
new Chart(ctx.getContext("2d"), {
|
var chart = new Chart(ctx.getContext("2d"), {
|
||||||
type: "line",
|
type: "line",
|
||||||
data: {
|
data: {
|
||||||
labels: times,
|
labels: times,
|
||||||
@@ -83,6 +83,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// The chart is built while the dashboard may still be placing this cell,
|
||||||
|
// and a chart sized then can stay blank until a window resize (#5214).
|
||||||
|
// Measure and draw again once layout has settled.
|
||||||
|
setTimeout(function () {
|
||||||
|
if (!ctx.isConnected) return;
|
||||||
|
chart.resize();
|
||||||
|
chart.update("none");
|
||||||
|
}, 250);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fail(err && err.message ? err.message : String(err));
|
fail(err && err.message ? err.message : String(err));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ WIDGET_REGISTRY: dict[str, dict] = {
|
|||||||
"detail_url": "/plugins/traefik/",
|
"detail_url": "/plugins/traefik/",
|
||||||
"plugin": "traefik",
|
"plugin": "traefik",
|
||||||
"poll": True,
|
"poll": True,
|
||||||
|
"poll_seconds": 300, # buckets are minutes wide; each refresh redraws the chart
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"key": "hours",
|
"key": "hours",
|
||||||
|
|||||||
Reference in New Issue
Block a user