Skip to content

Make the chart.data.datasets.dataset.hidden reflect the actual value #11339

@szmarczak

Description

@szmarczak

Feature Proposal

    chart.data.datasets = Object.keys(data[territorialUnit]).map(representationMethod => {
        const hidden = chart.data.datasets.find(entry => entry.label === representationMethod)?.hidden;

        return {
            label: representationMethod,
            data: Object.fromEntries(Object.entries(data[territorialUnit][representationMethod]).filter(filter)),
            borderWidth: 1,
            hidden: hidden ?? representationMethod !== defaultRepresentationMethod,
        };
    });

    chart.update();

The above is always resetting hidden to the default value (the !==), because dataset.hidden is not updated when user interacts.

I'm assigning datasets this way instead of .data = because I'm downloading the data asynchronously, so there's no initial data when the chart is created. I'm not checking if the dataset already exists, because in my opinion this would be unnecessary code.

Possible Implementation

No response

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