Chartjs-Chart.elements.Rectangle.prototype.draw inpacting on other charts in the same page(Angular)

0๐Ÿ‘

โœ…

I think you could try to use the method extend of the the RectangleElement, and also the BarController, adding the property dataElementType, like this:

const rectangleElement = Chart.elements.Rectangle;
const otherRectangleElement = rectangleElement.extend({
    draw() {
        const ctx = this._chart.ctx;
        // ...
    }
}

Chart.defaults.CustomerRetention = Chart.defaults.bar;

Chart.controllers.CustomerRetention = Chart.controllers.bar.extend({
    dataElementType: otherRectangleElement,
    draw(ease) {
        Chart.controllers.bar.prototype.draw.call(this, ease);
        // ...
    }
}

Leave a comment