Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Multiple Datatypes

Hi,

 

I have made a graph and I want to plot multiple different types of data. Right now, i have a custom point class, let's call it CustomClass and I am converting everything to the CustomClass before it is plotted, but it would be faster to directly plot some data.

 

ie, I am given some data:

double[] firstPlot;

double[] secondPlot;

List<CustomClass> thirdPlot;

 

Right now, I loop through firstPlot and secondPlot and convert each of them into a List<CustomClass>. (I also want to add an arbitrary amount of double[] arrays) Then I eventually plot List<List<CustomClass>> by binding it to the datasource. (This part is working but the looping takes too long)

 

Is there some sort of collection where I can place multiple different types of data and plot that? 

 

Thanks,

Kelly

0 Kudos
Message 1 of 6
(2,803 Views)

The DataSource property is used to populate the Data collection on a graph (similar to how the ItemsSource property populates the Items collection on an ItemsControl).

 

So the simplest way to populate Data with multiple separate data types is to directly change the Data collection (rather than trying to match all the types to make something convenient for DataSource to split up).

~ Paul H
Message 2 of 6
(2,788 Views)

Hi Paul,

 

How would you populate Data and what would I want to populate it with? I am using a WritableGraph and it looks like Data has a get method but no set.

 

Thanks,

Kelly

0 Kudos
Message 3 of 6
(2,778 Views)

Data is a collection, so you can use standard collection members like the Add method or the indexer to assign values in code:

 

graph.Data[0] = new double[...];
graph.Data.Add( new List<CustomClass>(...) );

 

~ Paul H
Message 4 of 6
(2,774 Views)

This appears to be working the first time that I am plotting the graph, but if I change some points in one of the DataCollections and I reassign say graph.Data[0] = someListOfPoints, the entire plot is not showing up. Also, calling refresh() on the graph doesn't help either. How do I make the new DataCollection appear on the graph?

 

Thanks,

Kelly

0 Kudos
Message 5 of 6
(2,592 Views)

I was not able to reproduce the issue based on your description. In my test, using just a graph and a button, this code always updated the graph:

private void OnChangeButtonClicked( object sender, RoutedEventArgs e ) {
    int[] array = (int[])graph.Data[0];
    if( array == null ) {
// Initial assignment. graph.Data[0] = new[] { 1, 3, 2, 4 }; } else {
// Modify existing data. Array.Reverse( array );

// Notify graph of change (since array does not have its own change event). graph.Refresh( ); } }

In addition to the data, you may want to verify that the associated plot and renderer are visible.

 

If you could create a simple test application that reproduces the issue, it would be easier to diagnose what is going wrong.

~ Paul H
0 Kudos
Message 6 of 6
(2,589 Views)