Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add pester test to validate the functionality of the New-DonutChart cmdlet
- Add example 12/13 to document on how to use the New-DonutChart cmdlet
- Add radar chart support: implement New-RadarChart cmdlet and associated classes
- Add pester test to validate the functionality of the New-RadarChart cmdlet
- Add example 14/15 to document on how to use the New-RadarChart cmdlet

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Examples/Example12.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#
.SYNOPSIS
Example 01 - Basic Donut Chart
Example 12 - Basic Donut Chart

.DESCRIPTION
This example demonstrates how to create a basic Donut Chart using the AsBuiltReport.Chart module.
Expand Down
2 changes: 1 addition & 1 deletion Examples/Example13.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#
.SYNOPSIS
Example 02 - Donut Chart with Legend, Custom Colors and Border
Example 13 - Donut Chart with Legend, Custom Colors and Border

.DESCRIPTION
This example demonstrates how to create a Donut Chart with additional visual options, including:
Expand Down
62 changes: 62 additions & 0 deletions Examples/Example14.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<#
.SYNOPSIS
Example 14 - Basic Radar Chart

.DESCRIPTION
This example demonstrates how to create a basic Radar Chart using the AsBuiltReport.Chart module.
The chart displays a simple security posture assessment for two data centers across multiple categories.
#>

[CmdletBinding()]
param (
[System.IO.DirectoryInfo] $Path = (Get-Location).Path,
[string] $Format = 'png'
)

<#
Starting with PowerShell v3, modules are auto-imported when needed. Importing the module here
ensures clarity and avoids ambiguity.
#>

# Import-Module AsBuiltReport.Chart -Force -Verbose:$false

<#
Since the chart output is a file, specify the output folder path using $OutputFolderPath.
#>

$OutputFolderPath = Resolve-Path $Path

<#
Define the data to be displayed in the chart.
In a real-world scenario these values would come from your infrastructure query.
#>

$ChartTitle = 'Security Posture Assessment'
$Values = @(@(3,5,4,2))
$Labels = @('USA DataCenter')

<#
The New-RadarChart cmdlet generates the Radar Chart image.

-Title : Sets the chart title displayed at the top of the image.
-Values : Array of numeric values, one per axis.
-LegendLabels : Array of label strings corresponding to each value.
-Format : Output file format (e.g. png, jpg, svg).
-OutputFolderPath : Directory where the generated chart file will be saved.
-Width : Width of the chart image in pixels.
-Height : Height of the chart image in pixels.
-ColorPalette : Predefined color palette (e.g. Category20, Pastel).
-Filename : Name of the output file (without extension).
#>

New-RadarChart `
-Title $ChartTitle `
-Values $Values `
-LegendLabels $Labels `
-Format $Format `
-EnableLegend `
-OutputFolderPath $OutputFolderPath `
-Width 600 `
-Height 400 `
-ColorPalette Category20 `
-Filename 'Example14-RadarChart'
67 changes: 67 additions & 0 deletions Examples/Example15.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
.SYNOPSIS
Example 15 - Advanced Radar Chart

.DESCRIPTION
This example demonstrates how to create a Advanced Radar Chart using the AsBuiltReport.Chart module.
The chart displays a security posture assessment for two data centers across multiple categories.
#>

[CmdletBinding()]
param (
[System.IO.DirectoryInfo] $Path = (Get-Location).Path,
[string] $Format = 'png'
)

<#
Starting with PowerShell v3, modules are auto-imported when needed. Importing the module here
ensures clarity and avoids ambiguity.
#>

# Import-Module AsBuiltReport.Chart -Force -Verbose:$false

<#
Since the chart output is a file, specify the output folder path using $OutputFolderPath.
#>

$OutputFolderPath = Resolve-Path $Path

<#
Define the data to be displayed in the chart.
In a real-world scenario these values would come from your infrastructure query.
#>

$ChartTitle = 'Security Posture Assessment'
$Values = @(@(1, 2, 5, 8), @(3, 5, 4, 2))
$Labels = @('USA DataCenter', 'UK DataCenter')
$Spokes = @('Network Security', 'Endpoint Security', 'Identity Management', 'Data Protection')

