Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Plots Collections

I'm having a problem ploting multiple plots on a single waveformGraph. I have a class(GraphData) that contains an array of the data that I want to plot. In my main program there is a ArrayList of GraphData. How do I a plot each object in the ArrayList? I've looked at the waveformPlotCollection documentation, but can't seem to figure out how to use it. Thanks

JMD
0 Kudos
Message 1 of 2
(3,368 Views)
One way that you could do it would be to make sure that there's as many plots in the graph as there are items in your ArrayList, then loop through the ArrayList and plot the data. For this example, I will assume that your ArrayList is called list and the GraphData class has a GetData() method that returns an array of doubles that can be plotted:

// First make sure that the graph has enough plots for the data.
if (list.Count > graph.Plots.Count)
{
int plotsToAdd = list.Count - graph.Plots.Count;
for (int i = 0; i < plotsToAdd; ++i)
graph.Plots.Add(new WaveformPlot());
}

// Now loop through the list and plot the data one item at a time.
for (int i = 0; i < list.Count; ++i)
{
GraphData item = list[i] as GraphData;

if (item != null)
{
double[] data = item.GetData();
graph.Plots[i].PlotY(data);
}
}

If all of your data in the ArrayList is the same size, another option would be to create a two-dimensional double array, populate it from your list, then pass the two-dimensional array to PlotYMultiple. The first option above is probably easier, though.

- Elton
0 Kudos
Message 2 of 2
(3,368 Views)