02-11-2018 02:47 PM
Plotting on winform is quite simple but I am trying to move to wpf and encountering some issues. How can I plot XY graph with Graph control? In the example below, I just want to plot the signal vs t. I can find some example for plotting but none is for xy plot
int Fs = 1000;
double T = 1.000 / Fs;
int L = 2000;
double[] t = new double[2000];
double[] signal = new double[2000];
for (int i = 0; i < L; i++)
{
t[i] = i * T;
signal[i] = Math.Sin(2 * 3.14 * 50 * t[i]);
}
Graph1.DataSource = signal;
Solved! Go to Solution.
02-12-2018
10:46 AM
- last edited on
01-10-2025
03:12 PM
by
Content Cleaner
Hello rle 2,
Are you using Measurement Studio? Have you seen the documentation on graphing using WPF?
Customizing Measurement Studio WPF Controls for a Unique User Interface
02-12-2018
11:37 AM
- last edited on
01-10-2025
03:12 PM
by
Content Cleaner
To plot XY data, you just need to provide the graph with a type that includes both X and Y values, such as a Point[] (or possibly a ChartCollection <double,double>😞
...
Point[] points= new Point[2000]; for (int i = 0; i < L; i++) { points[i].X = i * T; points[i].Y = Math.Sin( 2 * 3.14 * 50 * points[i].X ); }
Graph1.DataSource = points;
You may also want to look at the "XYPlotting" example that comes installed with Measurement Studio.