Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

What happened to support for multiple X axes?

Open timmay7 opened this issue 5 years ago • 3 comments

In v2, you could have two X axes using the following example: scales: { xAxes: [ { ... }, { ... } ] } I don't see how to do this in v3, and tried to dig into the docs.

Just to be clear, I've attached a screenshot showing a use case for the double X axes, with month as one axes, and year as the other. Chart was generated in v2. double-x-axes

timmay7 avatar Apr 12 '21 23:04 timmay7

This is now done via:

new Chart(ctx, {
  type: 'line',
  data: data,
  options: {
    scales: {
      x: { ...config },
      x2: {
        type: 'category',
        position: 'bottom',
      }
    }
  }
}

See https://www.chartjs.org/docs/latest/samples/other-charts/scatter-multi-axis.html for an example

etimberg avatar Apr 12 '21 23:04 etimberg

I have exactly the same problem after upgrading chartjs from v2 to v3. Now It seems that the dataset will only bind to one axis but not the other. @timmay7 Could you share how you could create the same chart in new version?

edwardyh80 avatar May 15 '21 08:05 edwardyh80

In v3 datasets only bind to one x-axis. You can set the min/max of the 2nd axis manually to make it display same range.

kurkle avatar May 15 '21 09:05 kurkle