MCPcopy
hub / github.com/chartjs/Chart.js / draw

Method draw

src/core/core.controller.js:698–732  ·  src/core/core.controller.js::Chart.draw
()

Source from the content-addressed store, hash-verified

696 }
697
698 draw() {
699 let i;
700 if (this._resizeBeforeDraw) {
701 const {width, height} = this._resizeBeforeDraw;
702 class="cm">// Unset pending resize request now to avoid possible recursion within _resize
703 this._resizeBeforeDraw = null;
704 this._resize(width, height);
705 }
706 this.clear();
707
708 if (this.width <= 0 || this.height <= 0) {
709 return;
710 }
711
712 if (this.notifyPlugins(class="st">'beforeDraw', {cancelable: true}) === false) {
713 return;
714 }
715
716 class="cm">// Because of plugin hooks (before/afterDatasetsDraw), datasets can't
717 class="cm">// currently be part of layers. Instead, we draw
718 class="cm">// layers <= 0 before(default, backward compat), and the rest after
719 const layers = this._layers;
720 for (i = 0; i < layers.length && layers[i].z <= 0; ++i) {
721 layers[i].draw(this.chartArea);
722 }
723
724 this._drawDatasets();
725
726 class="cm">// Rest of layers
727 for (; i < layers.length; ++i) {
728 layers[i].draw(this.chartArea);
729 }
730
731 this.notifyPlugins(class="st">'afterDraw');
732 }
733
734 /**
735 * @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