Abstract class error for "TickOptions"
Opened this issue · 11 comments
After the port to 2.0.0, now seeing this issue with the code below:
Abstract classes can't be created with a 'new' expression.
var config = new ChartConfiguration( type: 'line', data: data, options: new ChartOptions( responsive: true, scales: new ChartScales(type: 'linear', yAxes: [new ChartYAxe(type: 'linear', ticks: new TickOptions(min: 3000, max: 110000))])));
It seems the issue is similar to this issue:
#26 (this fixed "ChartYAxe")
and / or
#22
Almost a year and still no fix for the missing factory constructor
Like @basevers mentioned, this issue is similar to #26 and #22. I solved it by creating the missing factory class with it's attributes in the (Linear)TickOptions class, so it's not abstract anymore and you can create an instance of it:
external factory TickOptions({
dynamic min,
dynamic max
});
Don't forget to rebuild the project after manually updating the chartjs package.
@kevmoo This is a dart facade generator bug as far as I understand, please correct me if I am wrong. Does the project ever get re-generated? In which case the JS facade bugs would clear out manually re-added missing external factories? Need a bit of guidance here, as we're being bit really hard bit some of the Chart lib options not being there.
Happy to PR as needed, this is a small easy task, but just wanted to clear up things beforehand. Not sure if the facade output is a repository that sees a lot of love post auto-generation.
I also have this problem, I can't set max, min or anything else because the class can't be initialized.
I think we need to add constructors for the classes TickOptions and so for the other.
Anyone can help?
PRs welcome!
I don't know how to make pr.
If you can guide me, I will push my changes...
The fix works but misses the rest of the attributes.
@Verzu23 - would you, please, add all the available options for the respective classes? Thanks!
Hi @tomas-kucera , i will do it tonight and also take a look to your issue #51
Great! Thanks!
I am also looking into Locale for proper number formatting. If I get it working, I will publish the ticket and solution. ;)
Hi @tomas-kucera, at this moment you can use default constructor like:
analysisChart.config.options.scales.yAxes.first.ticks = LinearTickOptions(min: 0, max: maxScale);
analysisChart.config.options.scales.yAxes.first.ticks.showLabelBackdrop = true;
and so on.
analysisChart.config.options.scales.yAxes.first.ticks = LinearTickOptions();
analysisChart.config.options.scales.yAxes.first.ticks.min = 0;
analysisChart.config.options.scales.yAxes.first.ticks.max = maxScale;
analysisChart.config.options.scales.yAxes.first.ticks.showLabelBackdrop = true;
Or just like
Let me know if i miss something about your issue...