Skip to content

[WC-3362] Charts: Add refresh interval to list-based charts - #2486

Open
yordan-st wants to merge 10 commits into
mainfrom
feat/WC-3362_charts-refresh-interval
Open

yordan-st wants to merge 10 commits into
mainfrom
feat/WC-3362_charts-refresh-interval

Conversation

@yordan-st

@yordan-st yordan-st commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Pull request type

New feature (non-breaking change which adds functionality)


Description

Brings back the "Refresh time (in seconds)" option for charts, as documented for classic charts. Charts aggregating view entities otherwise never refresh without a page reload.

  • Adds a refreshInterval property (default 0 = off) to Area, Bar, Bubble, Column, Heat map, Line, Pie/Doughnut and Time series charts. Custom chart is out of scope (attribute-based data, not a list data source).
  • A shared useRefreshInterval hook in @mendix/shared-charts reloads every data source the chart renders after the interval. It restarts the timer on each data update and skips sources that are still loading, matching Datagrid 2 and Gallery. The chart keeps showing its current data during the reload.
  • Unit tests for the hook (including a StrictMode remount case) and a LineChart integration test. CHANGELOG entries for all 8 widgets.

Docs: the property is new in widget XML, so https://docs.mendix.com/refguide/charts-configuration/ may need a mendix/docs update.

What should be covered while testing?

  • Line chart on a view entity (or an entity editable from a second tab), static series, Refresh time = 5: change data elsewhere, chart updates within ~5 s
  • During the reload the chart keeps showing the previous data (no flash of an empty chart)
  • Refresh time = 0: no automatic update
  • Repeat with a Pie chart (single data source) and a chart with one static plus one dynamic series
  • Studio Pro: the property appears under General > Data source for all 8 charts and not for Custom chart
  • No errors in the DevTools console

@yordan-st yordan-st changed the title [WC-3362]: Add refresh interval to list-based charts [WC-3362] Charts: Add refresh interval to list-based charts Oct 22, 2026
@yordan-st
yordan-st force-pushed the feat/WC-3362_charts-refresh-interval branch from 4862ba8 to a022cb2 Compare October 22, 2026 09:25
@yordan-st
yordan-st marked this pull request as ready for review October 22, 2026 09:29
@yordan-st
yordan-st requested a review from a team as a code owner October 22, 2026 09:29
@yordan-st
yordan-st force-pushed the feat/WC-3362_charts-refresh-interval branch from a022cb2 to 2422da6 Compare October 22, 2026 09:29
@github-actions

This comment has been minimized.

Reloads the given data sources after the interval, restarting the timer on
every data source update and skipping sources that are still loading. Mirrors
the Datagrid 2 / Gallery refresh behaviour. Adds seriesDataSources helper.

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
Add "Refresh time (in seconds)" to the Data source group (default 0 = off).
When set, the chart periodically reloads its data source(s).

Ticket: WC-3362
@yordan-st
yordan-st force-pushed the feat/WC-3362_charts-refresh-interval branch from 2422da6 to 02dffb3 Compare October 22, 2026 09:47
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/shared/charts/src/hooks/useRefreshInterval.ts New shared hook: schedules periodic reload() on datasources
packages/shared/charts/src/hooks/__tests__/useRefreshInterval.spec.ts 9 unit tests for the hook and seriesDataSources helper
packages/shared/charts/src/main.ts Re-exports new hook and helper
packages/pluggableWidgets/{area,bar,bubble,column,heatmap,line,pie-doughnut,time-series}-chart-web/src/*.tsx One-line hook call added to each widget component
packages/pluggableWidgets/*/src/*.xml refreshInterval integer property (default 0) added to Data source group
packages/pluggableWidgets/*/typings/*Props.d.ts Regenerated: refreshInterval: number on container props, `number
packages/pluggableWidgets/*/src/__tests__/*.spec.tsx refreshInterval={0} added to render fixtures; integration tests in LineChart
packages/pluggableWidgets/*/CHANGELOG.md ### Added entry in all 8 widget changelogs
packages/shared/charts/openspec/changes/add-chart-refresh-interval/* OpenSpec proposal, design, spec, and tasks

Skipped (out of scope): dist/, pnpm-lock.yaml


Findings

🔶 Medium — security/snyk CI check is failing

File: PR checks
Problem: The security/snyk check has status FAILURE. Whether this is pre-existing or introduced by this PR needs to be verified before merge.
Fix: Check the Snyk report linked in the PR checks. If the finding is pre-existing (present on main), add a note to the PR description. If it is newly introduced by this change, address it before merging.


⚠️ Low — No test for negative refreshInterval

File: packages/shared/charts/src/hooks/__tests__/useRefreshInterval.spec.ts
Note: The spec (spec.md) says "When refreshInterval is 0 or negative, the chart SHALL NOT schedule any automatic reload". The implementation correctly guards with if (intervalSeconds > 0), but there is no test exercising a negative value. The interval: 0 test only covers the boundary. Adding one test case (e.g. interval: -1) closes the gap between the spec and the test suite.

it("does not reload when interval is negative", () => {
    const ds = new ListValueBuilder().build();
    setup({ datasources: [ds], interval: -1 });
    jest.advanceTimersByTime(60_000);
    expect(ds.reload).not.toHaveBeenCalled();
});

Positives

  • The dependency-free useEffect + element-wise shallowEqual ref pattern is the correct way to detect Mendix ListValue reference changes without spreading a variable-length array into deps — mirrors the autorun in DatasourceService without requiring MobX.
  • StrictMode remount is explicitly covered (the cleanup effect resets prevDatasourcesRef, allowing the remounted effect to reschedule the timer).
  • All 8 widget changes are identical in shape: one XML property, one hook call — minimal blast radius per widget.
  • ListValueBuilder used throughout; no manual mock objects.
  • seriesDataSources is co-located with its sole consumer and unit-tested independently, making widget wiring a one-liner.
  • CHANGELOG entries are present and user-facing for all 8 affected widgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants