From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-22-2016 04:02 AM
How to use several plot append data simultaneously?
For example, there are 18 plots for Graph. The datasouce of Graph is ChartCollection<Point>[18] graphds
It must execute 18 times of APPEND to update the whole Graph.
Code:
Aps[0-17]=graphds[0-17].append
Dispatcher.BeginInvoke(aps, simulatedData),//executing 18 times
I hope there is a similar data to
graphds.append(Point[18] datasources)
that can refresh 18 plot data at one time.
full code in testmultiplot.zip
thank you
Solved! Go to Solution.
09-22-2016 11:22 AM
There is nothing special about the delegate created from graphds[i].Append
in your code. The WPF dispatcher can accept any delegate. For example, here is a helper delegate for appending to multiple charts:
Action<ChartCollection<Point>[], IList<Point>[]> AppendAll = ( charts, points ) => {
for( int i = 0; i < charts.Length; ++i ) {
charts[i].Append( points[i] );
}
};
In your DataWorkerThread
method, you can replace the existing aps
collection with a var points = new IList<Point>[graphds.Length];
collection, and call the delegate like so:
while( true ) {
for( int f = 0; f < graphds.Length; f++ ) {
IList<Point> simulatedData = new List<Point>( );
// ...
for( int i = 0; i < cyclecountper; i++, x++ ) {
// ...
}
// Save the simulated data for the current chart.
points[f] = simulatedData;
//...
}
// Dispatch all the work with a single call at the end.
this.Dispatcher.BeginInvoke( AppendAll, graphds, points );
//...
}
09-24-2016 09:21 PM
Thank you but
I hope DATASOURCE is ChartCollection<CustomClass> ps, not ChartCollection<Point> [] ps .datasource not array
09-26-2016 12:41 PM
The specific item types involved are not importent. The idea of the AppendAll
helper function is just to have a single method to perform all of the append work, rather than invoking for each separate append. You could also define the helper generically and use any data type for the items:
private static void AppendAll<T>( ChartCollection<T>[] charts, IList<T>[] values ) {
for( int i = 0; i < charts.Length; ++i ) {
charts[i].Append( values[i] );
}
}