Skip to content

Fix ChartJS onClick on dart2wasm; run Chrome tests on dart2wasm in CI (3.0.2) - #16

Merged
gmpassos merged 2 commits into
masterfrom
fix/dart2wasm-callbacks
Nov 4, 2026
Merged

gmpassos merged 2 commits into
masterfrom
fix/dart2wasm-callbacks

Conversation

@gmpassos

@gmpassos gmpassos commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Problem

dart test -p chrome -c dart2wasm failed on master in ChartEngine[ChartJS] renderLineChart with options:

Assertion failed: functionToJSWrapper.containsKey(o)
"Must call `allowInterop` on functions before they flow to JS"
  jsifyFunction <- jsifyRaw <- jsify

ChartEngineChartJS._onClick returned a plain Dart closure, which toJSDeep (js_interop_utils) converts with jsify(). dart2js wraps it implicitly; dart2wasm rejects it.

Changes

  • ChartEngineChartJS._onClick now returns a JSFunction built with Function.toJS (dart:js_interop), with JSAny? parameters converted via dartify() — the same style as the existing _DateAdapter__* exports. This is the only Dart closure passed into chart options: the _DateAdapter__* functions were already exported with .toJS, and the ApexCharts engine passes no Dart callbacks (its formatter is pure JS).
  • renderScatterChart (ChartJS): the Dart side omitted the timed argument, so onClick landed in the JS timed slot, turning the X axis into a time scale and throwing Can't handle unit: millisecond. Now passes false.
  • renderBar (ChartJS wrapper JS): accepted no onClickCallback, so onClick was silently ignored for bar charts. Now wired through configure.
  • ChartOptions.onClick doc notes it's only called by the ChartJS engine.
  • Tests: new ChartEngineChartJS onClick group invokes the chart's options.onClick handler for every ChartJS chart type (line, time-series, bar, horizontal bar, gauge, scatter, timed scatter, financial) and checks the Dart callback receives the dartified items.
  • CI: new step dart test --platform chrome --compiler dart2wasm.
  • Bump to 3.0.2 (pubspec.yaml, ChartEngine.VERSION, CHANGELOG).

Verification (local)

  • dart format / dart analyze --fatal-infos --fatal-warnings: clean
  • dart test --platform vm,chrome: 102 passed
  • dart test --platform chrome --compiler dart2wasm: 93 passed
  • dart pub publish --dry-run: 0 warnings

🤖 Generated with Claude Code

gmpassos and others added 2 commits November 4, 2026 11:25
… dart2wasm; bump to 3.0.2

The onClick closure flowed into JS as a plain Dart function via jsify, which dart2wasm rejects. Also fix renderScatterChart passing onClick into the JS 'timed' slot, wire onClick for bar charts, test the handler for every ChartJS chart type, and run the Chrome tests on dart2wasm in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cords

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gmpassos
gmpassos merged commit 885c4a6 into master Nov 4, 2026
1 check passed
@gmpassos
gmpassos deleted the fix/dart2wasm-callbacks branch November 4, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant