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

Method _updateVisibility

src/core/core.controller.js:892–906  ·  view source on GitHub ↗

* @private

(datasetIndex, dataIndex, visible)

Source from the content-addressed store, hash-verified

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