New-ConsoleChartView
Makes a line chart explorable inside Show-ConsoleApp.
Syntax
New-ConsoleChartView
-Chart <Object>
[-Disabled]
[-Height <Int32>]
[-Key] <String>
[[-Label] <String>]
[-Labels <String[]>]
[-OnChange <ScriptBlock>]
[-SelectionKey <String>]
[-TabIndex <Int32>]
[-ValidationMessage <String>]
[<CommonParameters>]#All Parameter SetsDescription
Left/Right or a click moves a crosshair along X, and the row above the plot reads every shown series at that point; the app footer repeats it for screen readers. A number key or a click on a legend entry hides or shows a series. + and - or the wheel zoom along X, Shift+Left/Right or a drag pans, and Home shows everything. The state holds the index of the point under the crosshair. Give New-ConsoleDataGrid the same -SelectionKey to link a table: selecting a row moves the crosshair and moving the crosshair selects the row. -Chart takes a Line or Scatter chart from New-ConsoleChart, or a ChartForgeX line chart, whose zoom uses ChartForgeX's prepared X levels.
Examples
Example 1
$samples = 1..30 | ForEach-Object { [pscustomobject]@{ Minute = $_; Cpu = 40 + (Get-Random -Maximum 50); Memory = 50 + $_ } }
$chart = New-ConsoleChart -Type Line -Unit '%' -Series @(
@{ Key = 'cpu'; Values = $samples.Cpu }, @{ Key = 'memory'; Values = $samples.Memory })
Show-ConsoleApp -Content {
New-ConsoleChartView -Key Load -Chart $chart -Labels $samples.Minute -SelectionKey Minute
New-ConsoleDataGrid -Key Samples -InputObject $samples -Property Minute, Cpu, Memory -Height 8 -SelectionKey Minute
}Explore CPU and memory samples next to the table they came from
Parameters
- -Chart Object
- A Line or Scatter chart from New-ConsoleChart, a ChartForgeX line chart with numeric X, or a ChartPlot.
- -Disabled SwitchParameter
- Disables editing and removes the input from keyboard focus traversal.
- -Height Int32
- Rows for the readout and the plot, legend included.
- -Key String
- Unique key in the application's state and final hashtable.
- -Label String
- Visible label; defaults to the name using the core control's labels.
- -Labels String[]
- Labels for the points along X, such as times, read out with their values.
- -OnChange ScriptBlock
- Runs once per committed edit on the owning input thread. Receives param($Value, $State) and injected $Value, $State and $Control. State is a hashtable; add or assign keys to write back. Output is discarded. Retains closure variables.
- -SelectionKey String
- The state key shared with linked controls (New-ConsoleDataGrid, New-ConsoleSelect, another chart): the index of the point under the crosshair. A position it cannot show is ignored.
- -TabIndex Int32
- Keyboard focus order. Equal values preserve layout declaration order.
- -ValidationMessage String
- Initial validation text displayed below the input.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.