Skip to content

[Bug]: Chart.js type does not update on prop change #1054

@BlenderDude

Description

@BlenderDude

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

Current behavior:
When changing the prop type, the underlying chart does not update until the entire component re-renders.

Expected behavior:
When changing the prop type, the underlying chart updates (redraws) with the new type.

Reproduction

https://codesandbox.io/s/chart-type-update-issue-iym5e9

chart.js version

v3.8.0

react-chartjs-2 version

v4.2.0

Possible solution

Redraw the chart upon type change, I will be submitting a PR momentarily

[edit] Confirmation of ChartJS not working: https://stackoverflow.com/questions/36949343/chart-js-dynamic-changing-of-chart-type-line-to-bar-as-example

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions