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

Method draw

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

Source from the content-addressed store, hash-verified

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