EvotecIT / PSWriteHTML

PSWriteHTML is PowerShell Module to generate beautiful HTML reports, pages, emails without any knowledge of HTML, CSS or JavaScript. To get started basics PowerShell knowledge is required.
MIT License
826 stars 106 forks source link

New-ChartLegend is not showing labels on Bar/Pie Chart #249

Closed Kettoch closed 3 years ago

Kettoch commented 3 years ago

I have the following code that receives a PSObject with three fields. What I get is a pie chart that obeys colors either with the theme or directly assigned on the legend. But i get no labels on the legend on the right.

Dashboard -Name 'Bounce Chart' -FilePath C:\Scripts\DashboardChartsBar00.html {
    TabOptions -slimtabs
    Tab -Name 'Bounce Chart by Type' {
        Panel {
            Chart {
                ChartTheme -Palette palette6
                ChartLegend  -FontSize 14 -FontFamily 'Arial'
                foreach ($Bounce in $Bounces) {
                    ChartPie -Name $Bounce.BounceTypeName -Value $Bounce.Total
                }
            }
        }
        Section -Invisible {
            Table -DataTable $BounceList -HideFooter {
                Table -title 'Email Address'
                TableHeader -names 'EmailAddress' -alignment Left
                TableHeader -names 'Bounce Type','Date' -alignment Center
                TableContent -ColumnIndex 2,3 -alignment center
            }
        }
    }
} -Show

I have tried adding -names either by $Bounces.BounceTypeName or by @('Hard Bounce','Soft Bounce') or not even including it.

I am not sure what i am missing as I get the color dots of the legend and no text. Nor can I get labels on the pie other than %.

PrzemyslawKlys commented 3 years ago
$Bounces = @(
    [PSCustomObject] @{ BounceTypeName = 'Area1'; Total = 5 }
    [PSCustomObject] @{ BounceTypeName = 'Area2'; Total = 13 }
    [PSCustomObject] @{ BounceTypeName = 'Area3'; Total = 18 }
    [PSCustomObject] @{ BounceTypeName = 'Area4'; Total = 1 }
)

Dashboard -Name 'Bounce Chart' -FilePath C:\Scripts\DashboardChartsBar00.html {
    TabOptions -slimtabs
    Tab -Name 'Bounce Chart by Type' {
        Panel {
            Chart {
                ChartTheme -Palette palette6
                ChartLegend  -FontSize 14 -FontFamily 'Arial'
                foreach ($Bounce in $Bounces) {
                    ChartPie -Name $Bounce.BounceTypeName -Value $Bounce.Total
                }
            }
        }
        Section -Invisible {
            Table -DataTable $Bounces -HideFooter {
                Table -title 'Email Address'
                TableHeader -names 'EmailAddress' -alignment Left
                TableHeader -names 'Bounce Type','Date' -alignment Center
                TableContent -ColumnIndex 2,3 -alignment center
            }
        }
    }
} -Show

That's what I get

image

Seems to work?