08-07-2015 12:00 PM
I believe either Data
or DataSource
could work for your situation. DataSource
is used more frequently, but modifying the Data
collection gives you more direct control over the association between plots and data.
From the problem description, it sounds like there is either an issue when the Plots
collection is cleared, or a layout issue that is preventing the scales from re-displaying. However, without more information, it is hard to speculate what the actual root cause is.
To help you resolve this issue, ideally we would want to work with a small application that reproduces the problem. Absent that, any information you can provide on how the graph is configured (properties, axes), other controls bound to the graph (legend, tool palette), the layout of the graph in the user control (grid, canvas), and the layout of the user control in the application would be helpful. So far, we have not been able to reproduce the behavior you are seeing on our own.
Regarding a workaround, if the problem is related to layout you may want to try calling InvalidateMeasure
in addition to InvalidateVisual
. If the problem is related to the changes to Plots
, here are some different modifications you could try:
try
/catch
around where you clear Data
and Plots
. If there is an exception being thrown, it may be that the scales are never informed of the new state to redraw. Please report if any exception is actually being thrown.HorizontalScale
and VerticalScale
of the plots you create.Clear
on the Plots
collection, just update the Label
property of the corresponding plot, if one already exists. Plots without data will not be displayed, so they can be left in the collection.08-07-2015 01:03 PM - edited 08-07-2015 01:06 PM
Hi Paul,
Thank you for your response. You understand my problem exactly, the Data property gives me more control that I can't get with the DataSource property and is available probably for that reason.
Please find attached a project that reproduce the issue. I think the issue may have something to do with hosting the graphs in a tab controller. The data in the graph should produce plots with peaks at 0.1 and 10. These data are switched over between the two plots on clicking the Switch plot menuitem.
To reproduce the issue, please click on "Switch plot" and check the two tab items after each time you click on switch plot. You will notice that after second on third click, the plot in the inactive window becomes inconsistent. The tooltip still displays the right value and resizing the window will immediately adjust the axis labels correctly.
Calling InvalidateMeasure and InvalidateVisual does not solve the issue. I hope this reproduce the issue on your laptop. Thank you.
08-07-2015 02:37 PM
Thank you for the example application! It appears the tab control is causing the problem: when the graph is not visible, the scales avoid performing an unnecessary layout pass. When switching tabs and the graph becomes visible, the scales end up displaying stale information.
As a workaround, you can trigger a manual refresh of the scales by adding the following to a handler for the Loaded
event on your user control:
private void UserControl_Loaded( object sender, RoutedEventArgs e ) {
foreach( NationalInstruments.Controls.Primitives.IScale axis in niGraph.Axes )
axis.OnInvalidated( new PropertyChangedEventArgs( "Tab Loaded" ) );
}
08-07-2015 04:30 PM
Hi Paul,
Thanks for the fast feedback as usual. This solves the issue. You guys need to hire me for your bug . Thanks.
07-08-2019 04:18 PM
Just wanted to let you know this issue was fixed in the Measurement Studio 2019 release.