google / chartjs.dart

ARCHIVED/UNMAINTAINED Dart API for Chart.js
https://pub.dev/packages/chartjs
Other
143 stars 53 forks source link

ChartTooltipCallback doesn't work after dartjs compilation #24

Closed DigNZ closed 6 years ago

DigNZ commented 6 years ago

If I run webdev serve then ChartTooltipOptions callbacks work perfectly.

Inside new ChartOptions()

//snip tooltips: new ChartTooltipOptions( callbacks: new ChartTooltipCallback(label: (item, data) { String ele = item.xLabel; Set names = new Set(); nameList.forEach((a) { names.add(a); } }); return names.toList(); }, title: (_) { return "Title"; })) //snip Once I webdev build and run on a live site then the chart hangs with an error: Chart.bundle.js:13069 Uncaught TypeError: callbacks.title.apply is not a function at ChartElement.getTitle (Chart.bundle.js:13069) at ChartElement.update (Chart.bundle.js:13196) at ChartElement.handleEvent (Chart.bundle.js:13531) at Chart.eventHandler (Chart.bundle.js:8952) at listener (Chart.bundle.js:8886) at HTMLCanvasElement.proxies

I've also replaces my Chart.bundle.js with the CDN Chart.js from the example. Same result - works when being served locally, doesn't work once compiled. I've also removed the title callback and then I get the same error with the label callback: callbacks.label.apply is not a function

DigNZ commented 6 years ago

allowInterop around the callback function resolves this.