janhoedt
asked on
Powershell: create chart rds users via canvajs, $overview output not correct
Hi,
I'm trying to make a chart of number of rds users with https://canvasjs.com/
Example: https://canvasjs.com/javascript-charts/multi-series-chart/
I gather the info I need on an hourly basis in $tablerdssessions
which is of type System.Data.DataRow
Group NumberOfUsers Date
----- ------------- ----
TEAM01 57 29/01/2018 14:16:00
TEAM02 3 29/01/2018 14:16:00
TEAM03 9 29/01/2018 14:16:00
TEAM04 5 29/01/2018 14:16:00
TOTAL 74 29/01/2018 14:16:00
I then try to create an $Overview which holds Group and details.
Details are the x, y data needed for the graph.
foreach (group in $tablerds3Sessions){
#Selection of GroupName
$GroupName = ($tablerdssessions | Where-Object group -eq $($group.group)).group
#Selection of NumberofUsers and Date
$rds3groupsessions = $($tablerds3Sessions | Where-Object group -eq $group.group | select NumberOfUsers,Date)
foreach ($row in $rds3groupsessions)
{
#, to be removed in $DatapointRds3sessionsGrou p
$DatapointRds3sessionsGrou p += "{ x: new Date($($row.Date.Year),$($ row.Date.M onth),$($r ow.Date.Da y),$($row. Date.Hour) ,$($row.Da te.Minute) ), y: $($row.NumberOfUsers) },"
}
$Overview += [PSCustomObject] @{
GroupName = $GroupName
Details = $DatapointRds3sessionsGrou p
}
}
$overview should be
GroupName Details
--------- -------
TEAM01 { x: new Date(2018,1,29,14,00), y: 57 },{ x: new Date(2018,1,29,15,00), y: 57 }
TEAM02 { x: new Date(2018,1,29,14,00), y: 3 },{ x: new Date(2018,1,29,15,00), y: 2 }
TEAM03 { x: new Date(2018,1,29,14,00), y: 9 },{ x: new Date(2018,1,29,15,00), y: 6 }
TOTAL { x: new Date(2018,1,29,14,00), y: 69 },{ x: new Date(2018,1,29,15,00), y: 63 }
but is now (TEAM01, TEAM02 etc is added as extra row whereas it should just add details for TEAM01, TEAM02 etc
GroupName Details
--------- -------
TEAM01 {{ x: new Date(2018,1,29,14,00), y: 57 },}
TEAM02 {{ x: new Date(2018,1,29,14,00), y: 3 },}
TEAM03 {{ x: new Date(2018,1,29,14,00), y: 9 },}
TOTAL {{ x: new Date(2018,1,29,14,00), y: 69 },}
TEAM01 { {x: new Date(2018,1,29,15,00), y: 57 },}
TEAM02 {{ x: new Date(2018,1,29,15,00), y: 2 },}
Can you advise?
J.
I'm trying to make a chart of number of rds users with https://canvasjs.com/
Example: https://canvasjs.com/javascript-charts/multi-series-chart/
I gather the info I need on an hourly basis in $tablerdssessions
which is of type System.Data.DataRow
Group NumberOfUsers Date
----- ------------- ----
TEAM01 57 29/01/2018 14:16:00
TEAM02 3 29/01/2018 14:16:00
TEAM03 9 29/01/2018 14:16:00
TEAM04 5 29/01/2018 14:16:00
TOTAL 74 29/01/2018 14:16:00
I then try to create an $Overview which holds Group and details.
Details are the x, y data needed for the graph.
foreach (group in $tablerds3Sessions){
#Selection of GroupName
$GroupName = ($tablerdssessions | Where-Object group -eq $($group.group)).group
#Selection of NumberofUsers and Date
$rds3groupsessions = $($tablerds3Sessions | Where-Object group -eq $group.group | select NumberOfUsers,Date)
foreach ($row in $rds3groupsessions)
{
#, to be removed in $DatapointRds3sessionsGrou
$DatapointRds3sessionsGrou
}
$Overview += [PSCustomObject] @{
GroupName = $GroupName
Details = $DatapointRds3sessionsGrou
}
}
$overview should be
GroupName Details
--------- -------
TEAM01 { x: new Date(2018,1,29,14,00), y: 57 },{ x: new Date(2018,1,29,15,00), y: 57 }
TEAM02 { x: new Date(2018,1,29,14,00), y: 3 },{ x: new Date(2018,1,29,15,00), y: 2 }
TEAM03 { x: new Date(2018,1,29,14,00), y: 9 },{ x: new Date(2018,1,29,15,00), y: 6 }
TOTAL { x: new Date(2018,1,29,14,00), y: 69 },{ x: new Date(2018,1,29,15,00), y: 63 }
but is now (TEAM01, TEAM02 etc is added as extra row whereas it should just add details for TEAM01, TEAM02 etc
GroupName Details
--------- -------
TEAM01 {{ x: new Date(2018,1,29,14,00), y: 57 },}
TEAM02 {{ x: new Date(2018,1,29,14,00), y: 3 },}
TEAM03 {{ x: new Date(2018,1,29,14,00), y: 9 },}
TOTAL {{ x: new Date(2018,1,29,14,00), y: 69 },}
TEAM01 { {x: new Date(2018,1,29,15,00), y: 57 },}
TEAM02 {{ x: new Date(2018,1,29,15,00), y: 2 },}
Can you advise?
J.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER