Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

YAxis range error with multiYAxis

Hi,
I use a graph where I can show several plots with several YAxis.

 

When I show one or multiplots with only one YAxis, I can modify with success the YAxis range.

But, if I show several plots with two or more Yaxis, my application crashes on "InvalidOperationException : Cannot draw outside of a draw cycle".

 

Thanks for any help.

O. Daniere.

0 Kudos
Message 1 of 5
(5,631 Views)

Unfortunately, I could not reproduce the issue from your description. I have included the code I used below. If you could, please provide a program that reproduces the problem, or include the call stack from the exception you are seeing. You may also want to look at this earlier question that had the same issue with a different setup.


    XAML
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ni:Graph x:Name="graph" />

        <ToggleButton Grid.Row="1" Content="_Data" IsChecked="True" Click="OnDataButtonClicked" />
    </Grid>

    Code
    public partial class MainWindow : Window {
        private const int PlotCount = 3;
        private readonly Random random = new Random( );
        private readonly DispatcherTimer timer;

        public MainWindow( ) {
            InitializeComponent( );

            for( int i = 0; i < PlotCount; ++i ) {
                int n = i + 1;
                var axis = new Axis<double>( "Y" + n, Orientation.Vertical );
                var plot = new Plot( "P" + n ) { VerticalScale = axis };
                graph.Axes.Add( axis );
                graph.Plots.Add( plot );
            }

            timer = new DispatcherTimer( TimeSpan.FromSeconds( 0.1 ), DispatcherPriority.Normal, this.OnTimerTick, this.Dispatcher );
        }

        private void OnTimerTick( object sender, EventArgs e ) {
            graph.DataSource = Enumerable.Range( 0, PlotCount ).Select( i =>
                Enumerable.Repeat( random, 11 ).Select( r => i + r.NextDouble( ) ).ToArray( ) )
            .ToArray( );
        }

        private void OnDataButtonClicked( object sender, RoutedEventArgs e ) {
            timer.IsEnabled = !timer.IsEnabled;
        }
    }

~ Paul H
0 Kudos
Message 2 of 5
(5,612 Views)

Hi Paul,

Here is the stacktrace :

{NationalInstruments.Restricted.Guard`1[T] Satisfies(Boolean, System.Func`4[System.Object,System.String,System.String,System.Exception], System.String, System.Object[])}

 

I put also the screenshot:

Error WPF NI.jpg

 

I don't know if this can help you!

 

O. Daniere

 

 

0 Kudos
Message 3 of 5
(5,607 Views)

That looks like the first line from the stack trace, but we would need to see the full contents for it to be helpful. In the dialog in your screenshot where you have highlighted the StackTrace member, you can click the down triangle to the right and copy the full text.

~ Paul H
0 Kudos
Message 4 of 5
(5,603 Views)

Unfortunately, this is the complete StackTrace :

{NationalInstruments.Restricted.Guard`1[T] Satisfies(Boolean, System.Func`4[System.Object,System.String,System.String,System.Exception], System.String, System.Object[])}

 

But, it seems to me that I didn't have this problem before recent changes. I'll cancel my latest changes and come back to you with more informations.

 

O. Daniere

0 Kudos
Message 5 of 5
(5,587 Views)