How do I create different scales for my charts?

Viewed 43

I am trying to stack my bars but leave all my lines unstacked. I tried to create two sets of y and x settings but I get the error. Invalid scale configuration for scale: yAxes

So far the only documentation I've seen is you can create an array of objects with id's that assign those to my datasets. Here is my code.

 export const options = {
  responsive: true,
  plugins: {
    legend: {
      position: 'top',
    },
    title: {
      display: true,
      text: 'Chart.js Line Chart',
    },
  },
  scales:{
    xAxes:{
      stacked:true
    },
    yAxes:[{
      id:'LineYAxis',
      stacked:false
    },{
      id:'BarYAxis',
      stacked:true
    }]
  }
};

Any direction on this would be really appreciated. Also is there a better place then the github or the chartjs website to find documentation? I just feel a lot of examples are missing. Thanks.

EDIT: I know that in v3 the syntax was changed and now x and y axis scales are no longer stored as an array but I'm unsure what the new syntax should be if I need to configure multiple sets of x or y axes. I'm essentially trying to do this My Problem

Sandbox

EDIT: I've kind of gotten it to work however for some reason the scale for my barchart is capping at 1 instead of auto selecting a reasonable scale. Secondly I now have 2 y-axes instead of just 1. Updated version is in the sandbox.

Solution

0 Answers
Related