chartjs stacked group code example

Example: chart js stacked bar group

new Chart(document.getElementById("MyChart"), {
  type: 'bar',
  data: {
    labels: [2017, 2018, 2019, 2020, 2021, 2022, 2023],
    datasets: [{
      label: "Income - Base",
      type: "bar",
      stack: "Base",
      backgroundColor: "#eece01",
      data: [30, 31, 32, 33, 34, 35, 36],
    }, {
      label: "Tax - Base",
      type: "bar",
      stack: "Base",
      backgroundColor: "#87d84d",
      data: [-15, -16, -17, -18, -19, -20, -21],
    }, {
      label: "Income - Sensitivity",
      type: "bar",
      stack: "Sensitivity",
      backgroundColor: "#f8981f",      
      data: [20, 21, 22, 23, 24, 25, 26],
    }, {
      label: "Tax - Sensitivity",
      type: "bar",
      stack: "Sensitivity",
      backgroundColor: "#00b300",
      backgroundColorHover: "#3e95cd",
      data: [-10, -11, -12, -13, -14, -15, -16]
    }]
  },
  options: {
    scales: {
      xAxes: [{
        //stacked: true,
        stacked: true,
        ticks: {
          beginAtZero: true,
          maxRotation: 0,
          minRotation: 0
        }
      }],
      yAxes: [{
        stacked: true,
      }]
    },
  }
});