Need up with UDChart


I am trying to create more of a dynamic chart. My data is as follows:


The version is always changing as new versions are released. I have been testing with the following:

New-UDChart -FontColor "Black" -Title "Historical iOS Version History" -Type Line -AutoRefresh -RefreshInterval 100  -Endpoint { Import-csv C:\Dashboard\Versions\DailyOSversions.csv | Select "Name","Count","Date" | Out-UDChartData -DataProperty "Name" -LabelProperty Date -BackgroundColor '#FF530D' -BorderColor 'black' -HoverBackgroundColor '#FF9F0D' -Dataset @(
                New-UdlineChartDataset -DataProperty "Count" -Label "Count" -bordercolor "#4286f4" -BorderWidth 3 -Fill $false

Ideally what I am trying to get is something like this:

But what I am getting is this:

Any ideas?

I’ve literally just done one of these. You’ll need to create a pscustomobject for each date with values for version and count.
From UD docs: Get-Process | ForEach-Object { [PSCustomObject]@{ Name = _.Name; Threads = _.Threads.Count } }
I’ll try to find another example.


I can’t see anything in the forums that really matches your plan of a multi line date driven chart.

What I do is get my data from sql and plug it into the ArgumentList of new-udchart. It looks exactly the same as yours date,version,count.
Then I pull out all the unique dates:
$dates = $argumentList[0].Date | Select-Object -Unique
For each date filter the data:
ForEach ($date in $dates) { $rowData = $argumentList[0] | Where-Object{$_.Date -eq $date}
This gives me several rows of date,version,count for that specific date.
I create a PSCustomObject with the date value:
$psco = [pscustomobject]@{Date = $date.ToShortDateString()}
then loop through the rows
ForEach ($i in 0..($rowData.count-1)){
adding the count for each version
$version= ($rowData[($i)].Version); $psco.add($version,$rowData[($i)].count) }
Add the PSCustomObject to an array for charting:
$chartData += $psco }

To keep it flexible and portable I dynamically build the UdChartDatasets. This way I don’t need to know the versions and I can copy/paste the code for other similar datasets.

$versions= $argumentList.Version | Select-Object -Unique
$command = "`$chartData | Out-UDChartData -LabelProperty `"Date`" -Dataset @("
ForEach ($version in $versions) {
$command += "`r`nNew-UdChartDataset -DataProperty `"$version`" -Label `"$version`""}
$command += "`r`n)"
Invoke-Expression $command

I never said it was pretty, or necessarily efficient, but it’s easy to follow should I get hit by a bus and someone else needs to support it! If your dataset is very large, I’m sure a PS pro could improve it no end, but it works for me.


1 Like