Product: PowerShell Universal
Version: 3.9.13
Hello all,
I’ve created a line chart using New-UDNivoChart
, and I’m wondering if there are any additional adjustments or decorations I can apply to enhance its readability. While I’ve primarily been using New-UDNivoChart
, I’m also open to exploring other UD visualizations if you have suggestions.
My current code is as follows:
# Define a list of colors
$colors = @(
"hsl(272, 70%, 50%)", "hsl(244, 70%, 50%)", "hsl(94, 70%, 50%)",
"hsl(170, 70%, 50%)", "hsl(130, 70%, 50%)", "hsl(290, 70%, 50%)",
"hsl(0, 70%, 50%)", "hsl(18, 70%, 50%)", "hsl(36, 70%, 50%)",
"hsl(54, 70%, 50%)", "hsl(72, 70%, 50%)", "hsl(90, 70%, 50%)",
"hsl(108, 70%, 50%)", "hsl(126, 70%, 50%)", "hsl(144, 70%, 50%)",
"hsl(162, 70%, 50%)", "hsl(180, 70%, 50%)", "hsl(198, 70%, 50%)",
"hsl(216, 70%, 50%)", "hsl(234, 70%, 50%)", "hsl(252, 70%, 50%)",
"hsl(270, 70%, 50%)", "hsl(288, 70%, 50%)", "hsl(306, 70%, 50%)",
"hsl(324, 70%, 50%)", "hsl(342, 70%, 50%)"
)
# Query the database to get all mismatched data
$Query = "SELECT * FROM mismatched ORDER BY [date]"
$param = @{
Connection = $connection
Query = $Query
ErrorAction = 'Stop'
}
try {
$data = Read-GacAFdb @param
}
catch {
Show-UDToast ('ERROR: {0}' -f $_.Exception.Message) -Duration 10000
}
# Build the chart data dynamically
$colorIndex = 0
$chartData = @()
foreach ($column in $data[0].PSObject.Properties) {
$excludedColumns = @("date", "IsNull", "Value", "RowError", "RowState", "Table", "ItemArray", "HasErrors")
if ($excludedColumns -notcontains $column.Name -and $column.MemberType -eq 'Property') {
$dataPoints = @() # Initialize an empty array
$data | ForEach-Object {
$value = $_.($column.Name)
if ($null -eq $value -or $value -eq "Null") {
$intValue = 0
}
else {
try {
$intValue = [int]$value
}
catch {
$intValue = 0
}
}
$dataPoints += @{
"x" = $_.date.ToString()
"y" = $intValue
}
}
$chartDataItem = @{
"id" = $column.Name
"color" = $colors[$colorIndex]
"data" = $dataPoints
}
$chartData += $chartDataItem
# Move to the next color
$colorIndex++
if ($colorIndex -ge $colors.Length) { $colorIndex = 0 } # Wrap around if we run out of colors
}
}
# Create a single line chart
New-UDNivoChart -Responsive -Id 'lineChart' -Line -Data $chartData -Height 400 -Width 600 -MarginBottom 50 -MarginTop 50 -MarginRight 110 -MarginLeft 60 -OnClick {
Show-UDToast -Message $EventData -Duration 3000
}
I’ve attached a visualization of the current chart below. As you can see, there hasn’t been significant movement in the data, making it challenging to determine what each line represents. I did consider creating multiple line charts to distinguish the data, but I’d love to hear any other ideas or recommendations you might have.
@adam any ideas here?
Thank you in advance for your suggestions!