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.
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.