Extending Existing Chart Types angular chart js using chart js 2.0

吃可爱长大的小学妹 提交于 2019-12-01 07:38:26

A bit late answer but you can extend the shape of the element, not the type of the specific chart, from v2.

For example,

Chart.elements.Rectangle.prototype.draw = function() {
   // Do your draw thingy.
}

There's an issue regarding this one at the official Github repo and also a great example of implementing it.

Try this for the line chart:

var originalLineController = Chart.controllers.line;
Chart.controllers.line = Chart.controllers.line.extend({
    draw: function() { 
        originalLineController.prototype.draw.apply(this, arguments);
        /* own drawing code here */
    }
}

You can get the context with:

var ctx = this.chart.chart.ctx;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!