Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

binding data in single xpf graph for multiple xy chart plots

Solved!
Go to solution

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.

0 Kudos
Message 1 of 4
(4,906 Views)

I got close to what I had in mind by using an observableCollection of Point arrays as a data source.

 

0 Kudos
Message 2 of 4
(4,873 Views)
Solution
Accepted by topic author joemg

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 );
            }
        }

    }

~ Paul H
0 Kudos
Message 3 of 4
(4,866 Views)

Looks good to me.  Thx.

 

Solved.

0 Kudos
Message 4 of 4
(4,860 Views)