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

Method _deactivateHidden

src/core/core.controller.js:550–583  ·  view source on GitHub ↗

* Drops the hidden data from the active elements before the datasets update, so * the update resolves their normal options. Their hover style ends without the * un-hover animation: the update animates them in its own mode, such as 'hide'. * @private

()

Source from the content-addressed store, hash-verified

548 * @private
549 */
550 _deactivateHidden() {
551 const lastActive = this._active;
552 if (!lastActive.length) {
553 return;
554 }
555 const isShown = this._activeFilter();
556 const active = [];
557 const dropped = new Set();
558 let datasetIndex, controller;
559 for (const item of lastActive) {
560 if (isShown(item)) {
561 active.push(item);
562 continue;
563 }
564 if (item.datasetIndex !== datasetIndex) {
565 datasetIndex = item.datasetIndex;
566 dropped.add(datasetIndex);
567 // A removed dataset has no meta left, and getDatasetMeta would make one.
568 controller = this.data.datasets[datasetIndex] && this.getDatasetMeta(datasetIndex).controller;
569 }
570 if (controller) {
571 controller._clearHoverStyle(item.element, item.index);
572 } else {
573 item.element.active = false;
574 }
575 }
576 if (active.length === lastActive.length) {
577 return;
578 }
579 this._active = active;
580 if (this.options.hover.mode === 'dataset') {
581 this._deactivateDatasetElements(dropped, active);
582 }
583 }
584
585 /**
586 * In hover mode 'dataset', ends the active state of the dataset elements whose

Callers 1

updateMethod · 0.95

Calls 5

_activeFilterMethod · 0.95
getDatasetMetaMethod · 0.95
_clearHoverStyleMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected