How to create a stacked bar graph

Hi, I need to create a staked bar graph. Is this possible with the node-red dashboard?
example:

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

Nice example!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.