У меня небольшая проблема. Я пытаюсь добиться чего-то вроде этого: http://www.codeproject.com/Articles/168056/Windows-Charting-Application Первая диаграмма на странице. У меня есть мой код здесь
### Load assemblies
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
$Servers = Get-XAWorkerGroup -WorkerGroupName Agresso | select servernames -ExpandProperty servernames
$SessionTable = @()
foreach ($Server in $Servers) {
$ActiveSessions = (Get-XASession -ServerName $Server | ?{$_.State -eq "Active"}).Count
$DisconnectedSessions = (Get-XASession -ServerName $Server | ?{$_.State -eq "Disconnected"}).Count
$ListeningSessions = (Get-XASession -ServerName $Server | ?{$_.State -eq "Listening"}).Count
$LoopArray = "$Server,$ActiveSessions,$DisconnectedSessions,$ListeningSessions"
$SessionTable += $LoopArray
}
### CREATE CHART
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$Chart.Width = 1600
$Chart.Height = 400
$Chart.Left = 10
$Chart.Top = 10
# create a chartarea to draw on and add to chart
$ChartArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
$Chart.ChartAreas.Add($ChartArea)
foreach ($server in $SessionTable) {
$Splitted = $Server.Split(",")
$Name = $Splitted[0]
$Active = $Splitted[1]
$Disconnected = $Splitted[2]
$Listening = $Splitted[3]
[void]$Chart.Series.Add($Name)
$dp1 = new-object System.Windows.Forms.DataVisualization.Charting.DataPoint(0,$Active)
$dp2 = New-Object System.Windows.Forms.DataVisualization.Charting.DataPoint(0,$Disconnected)
$dp3 = New-Object System.Windows.Forms.DataVisualization.Charting.DataPoint(0,$Listening)
$dp1.Color = "Blue"
$dp2.Color = "Red"
$dp3.Color = "Orange"
$dp1.AxisLabel = $Name + " Active"
$dp2.AxisLabel = $Name + " Disconnected"
$dp3.AxisLabel = $Name + " Listening"
$Chart.Series[$Name].Points.Add($dp1)
$Chart.Series[$Name].Points.Add($dp2)
$Chart.Series[$Name].Points.Add($dp3)
$ChartArea.AxisX.LabelStyle.Angle = "-90"
$ChartArea.AxisX.LabelStyle.Interval = "1"
}
$title = new-object System.Windows.Forms.DataVisualization.Charting.Title
$Chart.Titles.Add( $title )
$Chart.Titles[0].Text = "Testing"
$Chart.Titles[0].Font = New-Object System.Drawing.Font("arial",20,[System.Drawing.FontStyle]::Bold)
### Show on form
$Chart.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right -bor
[System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left
$Form = New-Object Windows.Forms.Form
$Form.Text = "Testing form"
$Form.Width = 1400
$Form.Height = 820
$Form.controls.add($Chart)
$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()
Но мой вывод выглядит так:
Я хочу, чтобы вывод был похож на тот, который я связал вверху, поэтому в моем случае: имя сервера с 3 комбинированными значениями для разных сеансов. Например, Server1 со значениями 6, 7, 0. Надеюсь, я четко понимаю, чего хочу достичь! :D