02-24-2015 12:00 PM
I am evaluating MS2013 in VS2012. I have a long history with MS and Visual C++. My goal is charting frequency vs voltage data from two dac channels. I collect data at a particular frequency for two channels, process the data, and then chart the two resulting xy points. As noted in earlier posts i found examples of binding a single xy data set via an array of points bound with .DataSource but not a means for binding to multiple plots. I tried without success to find a ChartCollection that would handle a double as index and two y double values.
Stated a different way I would like to bind two XY chart plots in a single wpf NI:Graph to a data source I can fill over time and have the graph chart the entire time period.
My apologies if i have missed a piece of documentation that addesses this requirement.
Solved! Go to Solution.
02-25-2015 07:53 AM
I got close to what I had in mind by using an observableCollection of Point arrays as a data source.
02-25-2015 10:05 AM
Unfortunately, we do not have any pre-defined data types that will chart multiple Y values against a single X value. Using an ObservableCollection<Point[]>
is a valid approach.
If you are charting (X values are always increasing), then you could use an array of ChartCollection<double,double>
instead, and mimic a multi-value chart using an extension method:
public static class ChartExtensions {
public static void Append( this ChartCollection<double, double>[] charts, double x, params double[] ys ) {
for( int i = 0; i < ys.Length; ++i ) {
double y = ys[i];
var chart = charts[i];
chart.Append( x, y );
}
}
}
02-25-2015 02:10 PM
Looks good to me. Thx.
Solved.