How to create a stacked bar graph

Based on data format example here: https://github.com/node-red/node-red-dashboard/blob/master/Charts.md#bar-and-pie-charts
And chartjs documentation here: https://www.chartjs.org/docs/latest/charts/bar.html#stacked-bar-chart
You will need to change options for chart to make bars stacked.
Use msg.ui_control property to send options.

msg.payload = [{
    "series": ["X", "Y", "Z" ],
    "data": [ [5,6,9], [3,8,5], [6,7,2] ],
    "labels": [ "Jan", "Feb", "Mar" ]
}]
msg.ui_control = {
     options: {
        scales: {
            xAxes: [{
                stacked: true
            }],
            yAxes: [{
                stacked: true
            }]
        }
    }
}

return msg;
8 Likes