<#
The New-RadarChart cmdlet generates the Radar Chart image.

-Title : Sets the chart title displayed at the top of the image.
-Values : Array of numeric values, one per axis.
-LegendLabels : Array of label strings corresponding to each value.
-SpokeLabels : Array of label strings for each spoke on the radar chart.
-SpokesLength : Length of the spokes (axes) in the radar chart.
-Format : Output file format (e.g. png, jpg, svg).
-OutputFolderPath : Directory where the generated chart file will be saved.
-Width : Width of the chart image in pixels.
-Height : Height of the chart image in pixels.
-ColorPalette : Predefined color palette (e.g. Category20, Pastel).
-Filename : Name of the output file (without extension).
#>

New-RadarChart `
-Title $ChartTitle `
-Values $Values `
-LegendLabels $Labels `
-SpokeLabels $Spokes `
-SpokesLength 9 `
-Format $Format `
-EnableLegend `
-OutputFolderPath $OutputFolderPath `
-Width 600 `
-Height 400 `
-ColorPalette Aurora `
-Filename 'Example15-RadarChart'
14 changes: 11 additions & 3 deletions Sources/DonutChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ public object Chart(double[] values, string[] labels, string filename = "output"
// Set label distance from the center of the donut slices
pie.SliceLabelDistance = _labelDistance;

if (DonutCenterText != null)
{
var annotation = myPlot.Add.Annotation(DonutCenterText);
annotation.Alignment = Alignment.MiddleCenter;
annotation.LabelStyle.FontSize = 12;
annotation.LabelStyle.BackgroundColor = Colors.White;
annotation.LabelStyle.BorderColor = Colors.White;
annotation.LabelShadowColor = Colors.Transparent;
}

// Apply watermark if enabled
ApplyWatermark(myPlot);

Expand All @@ -127,6 +137,4 @@ public object Chart(double[] values, string[] labels, string filename = "output"
}
}
}
}


}
10 changes: 9 additions & 1 deletion Sources/PowerShell/RadarChartPwsh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public class NewRadarChartCommand : Cmdlet
[Parameter(Mandatory = false, HelpMessage = "Switch to make label font bold.")]
public SwitchParameter LabelBold { get; set; }

// this set the distance of the labels from the chart center (Radar Chart)
[Parameter(Mandatory = false, HelpMessage = "Distance of labels from the chart center (0.5 to 0.9). Defaults to 0.6.")]
[ValidateSet("0.5", "0.6", "0.7", "0.8", "0.9")]
public double LabelDistance { get; set; } = 0.8;

// this set the distance of the labels from the chart center (Radar Chart)
[Parameter(Mandatory = false, HelpMessage = "Distance of labels from the chart center (10 to 50). Defaults to 10.")]
public double SpokesLength { get; set; } = 10;
Expand Down Expand Up @@ -221,9 +226,12 @@ protected override void ProcessRecord()
Chart.TitleFontColor = TitleFontColor;
}

// This set the distance of the labels from the chart center (Radar Chart)
// This set the distance of the spokes from the chart center (Radar Chart)
Chart.SpokesLength = SpokesLength;

// This set the distance of the labels from the chart center (Radar Chart)
Chart.LabelDistance = LabelDistance;

// Font Settings
Chart.FontName = FontName;
Chart.LabelFontSize = LabelFontSize;
Expand Down
1 change: 1 addition & 0 deletions Sources/RadarChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public object Chart(List<double[]> values, string[] labels, string[] categoryNam
radar.PolarAxis.Spokes[i].LabelStyle.ForeColor = GetDrawingColor(LabelFontColor);
radar.PolarAxis.Spokes[i].LabelStyle.Bold = LabelBold;
radar.PolarAxis.Spokes[i].LabelStyle.FontName = FontName;
radar.PolarAxis.Spokes[i].LabelPaddingFraction = LabelDistance;
}
}
else
Expand Down
Loading