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

Method _updateVisibility

src/core/core.controller.js:896–910  ·  view source on GitHub ↗

* @private

(datasetIndex, dataIndex, visible)

Source from the content-addressed store, hash-verified

894 * @private
895 */
896 _updateVisibility(datasetIndex, dataIndex, visible) {
897 const mode = visible ? 'show' : 'hide';
898 const meta = this.getDatasetMeta(datasetIndex);
899 const anims = meta.controller._resolveAnimations(undefined, mode);
900
901 if (defined(dataIndex)) {
902 meta.data[dataIndex].hidden = !visible;
903 this.update();
904 } else {
905 this.setDatasetVisibility(datasetIndex, visible);
906 // Animate visible state, so hide animation can be seen. This could be handled better if update / updateDataset returned a Promise.
907 anims.update(meta, {visible});
908 this.update((ctx) => ctx.datasetIndex === datasetIndex ? mode : undefined);
909 }
910 }
911
912 hide(datasetIndex, dataIndex) {
913 this._updateVisibility(datasetIndex, dataIndex, false);

Callers 2

hideMethod · 0.95
showMethod · 0.95

Calls 6

getDatasetMetaMethod · 0.95
updateMethod · 0.95
setDatasetVisibilityMethod · 0.95
definedFunction · 0.85
updateMethod · 0.65
_resolveAnimationsMethod · 0.45

Tested by

no test coverage detected