Somebody give a Chart.controllers.bar.extend example?
See original GitHub issueI’m stuck in extend bar chart. I use codes below but not working…
Chart.controllers.bar.extend({
draw: function() {
Chart.controllers.bar.prototype.draw.call(this, arguments);
/* your own drawing code here */
console.log(this); // but no any console log appear
}
});
var sleepToday = new Chart(ctx, {
type: 'bar',
data: data,
options: options
});
Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Extend bar chart on Chart JS 2 into a new type of Chart
I finally suceeded in creating the new type that extend the bar type and add a line if the value is provided. //...
Read more >Extend bar chart on Chart JS 2 into a new type of Chart-Chart.js
I finally suceeded in creating the new type that extend the bar type and add a line if the value is provided. //...
Read more >Layout - Foundations - Human Interface Guidelines - Design
Extend visual content to fill the screen. Make sure backgrounds extend to the edges of the display, and that vertically scrollable layouts, like...
Read more >Chapter 2: Aeronautical Decision-Making - FAA
Controllers work to make flights as safe as possible. time to use a particular resource and the impact its use will have upon...
Read more >Apache NiFi User Guide
Controller Service: Controller Services are extension points that, ... This Template is given a name and can then be dragged onto the canvas ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Bump. Is there an issue with extension that is being looked at currently? Looking at the docs, it isn’t 100% clear as to the best approach to extending an existing chart type. Whilst the code posted by Rafael does achieve the extension (Thanks Rafael for posting that!), surely this isn’t the preferred means to extend? Like Iain said, it would be really nice to have a clear example in the docs.
For anyone who may stumble across this, here is how I created a new chart type based on the line chart. Credit to Rafael for pointing out that Chart.defaults needed to be set.
Rafael’s code is close to the recommended way to extend a chart type. I think there is a bug here because we shouldn’t cause a problem if the defaults are not defined. I’ve added comments for each line of the
I have an example of a chart derived from one of the existing types. I wrote a Smith Chart which derives from a line chart. I think you can use that as a partial reference for getting started.
If you don’t want to create a new chart, you would simply extend
Chart.DatasetController
to your liking. The API that needs to be implemented is documented at http://www.chartjs.org/docs/#advanced-usage-writing-new-chart-types