Incremental chart updates in ApexChart (updateSeries instead of full re-render) #23
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
ApexChartexposes exactly one path to the client:renderChartinfrontend/components/apex-chart.tstears the chart down and builds it again. Every data change is a full destroy + rebuild: the chart flashes, animations restart from zero, and any zoom/selection state is lost.That is fine for a one-shot dashboard. It is not fine as soon as data can change — refresh buttons, polling, a global date filter, or
@Push-driven live updates all become visibly janky.Proposal
updateSeries(and optionallyappendData) client function toapex-chart.tsthat calls ApexCharts' ownupdateSeries/updateOptionson the existing instance.updateData(...)onAxisChart/PieChartthat sends only series and categories, falling back to a fullrenderChartwhen no chart instance exists yet.applyThemeOverlay()) correct across incremental updates — it currently runs as part of the render path.Once this exists, the follow-ups become cheap:
UI.setPollIntervalor@Pushfor auto-refreshing widgets,Acceptance criteria
Depends on
Data service layer — without a way to get new data, there is nothing to push through this path.
Scope
Small to medium, mostly in
apex-chart.tsplus a thin Java API.PR: #32
updateDatapatches the live ApexCharts instance (updateSeries, plusupdateOptionsonly when categories/labels change);AxisChart.updateData/PieChart.updateDatafall back tosetDatabefore the first render. Theme overlay is re-applied to the merged options.Covered by
ApexChartUpdateTest(browserless, asserts the queued client call) andDashboardChartPlaywrightTest(Chromium, asserts the<svg>node is not recreated)../mvnw test: 16/16 green.Not part of this PR (follow-ups from the issue): per-widget refresh action, polling/
@Push, global filter bar — no data service layer yet, so nothing drives the new path in the UI.