chartjs / chartjs/Chart.js

Update dataset to default values from array not working

Open
#11,679 8 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

When deleting a dataset property (or setting it to null) it should have its default values after `chart.update()`, independent if it was a single value or an array.

### Current behavior

When deleting a dataset property (or setting it to null) when it was an array does not reset its default value.

### Reproducible sample

https://codepen.io/Ipax77-the-flexboxer/pen/jOJoWqJ

### Optional extra steps/info to reproduce

Click "Update Test Arrays" then "Reset"
("Update Test Single" then "Reset" is working as expected)

### Possible solution

It is working when you do a chart.update() after setting each property to null (codepen line 43), but then you have multiple animations (or none with chart.update('none')).

### Context

I want to be able to update datasets with animations for my [Blazor wrapper library](https://github.com/ipax77/pax.BlazorChartJs).

### chart.js version

v4.4.1

### Browser name and version

Chrome 121.0.6167.185

### Link to your project

https://github.com/ipax77/pax.BlazorChartJs

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.