02-15-2016 07:51 AM
Hi,
I use WPF graph from MS2015, I want to allow selection of horizontal range (without zoom) so that the user can see the selected range.
1. How I allow to select horizontal range in the graph?
2. The graph Data is ChartCollectionAnalogWaveform<double> , how can I access the data of the selected range only (I want to show statistics of this data) ?
Solved! Go to Solution.
02-15-2016 12:53 PM
What you describe sounds like a perfect fit for the RangeCursor
. For example:
XAML
<ni:Graph x:Name="graph" ...>
<ni:Graph.Children>
<ni:RangeCursor x:Name="rangeCursor"/>
</ni:Graph.Children>
</ni:Graph>
Code
foreach( IPlot plot in graph.AllPlots ) {
var values = rangeCursor.RetrieveValues( plot );
using( var xValues = values[0] )
using( var yValues = (Buffer<double>)values[1] ) {
double average = yValues.Average( );
string example = string.Format( "Plot {0} average over [{1:0}]: {2:0.##}", plot.Index, rangeCursor.ActualHorizontalRange, average );
// ...
}
}
02-17-2016 03:01 AM
That was easy!
Thanks, it works for me.