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

Method _updateVisibility

src/core/core.controller.js:971–985  ·  view source on GitHub ↗

* @private

(datasetIndex, dataIndex, visible)

Source from the content-addressed store, hash-verified

969 * @private
970 */
971 _updateVisibility(datasetIndex, dataIndex, visible) {
972 const mode = visible ? 'show' : 'hide';
973 const meta = this.getDatasetMeta(datasetIndex);
974 const anims = meta.controller._resolveAnimations(undefined, mode);
975
976 if (defined(dataIndex)) {
977 meta.data[dataIndex].hidden = !visible;
978 this.update();
979 } else {
980 this.setDatasetVisibility(datasetIndex, visible);
981 // Animate visible state, so hide animation can be seen. This could be handled better if update / updateDataset returned a Promise.
982 anims.update(meta, {visible});
983 this.update((ctx) => ctx.datasetIndex === datasetIndex ? mode : undefined);
984 }
985 }
986
987 hide(datasetIndex, dataIndex) {
988 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