Repository navigation
Bugfix Issue 921 EventViewer Chart Rerender
On the modernized Event Viewer, the two charts ('Events by Level' doughnut + 'Events per Day' line) rendered correctly on first load, but after changing a filter and clicking Apply the charts stayed frozen on the previous dataset. The DataTable below refreshed correctly.
Symptoms (browser console, one per Apply click):
Uncaught TypeError: pieChart.clear is not a functionUncaught TypeError: lineChart.clear is not a function
In-page proof: typeof (pieChart.clear) === 'undefined'.

-
gui/templates/eventviewer/eventviewer.html:314renderPie()and:329renderLine()guarded chart re-creation withif (pieChart) { pieChart.clear(); pieChart = null; }. - The bundled
gui/templates/dashio/lib/chart-master/Chart.jsis the 2013 v1 build with no public.clear()on chart instances. The onlyclearin the library is an internal helpervar clear = function(c){ c.clearRect(0,0,width,height); }atChart.js:353, invoked from the animation loop atChart.js:1243— never exposed on the chart objects. - ⇒
pieChart.clear()throwsTypeError, aborting the rest ofrenderPie/renderLinebeforenew Chart(ctx)...Doughnut(...)/new Chart(ctx).Line(...)and before the#pieLegendinnerHTML regeneration. - The DataTable refresh (
renderTable) lives on an independent code path, so the split behaviour (table updates, charts don't) is exactly what the report saw.
Regression source: the screen's original modernization assumed a modern Chart.js API; every re-render (Apply filter, Clear Events) trips the missing method.
- Dropped the non-existent
.clear()call, keeping the reference discard:-
renderPie():if (pieChart) { pieChart.clear(); pieChart = null; }→if (pieChart) { pieChart = null; } -
renderLine():if (lineChart) { lineChart.clear(); lineChart = null; }→if (lineChart) { lineChart = null; }
-
- Hardened the same re-render path for HiDPI displays: Chart.js v1 multiplies
context.canvas.width/heightbydevicePixelRatioon every instantiation (Chart.js:157-161), so on a dpr>1 screen each Apply used to scale the canvas up from the already-doubled backing store (240→480→960 px …).renderPie/renderLinenow reset the canvas to its markup size (pieCanvasSize/lineCanvasSize, captured once at page init) before re-instantiating, so the backing store stays constant (dpr=2: pie 480, line 1400 across repeated Applies).
Why this is safe: Chart.js v1 clears the whole canvas itself on re-creation — the constructor resizes context.canvas when window.devicePixelRatio is truthy (Chart.js:157-161), and the animation loop calls clear(ctx) (full clearRect) at the start of every frame (Chart.js:1243 → :353). So no stale pixels can survive into the new chart. #pieLegend is regenerated unconditionally. The tooltip shims (tl-pie-tooltip.js / tl-line-tooltip.js) already de-register prior listeners on re-attach (if (canvas._tlPieMove) canvas.removeEventListener(...)), so repeated re-renders do not stack handlers.
- Add a
.clear()method to the bundledChart.js: rejected — needless surface change to a shared legacy library used by every Dashio chart screen. - Upgrade to Chart.js v2/v3: rejected — every
.Doughnut()/.Bar()/.Line()call site in the app uses the v1 API; out of scope for a bug fix.
Blast radius: grep '\.clear()' gui/templates/**/*.html → only these two call sites, both in eventviewer.html. No other screen calls .clear() on chart instances.
Verification (CI: MariaDB 127.0.0.1:3306, TestLink @ http://localhost:8082, admin/admin)
Dataset for the final pass: 7 seeded events (AUDIT 3 / WARNING 2 / INFO 1 / ERROR 1).
- First load: both charts + legend render, footer
7 events, zero console errors. - Apply with
04/09/2026-04/09/2026filter: table →4 events, pie legend updates toAUDIT: 2 (50%) / INFO: 1 (25%) / WARNING: 1 (25%) / ERROR: 0 (0%), line chart re-renders, zero console errors. - Repeated Apply (same + changed filters): stable values, still zero errors.
- Empty-result filter (dates in 2020): table
0 events, legend all zeros, no errors (line-tooltip geometry already guards degenerate all-zero data). - Clear Events flow: confirm dialog →
0 events, charts zeroed, zero console errors (exercises the same re-render path). - Pie hover tooltip after re-render:
WARNING: 2 (25%)shown at the hit point. -
eventstable: zero new ERROR/WARNING rows generated by the app (only the intentionally seeded fixtures). - HiDPI (emulated
devicePixelRatio:2): 4 consecutive Applies keep the pie canvas at 240px CSS / 480 backing and the line canvas at 700px CSS / 1400 backing — no per-Apply canvas growth.

| File | Purpose |
|---|---|
gui/templates/eventviewer/eventviewer.html |
Fix: drop the two non-existent .clear() calls + HiDPI canvas-size reset on re-render |
docs/screenshots/issue-921-eventviewer-charts-frozen.png |
Pre-fix symptom screenshot |
docs/screenshots/issue-921-eventviewer-charts-updated.png |
Post-fix verification screenshot |