Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TheoLaperrouse opened this issue May 17, 2021 · 7 comments · Fixed by #9105 or #9170
Closed

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

TheoLaperrouse opened this issue May 17, 2021 · 7 comments · Fixed by #9105 or #9170

Comments

@TheoLaperrouse
Copy link

TheoLaperrouse commented May 17, 2021

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)
@kurkle
Copy link
Member

kurkle commented May 17, 2021

Reproduces with master: https://jsfiddle.net/f1mt0hg5/1/

@kurkle
Copy link
Member

kurkle commented May 17, 2021

The issue is invalid scales config, works fine if the scales are configured properly (master): https://jsfiddle.net/f1mt0hg5/3/
3.2.1 still has the issue: https://jsfiddle.net/m8ex0sbw/

@kurkle
Copy link
Member

kurkle commented May 17, 2021

I think this was fixed in #9105

@kurkle kurkle linked a pull request May 17, 2021 that will close this issue
@kurkle kurkle closed this as completed May 17, 2021
@TheoLaperrouse
Copy link
Author

Hello again,
We have upgraded our application to chartJS 3.3.0 and we are still experiencing the same problem. After spending quite a bit of time looking at our chart configurations, it seems that the problem is that we are using yAxisID to reference the y-axis in our datasets.

When we use y-axis-1 as the axis name and reference it in our datasets. We have the same problem as mentioned above in the issue.
https://jsfiddle.net/guza6sec/1

However, when we remove these yAxisIDs and change the name of the y-axis to y, the behaviour is what we want.
https://jsfiddle.net/guza6sec

For us, however, these two examples should have the same behaviour.

@kurkle kurkle reopened this May 27, 2021
@kurkle kurkle changed the title Change on stack does not update the chart properly Change on stack does not update the chart properly with non-default scaleId May 27, 2021
@kurkle
Copy link
Member

kurkle commented May 27, 2021

@TheoLaperrouse looks like there is another bug in there.

@etimberg etimberg linked a pull request May 29, 2021 that will close this issue
@etimberg
Copy link
Member

I believe the 2nd issue was fixed in #9170

@kurkle
Copy link
Member

kurkle commented May 29, 2021

Looks like I had linked a wrong number there, this was indeed fixed.

@kurkle kurkle closed this as completed May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants