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

Method _update

src/core/core.animator.js:57–107  ·  view source on GitHub ↗

* @private

(date = Date.now())

Source from the content-addressed store, hash-verified

55 * @private
56 */
57 _update(date = Date.now()) {
58 let remaining = 0;
59
60 this._charts.forEach((anims, chart) => {
61 if (!anims.running || !anims.items.length) {
62 return;
63 }
64 const items = anims.items;
65 let i = items.length - 1;
66 let draw = false;
67 let item;
68
69 for (; i >= 0; --i) {
70 item = items[i];
71
72 if (item._active) {
73 if (item._total > anims.duration) {
74 // if the animation has been updated and its duration prolonged,
75 // update to total duration of current animations run (for progress event)
76 anims.duration = item._total;
77 }
78 item.tick(date);
79 draw = true;
80 } else {
81 // Remove the item by replacing it with last item and removing the last
82 // A lot faster than splice.
83 items[i] = items[items.length - 1];
84 items.pop();
85 }
86 }
87
88 if (draw) {
89 chart.draw();
90 this._notify(chart, anims, date, 'progress');
91 }
92
93 if (!items.length) {
94 anims.running = false;
95 this._notify(chart, anims, date, 'complete');
96 anims.initial = false;
97 }
98
99 remaining += items.length;
100 });
101
102 this._lastDate = date;
103
104 if (remaining === 0) {
105 this._running = false;
106 }
107 }
108
109 /**
110 * @private

Calls 3

_notifyMethod · 0.95
tickMethod · 0.80
drawMethod · 0.65

Tested by

no test coverage detected