Unable to extend an existing controller
See original GitHub issueExpected Behavior
I had some problems to extend an existing controller with Chart.js 3.0. Then I have tested the sample into documentation https://www.chartjs.org/docs/master/developers/charts#extending-existing-chart-types, changing a little as following:
Chart.defaults.myline = Chart.defaults.line;
class Custom extends Chart.controllers.line {
draw() {
// Call super method first
super.draw(arguments);
}
};
Chart.controllers.myline = Custom;
console.log(Chart.controllers);
I was expecting to have a line chart.
Current Behavior
The issue on console is Error: "myline" is not a chart type.
.
Then I printed the content of Chart.controllers
, expecting to find Chart.controllers.myline
but was missing.
Additional question
I was using into version 2.9.3 Chart.controllers.line.extend
. Can I still use it to extend an existing controller, in version 3.0.0?
Steps to Reproduce
https://codepen.io/stockinail/pen/RwrazGR
Environment
- Chart.js version: dist/master
- Browser name and version: FF 77.0.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
What's the recommended way to extend AngularJS controllers?
Perhaps you don't extend a controller but it is possible to extend a controller or make a single controller a mixin of multiple...
Read more >Fiori Elements: Controller Extension not loaded
I have a Fiori Elements ListReport/ObjectPage app and want to extend the controller of the ObjectPage. Hence I added this to the manifest....
Read more >Extend on-premises Active Directory to an existing Amazon ...
The following steps guide you through an Active Directory deployment with AWS Launch Wizard after you have launched it from the console for...
Read more >Extending a Controller in AngularJS - Tushar Ghate
A good way to minimize code duplication is to create a base controller and extend it's behavior in other controllers.
Read more >lightning component extend existing Apex class
Error while creating component for lightning component quick action [Unable to find action 'getAccount' on the controller of c:Clone]" Please ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure if
.extend
is still around, but I wouldn’t recommend it. Using an ES6 class withextend
is much more natural.You don’t have to do
Chart.controllers.myline = Custom;
unless you’ve done ascript
import, but I’d recommend usingnpm
instead.Here’s an example chart that uses Chart.js 3: https://github.com/chartjs/chartjs-chart-financial
I think this is due to
I think #7435 would resolve this though.