MCPcopy Create free account
hub / github.com/chartjs/Chart.js / draw

Method draw

src/core/core.controller.js:777–811  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

775 }
776
777 draw() {
778 let i;
779 if (this._resizeBeforeDraw) {
780 const {width, height} = this._resizeBeforeDraw;
781 // Unset pending resize request now to avoid possible recursion within _resize
782 this._resizeBeforeDraw = null;
783 this._resize(width, height);
784 }
785 this.clear();
786
787 if (this.width <= 0 || this.height <= 0) {
788 return;
789 }
790
791 if (this.notifyPlugins('beforeDraw', {cancelable: true}) === false) {
792 return;
793 }
794
795 // Because of plugin hooks (before/afterDatasetsDraw), datasets can't
796 // currently be part of layers. Instead, we draw
797 // layers <= 0 before(default, backward compat), and the rest after
798 const layers = this._layers;
799 for (i = 0; i < layers.length && layers[i].z <= 0; ++i) {
800 layers[i].draw(this.chartArea);
801 }
802
803 this._drawDatasets();
804
805 // Rest of layers
806 for (; i < layers.length; ++i) {
807 layers[i].draw(this.chartArea);
808 }
809
810 this.notifyPlugins('afterDraw');
811 }
812
813 /**
814 * @private

Callers 1

renderMethod · 0.95

Calls 5

_resizeMethod · 0.95
clearMethod · 0.95
notifyPluginsMethod · 0.95
_drawDatasetsMethod · 0.95
drawMethod · 0.65

Tested by

no test coverage detected