Showing values in chart
$userObjects=Get-ADUser -Filter *
$chart = $userObjects | Group-Object Department | Select-Object Name, @{Name = "Values"; Expression = { [math]::round(((($_.Count) / $userObjects.Count) * 100), 2) } } | Where-Object { $_.Values -ge 1 } | Sort-Object -Descending Values
Add-WordText -WordDocument $reportFile -HeadingType Heading3 -Text "Chart" -Supress $true
Add-WordPieChart -WordDocument $reportFile -ChartName 'Chartk'-ChartLegendPosition Bottom -ChartLegendOverlay $false -Names $([array]$chart.Name) -Values $([array]$chart.Values)
I want to show values in chart legend or on the chart image. How to do this?
Basically, you would need to build Names with values inside.
$userObjects = Get-ADUser -Filter *
$chart = $userObjects | Group-Object Department | Select-Object Name, @{Name = "Values"; Expression = { [math]::round(((($.Count) / $userObjects.Count) * 100), 2) } } | Where-Object { $.Values -GE 1 } | Sort-Object -Descending Values
Add-WordText -WordDocument $reportFile -HeadingType Heading3 -Text "Chart" -Supress $true
[array] $Names = foreach ($O in $Chart) {
"$($O.Name) ($($O.Values))"
}
Add-WordPieChart -WordDocument $reportFile -ChartName 'Chartk'-ChartLegendPosition Bottom -ChartLegendOverlay $false -Names $Names -Values $([array]$chart.Values)
But is it possible to simplify that by adding more options to cmdlet. Like adding values to pie like: percent values or simple values or something?
or percent values

Yes, you can create PR to do it for you.
I try to do it with calculated field but no results( to simplify my code). But, do you know how to do the second version of graph from my images nad paste the code here?
You just need to calculate the percentage yourself. My code won't do it for you.
I know how to calculate it but dont know how to pass it into pie like in the 2 image