11-19-2012 06:43 AM
How do I insert or move plot to be the first?
graph.Plots.Insert(0, _newPlot) throws exception regarding incorrect index
graph.Plots.Add( _newPlot ) appends a plot, so it's the last one
_newPlot.Index is read-only
11-19-2012 04:27 PM
Hi eugenem,
Can you confirm if you are using any BarPlotRenderers or AreaPlotRenderers in the plots in front of which you are inserting your new plot? I have been able to recreate this issue with those conditions and will file an appropriate report.
As a workaround, if you need to insert on the fly, do not use those PlotRenderers.
11-20-2012 02:01 AM
nope, I use LineRenderer, PointRenderer, or both (as a group)
11-20-2012 09:54 AM
Hmm, I am unable to recreate it with those situations.
Could you post some of your XAML related to the renderers? Or anything else you think is relevant to the renderers.
11-22-2012 04:44 AM - edited 11-22-2012 04:51 AM
I build them from code, but there are some details:
_newPlot.Renderer
{PlotRendererGroup}
[NationalInstruments.Controls.Rendering.PlotRendererGroup]: {PlotRendererGroup}
base {System.Windows.Freezable}: {PlotRendererGroup}
SupportedRenderModes: Raster | Vector
(_newPlot.Renderer as PlotRendererGroup).PlotRenderers
{PlotRendererCollection: Count=2}
[0]: {LinePlotRenderer}
[1]: {PointPlotRenderer}
at then I do:
graph.Plots.Insert(0, _newPlot);
and get exception:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
even like this it fails:
_newPlot = new Plot();
_newPlot.Renderer = new LinePlotRenderer() { Stroke = Brushes.White };
graph.Plots.Insert(0, _newPlot);
11-26-2012 05:30 PM
Does the error message provide any additional information? Can you provide a screenshot? Since that the error is referring to the index of a collection, I would try using the plot collection instead of plot class.
11-27-2012 04:07 PM
It looks like this is an issue with how the graph handles changing renderers associated with plots.
To workaround this, I would try adding a call to graph.Refresh(); after inserting the new plot, which should force the graph to update all plots immediately.
11-28-2012 02:24 AM
Hi, Paul!
But it crashes the moment I insert plot. I won't be able to call Refresh...
Anyway, Plots.Add does work, but I'd like to control order of the plots as well.
11-28-2012 01:35 PM
Sorry that didn’t help (as Jeff mentioned, we are having trouble reproducing your original error, so this may be due to additional state configured on the graph, like render mode or data).
From your code snippet, it looks like you are only setting the Renderer property on the new plot. If so, another workaround would be to insert the renderer into the graph’s DefaultPlotRenderers collection, rather than changing the Plots collection.
If you do need to configure other plot members, the only other workaround I can think of for the currrent Measurement Studio release would be to use Add as you suggested, and assign the renderer to graph.Plots[insertIndex] instead of to _newPlot (and update the properties of all plots after the insert index).
04-05-2013 12:49 PM
Just wanted to let you know this issue was fixed in the Measurement Studio 2013 release.