Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

plot layer order

When I add multple graph in ni graph, the first graph is plotted at the bottom, and the last graph added is plotted on top. Is it possible to have nigraph  reverse this plot order so the last graph added is below all other graphs? Said in another way,I want the first graph in the legend to be the graph that is on top of all other graphs, right now ni will take the first graph in the legend and plot that on the bottom which is not ideal right now thank you

0 Kudos
Message 1 of 3
(2,068 Views)

How are you plotting the graphs? i.e. what type of graph, what language, and what function are you using? There is probably a parameter we can edit.

 

Here's the full help documentation on Windows forms graph .NET controls. Take a look and see if this offers any insight!

Using the Measurement Studio Windows Forms Graph .NET Controls

Francine P.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 3
(2,038 Views)

The simplest approach to re-ordering collection items in WPF is to use the collection view for that collection.

 

To make it easier to initialize the Legend, you could use a converter that sorts the incoming collection of plots by Index:

public sealed class ReverseListConverter : IValueConverter {

    public static readonly ReverseListConverter Instance = new ReverseListConverter();

    public object Convert( object value, Type targetType, object parameter, CultureInfo culture ) {
        var view = CollectionViewSource.GetDefaultView( value );
view.SortDescriptions.Clear( ); view.SortDescriptions.Add( new SortDescription( "Index", ListSortDirection.Descending ) ); return view; } public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture ) { var view = (ICollectionView)value; return view.SourceCollection; } }

 

Then you can use the converter in the binding for the legend items:

<ni:Legend ItemsSource="{Binding ElementName=graph, Path=AllPlots, Converter={x:Static local:ReverseListConverter.Instance}}"/>
~ Paul H
Message 3 of 3
(2,036 Views)