showing results for - "chart js stacked bar group"
Aida
06 Feb 2020
1new Chart(document.getElementById("MyChart"), {
2  type: 'bar',
3  data: {
4    labels: [2017, 2018, 2019, 2020, 2021, 2022, 2023],
5    datasets: [{
6      label: "Income - Base",
7      type: "bar",
8      stack: "Base",
9      backgroundColor: "#eece01",
10      data: [30, 31, 32, 33, 34, 35, 36],
11    }, {
12      label: "Tax - Base",
13      type: "bar",
14      stack: "Base",
15      backgroundColor: "#87d84d",
16      data: [-15, -16, -17, -18, -19, -20, -21],
17    }, {
18      label: "Income - Sensitivity",
19      type: "bar",
20      stack: "Sensitivity",
21      backgroundColor: "#f8981f",      
22      data: [20, 21, 22, 23, 24, 25, 26],
23    }, {
24      label: "Tax - Sensitivity",
25      type: "bar",
26      stack: "Sensitivity",
27      backgroundColor: "#00b300",
28      backgroundColorHover: "#3e95cd",
29      data: [-10, -11, -12, -13, -14, -15, -16]
30    }]
31  },
32  options: {
33    scales: {
34      xAxes: [{
35        //stacked: true,
36        stacked: true,
37        ticks: {
38          beginAtZero: true,
39          maxRotation: 0,
40          minRotation: 0
41        }
42      }],
43      yAxes: [{
44        stacked: true,
45      }]
46    },
47  }
48});