How to add Legend to Bar Chart

I haven’t been able to find any docs on added a legend to a stacked bar chart.
Is there a way?

Thanks
Joe

I watched the videos on the youtube channel and I recall one video where Alan explains this:

Hello @SenseiJoe and a big warm welcome to the universal dashboard forums. Thanks for your post, so here is the code I use to produce my “stacked bar chart” which has legend at the top…Just for clarification the $TrendData is holding the output of the SQL query…I then do this to get my lovely looking stacked bar chart with legend:-

$TrendData | Select-Object MonthName,Quality,Transport,Staff,Delivery,Admin,Stock | Out-UDChartData -LabelProperty "MonthName" -DataProperty "Total" -Dataset @(
 New-UDChartDataset -DataProperty "Quality" -Label "Quality" -BackgroundColor "#6a0136" -BorderColor "#6a0136" -HoverBackgroundColor "#6a0136"
 New-UDChartDataset -DataProperty "Transport" -Label "Transport" -BackgroundColor "#404e4d" -BorderColor "#404e4d"  -HoverBackgroundColor "#404e4d"
 New-UDChartDataset -DataProperty "Staff" -Label "Staff" -BackgroundColor "#c3423f" -BorderColor "#c3423f"  -HoverBackgroundColor "#c3423f"
 New-UDChartDataset -DataProperty "Delivery" -Label "Delivery" -BackgroundColor "#9bc53d" -BorderColor "#9bc53d"  -HoverBackgroundColor "#9bc53d"
 New-UDChartDataset -DataProperty "Admin" -Label "Admin" -BackgroundColor "#fde74c" -BorderColor "#fde74c" -HoverBackgroundColor "#fde74c"
 New-UDChartDataset -DataProperty "Stock" -Label "Stock" -BackgroundColor "#5bc0eb" -BorderColor "#5bc0eb"  -HoverBackgroundColor "#5bc0eb"
 )
                    }  -Labels @("MonthName") -Options @{
                        scales = @{
                            xAxes = @(
                                @{
                                    stacked = $true
                                }
                            )
                            yAxes = @(
                                @{
                                    stacked = $true
                                }
                            )
                        }
                    }

I am also looking to write more on my blog page for UD here:- https://psdevuk.github.io/ud-flix/ so if you think this would make a good blog post let me know.

Thanks, I’ll take a look.

Thanks for the quick response, I guess I should have been more specific. I’m using the Nivo Charts. Is that any different?

My data shows up as expected, would like to see some legends.

Joe

        New-UDNivoChart -Id 'DevPRs' -Bar -Data $ChartData -Keys $KeyList -IndexBy 'repo' -Height 300 -Width 900 -MarginTop 50 -MarginRight 130 -MarginBottom 50 -MarginLeft 60 -Padding 0.3

Ok good question, I had a butchers at the parameter sets and cannot see anything obvious in there… @adam can you please enlighten us both? Please and thank you