3

I'm struggling to get the chart.js dart port to properly render a bubble chart when serving the web app with the --release flag. Using dart2js seems to be breaking the chart, as it works perfectly with --no-release.

The chart renders in properly, and the axes look fine. It's just the data that isn't rendering in. No errors are thrown in the console.

I've tried two approaches to adding the data. One with a simple map, like so:

 List<Map> myData = [];
 myData.add({'x': 0, 'y': 0, 'r': 5}); //for example..

 ChartDataSets dataset = new ChartDataSets(
    label: 'outer',
    data: myData
  );

 var chartData = new LinearChartData(datasets: <ChartDataSets>[
   dataset,
 ]);

 ChartConfiguration config = new ChartConfiguration(
   type: 'bubble', data: dataset, options: new ChartOptions(
     responsive: true,
     legend: new ChartLegendOptions(display: false),
     scales: scales,
 ));

I've also tried creating an class to hold the data, and handing objects to the input list:

class BubbleObject{

  int x;
  int y;
  double r;

  BubbleObject(this.x, this.y, this.r);

}

so myData becomes List<BubbleObject> myData = []

Any idea why the --release flag would break this approach, and how this issue can be fixed?

Thanks in advance!

Sam
  • 1,234
  • 3
  • 17
  • 32
  • definitely a --minify problem. I added a `build.yaml` file with `dart2js_args: -01` which fixed the issue. Going to leave this open in case someone finds a better solution. – Sam Mar 12 '19 at 10:09

0 Answers0