fix: incremental chart updates in ApexChart (updateSeries instead of full re-render) (#23) #32
Reference in New Issue
Block a user
Delete Branch "ai/issue-23-incremental-chart-updates"
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?
Closes #23
What
ApexCharthad exactly one path to the client:renderChartwith a full option set, which rebuilds the chart on every data change (animations restart from zero, zoom/selection state lost).This adds a data-only update path:
apex-chart.ts: newupdateData(patchJson)client function. It mergesseries(andcategories/labels) into the stored options and applies them via ApexCharts'updateSerieson the existing instance.updateOptionsis only called when categories/labels actually changed — a pure data refresh never touches it. The theme overlay is re-applied to the merged options andlastOptionsJsonis refreshed, so a rebuild after a detach (gridstack re-append, Flow detach) starts from the patched data.ApexChart.sendDataPatch(...)/hasSentOptions(), plus publicAxisChart.updateData(seriesName, values, categories)andPieChart.updateData(values, labels). Before the first render there is no chart to patch, so both fall back tosetData(...).First render is unchanged —
setData(...)still sends the full option set.Tests
components/ApexChartUpdateTest(browserless): asserts the queued client call isupdateDatawith a data-only payload after a render, andrenderChartwith the full theme options before one.e2e/DashboardChartPlaywrightTest(Chromium): tags the rendered<svg>node, triggers a data update, and asserts the same node is still there (patched in place, not recreated) with the new data — plus thatgrid.borderColoris still a resolved theme color after the update../mvnw test— 16/16 green, e2e included.