question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change on stack does not update the chart properly with non-default scaleId

See original GitHub issue

Expected Behavior

When I change the stack of one of the datasets, I would like the graph to update correctly.

Current Behavior

Here, the dataset stays in the same place when it should go down

Steps to Reproduce

Example

Here is a link with small datasets where you can see the issue : JsFiddle

Here is what I would like to have when I update the chart : JsFiddle

Chart Config:

const myChart = new Chart(ctx, {
  type: "bar",
  data: {
    labels: ["January", "February", "March", "April", "May", "June"],
    datasets: [
      {
        backgroundColor: "rgba(255,99,132,0.8)",
        label: "Dataset 1",
        data: [12, 19, 3, 5, 2, 3],
        stack: "0"
      },
      {
        backgroundColor: "rgba(54,162,235,0.8)",
        label: "Dataset 2",
        data: [13, 19, 3, 5, 8, 3],
        stack: "0" //When I change this, the chart is not updated correctly
      },
      {
        backgroundColor: "rgba(75,192,192,0.8)",
        label: "Dataset 3",
        data: [13, 19, 3, 5, 8, 3],
        stack: "0"
      }
    ]
  },
  options: {
    scales: {
      yAxes: [
        {
          ticks: {
            beginAtZero: true
          }
        }
      ]
    }
  }
});

Context

When I edit a chart, the editing preview is not the same depending on whether I reload the page or not.

Here is when i’m editing: Capture d’écran de 2021-05-17 15-14-56

Then i save the configuration and i update the chart: Capture d’écran de 2021-05-17 15-15-32

Environment

  • Chart.js version: 3.2.0
  • Browser name and version: Firefox 88.0.1 (64 bits)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kurklecommented, May 27, 2021

@TheoLaperrouse looks like there is another bug in there.

1reaction
kurklecommented, May 17, 2021

I think this was fixed in #9105

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't update chart - Stack Overflow
Remember that you assigned the newly created chart to the variable barChart . Therefore, try to change your updateConfigByMutating from.
Read more >
Chart.js - Bountysource
Change on stack does not update the chart properly with non-default scaleId $ 0 ... Created 1 year ago in chartjs/Chart.js with 5...
Read more >
Updating Charts | Chart.js
Scales can be updated separately without changing other options. To update the scales, pass in an object containing all the customization ...
Read more >
chart js show x axis labels
X and Y axis labels are by default disabled in Highmaps, ... If you are still not installed Vue. etimberg added the status:...
Read more >
Excel 2013: stacked bar chart with date, updating date issue
A quick and easy fix to your issue is to set the minimum and maximum values for your x-axis to the window which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found