Skip to content

Ability to configure visibility status of a dataset, to retain visibility state of datasets hidden by clicking Legend label #8451

@kashifshamaz21

Description

@kashifshamaz21

Feature Proposal

I'm using Chart.js (v3.x.x) with React, using chartjs-react wrapper.

I would like to know if there is a way to configure a dataset to be hidden. The use case is described below, wherein, once a dataset is hidden by clicking on its legend label, the visibility of this dataset can't be retained when new datasets are added to the graph.

Feature Use Case

When a dataset in a line chart gets hidden by clicking on its label in the legend, and then if a new dataset is added, the previously hidden dataset gets enabled/shown again as the component re-renders and I could not find a way to set the "visibility / hidden" status of a dataset in the docs.

Possible Implementation

Using the generateLabels and onClick callbacks on Legend plugin, one can keep track of which fields are in hidden state.
By exposing a hidden property in the dataset's config, consumers can configure which datasets they would like to be in hidden state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions