ObjectDisposedException with ChartCollection a WPF chart

When I start the following program (WPF. net4.0, NI.common (13.0.40.190), OR.) Controls.Graph (13.0.40.242)) I get the following in the debugger error message

ObjectDisposedException was not handled

The data store has been modified.
Name of the object: ' Buffer'.

Source : NI.Common

I have a device class that generates some milli seconds of random data. I inform my main class through events and then pass the values via the parameter.

XAML I bind the data graphic to a ChartCollection as follows: (the bold lines are the most relevant)

The error occurs only when the time of my data provider crosses a certain threshold.

500 ms - all right

200ms - works ok, but hangs at the exception, when I change the size of the window

20 ms - always ok

10ms - crashes instantly with the exception

{

Data = new Data();

public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged (string propertyName)
{
var Manager = PropertyChanged;
If (Manager! = null) Manager (this, new PropertyChangedEventArgs;
}

Private ChartCollection _chartCollection1 = new ChartCollection(1000);

private ChartCollection = new ChartCollection_chartCollection2 (1000);
private ChartCollection = new ChartCollection_chartCollection3 (1000);
private ChartCollection = new ChartCollection_chartCollection4 (1000);

public ChartCollection Chart1
{
get {return _chartCollection1 ;}
set
{
If (_chartCollection1.Equals (value))
{
return;
}

_chartCollection1 = value;
OnPropertyChanged ("Chart1");
}
}

public ChartCollection Graph2
{
get {return _chartCollection2 ;}
set
{
If (_chartCollection2.Equals (value))
{
return;
}

_chartCollection2 = value;
OnPropertyChanged ("Graph2");
}
}
public ChartCollection Graph3
{
get {return _chartCollection3 ;}
set
{
If (_chartCollection3.Equals (value))
{
return;
}

_chartCollection3 = value;
OnPropertyChanged ("Graph3");
}
}
public ChartCollection Graph4
{
get {return _chartCollection4 ;}
set
{
If (_chartCollection4.Equals (value))
{
return;
}

_chartCollection4 = value;
OnPropertyChanged ("Graph4");
}
}

public Window1()
{
InitializeComponent();

GraphView graphView = new GraphView();
ContentControlGraph.Content = graphView;
ContentControlGraph.DataContext = this;

data.dataReadyEvent += dataEventHandler;
Closing += MainWindow_Closing;
}

Sub MainWindow_Closing (ByVal sender As Object, e CancelEventArgs)
{
data. Stop();
Environment.Exit (0);
}

' private void ButtonBase_OnClick (object sender, RoutedEventArgs e)
{
data. Start();
}

private int j;
' private void dataEventHandler (object sender, EventArgs e)
{
j ++ ;
If (j == 1)
{
Graph1.Append ((double[]) sender);
}
Else if (j == 2)
{
Graph2.Append ((double[]) sender);
}
Else if (j == 3)
{
Graph3.Append ((double[]) sender);
}
on the other
{
Graph4.Append ((double[]) sender);


j = 0;
}
}
}

The exception occurs in the DLL, so I can not catch it either.

I think that you run in the multi-threading problem described here: could not get Graph.DataSource to work in WPF, I (thread problem?).

In short, your chart add calls must be marshaled to the user interface thread.

Tags: NI Software

Similar Questions

  • Secondary axis on the WPF chart

    Hello

    I'm tracing a secondary value axis on my WPF chart. I have a graphic linked to a table of AnalogWaveform of objects that I change during execution. This table can be different sizes depending on the user's selection, however assume that there are two types of data to the chart.

    I would like to match a data type of my main axis and the other guy to my axis is secondary. For example, I have four AnalogWaveform opposes the plot, two of whom are in Hz (primary) and the other two in Volts (secondary).

    According to the documentation, I need an additional of element under my definition of . What I have is:

             

























    This adds a second value axis to the left of my main axis. What I need is for this axis which will be located to the right of my chart and somehow to draw each AnalogWaveform on the right y-axis.

    I build my locations in the code as follows:


    _graph. Plots.Clear ();

    RawData is my AnalogWaveform[], built in advance based on a response from the server
    foreach (AnalogWaveform waveform in RawData)
    {
    If (waveform! = null)
    {
    field = new plot (waveform. ChannelName);
    parcel of land. DataContext = waveform;

    plots. Add (Plot); plots is a simple list
    }
    }

    _graph. Plots.AddRange (studs); Add locations to graph

    _legend. ItemsSource = plots. Add locations to the legend

    Any help would be appreciated on how to do it.

    Thanks in advance.

    To position your second Y axis across the graph, set the Location property on the axis of Far .

    To associate a plot to a default axis, set the VerticalScale property on the ground in the axis value is appropriate.

  • Chart how many plots with wpf chart

    This is probably a very basic question, but I can't understand how the chart more than a set of data with the chart WPF in VS2010.  There is a DataSource property on the chart, but I don't see the same on each class of land.  I can't find any documentation on the source property of the chart data.  Can I pass an array of doubles and he plots very well but now I need to draw two sets of data.  Can anyone help?

    The DataSource property is documented in the how: map and graphic subject and on the GraphBase class (which is the type that defines the property). However, it seems that these issues do not directly address your question multiple plot; I put in a request to improve this.

    To answer your question, if you use DataSource to pass an array of double values in a plot, you can use a collection to pass data to multiple locations (for example a double[][] , a List , or a ObservableCollection ).

    Otherwise, you could use the Data collection to provide each parcel with data; for example:

    graph.Data[0] = /* double[] for plot 0 */;

        graph.Data[1] = /* double[] for plot 1 */;

    ~ Paul

  • Draw a line connecting two points in the WPF chart

    I'm trying to understand the best way to draw a line between two existing points on my graph in WPF.  At first, I thought I had it works fine; I just added another parcel to my graph then given exactly two points for rendering.  But I quickly noticed that the app has become surprisingly slow and CPU was quite high (adding other plots does not affect the use of the CPU as long as they have a complete set of points (?)).  He wants me if I looked at using the DataToScreen method on the chart but I can't know what the parameters are.  The second parameter is simply an IList that tells me a lot.  This seems to be the method I want to use for the coordinates of a point on the graph screen.

    No one knows what the second parameter is supposed to be for the DataToScreen method?  Everything I tried throws an Exception of Argument.

    Thank you
    Dan

    DataToScreenwill return a screen coordinate in the plot area of a chart of the value of the raw data horizontal and vertical in the given list. The parameter value is a IList for compatibility with other methods of graphical query such as FindNearestValue , return IList values containing raw data.

    A concrete example, say you had a graphical configuration with a wide horizontal axis ranging from 0 to 100 and a vertical axis double precision ranging from 10 to 20:


            
                
                
            
        

    To get the screen coordinates of the value at the center of the two axes, you can call:

    graph.DataToScreen(plot, new object[] { 50, 15.0 })

    Note that the raw data values corresponding to the type of axes (horizontal AxisInt32 returns the integer 50 and vertical AxisDouble Gets the value 15.0 ).

    You also mentioned a performance issue where "adding other plots does not affect the CPU so that they have a complete set of points". I did a simple test app that adds an array of two points of a chart on each key (for example graph.Data.Add(new[] { new Point(x1, y1), new Point(x2, y2) }); ), but could not reproduce the problem you saw. Could you share the code, you use to draw the connection line?

  • Plots of non-visible WPF chart

    I am using measurement graphic studio in my WPF application. Firstly to my chart, the plots on it becomes sometimes invisible, but the graph becomes visible if I click on the limits of the axis or change the title of the axis. It happen with one is not specific in my request, and I'm not sure why it's happening. I will be grateful if someone could help with this.

    Thank you.


  • Can build, but can not run a simple WPF chart

    Hello

    I just got my NI Measurnments Studio package and I try to add a graphic to my WPF c# application but I have questions that I have not seen in the examples of the trial.  Before you buy this package, I changed one of the examples of the trial to draw my own data and it worked beautifuly.  Now I tried to do the same thing in my own project and it builds without error but I get InitializeComponent() exception when I try to run it:

    "The call of the constructor on type"NationalInstruments.Controls.Graph"that matches the constraints of binding specified threw an exception."

    That's what I have:

    • Added to my project references (VS 2013)

    C:\Program Files (x 86) \National Instruments\MeasurementStudioVS2012\DotNET\Assemblies\Current\NationalInstruments.Common.dll

    C:\Program Files (x 86) \National Instruments\MeasurementStudioVS2012\DotNET\Assemblies\Current\NationalInstruments.Controls.dll

    C:\Program Files (x 86) \National Instruments\MeasurementStudioVS2012\DotNET\Assemblies\Current\NationalInstruments.Controls.Graphs.dll

    • Added to this, notably in XAML

    "" xmlns: or = 'http://schemas.ni.com/controls/2009/xaml/presentation '

    • And added this chart control to XAML



    <>area of Label = "Channel 1" x: Name = "Plot1" / >
    <>area of Label = "Channel 2" x: Name = "Plot2" / >


    Nothing else behind it, so I should at least power run and see a graph empty, right?

    Please advice.

    Thank you!

    I got it work.  Basically, it was licening known issue in 2013 VS.  I had the .licx added manually in my project file.  Here is the email that I received or who has been very useful:

    "I noticed that you use Visual Studio with Measurement Studio 2013 2013. Currently measure Studio 2013 is only officially supported by Visual Studio 2012, however, many of our clients were able to make it work with Visual Studio 2013 Measurement Studio 2013. We have an article for the knowledge base that walks by working with Measurement Studio 2013 in Visual Studio 2013. It might be good to make sure you followed every step through this article: http://digital.ni.com/public.nsf/allkb/C51E3B38578FAD2786257C070069F386

    It looks like you are using the correct assemblies, and we were able to test the XAML for our side. It works beautifully, so it doesn't seem like there's something is happening with the code. Another thing, we can try is to clean the Solution and regenerate the Solution in Measurement Studio. It will be a good step to make sure that no old persistent files. »

    Thank you

  • WPF CHART DATASOUCE CUSTOM STRUCT POINT

    Graph DataSource in the Group ChartCollection

    Graph.Plot = PointPlotRenderer

    execution error:

    Could not find item type conversion to type Double.

    public struct item: IFormattable
    {

    Public item (double x, double y)
    {
    X = x;
    Y = y;
    }

    public double X {get; set ;}}

    public double Y {get; set ;}}

    public string ToString (string format, IFormatProvider formatProvider)
    {
    throw new NotImplementedException();
    Returns the string. Format ("{0}, {1}", X, Y);
    }
    }

    To use a custom with the graphic data type, you must also implement a descriptor so that the graph knows how to access your data. I have attached a descriptor to another question, translated into c# for your type of data.

    To use the descriptor, add a DataTypeDescriptor attribute to your custom type:

    [DataTypeDescriptor( typeof( PointIDescriptor ) )]

        public struct PointI : IFormattable {

            // ...

        }

  • WPF chart - select a horizontal range

    Hello

    I use the chart WPF of MS2015, I want to allow the selection of a range of horizontal (without zoom) so that the user can see the selected range.

    1. How do I allow to select the horizontal range in the chart?

    2. the data graphic is ChartCollectionAnalogWaveform , how can I access the data of the selected only (I want to show statistical data)?

    What you describe sounds like a perfect fit for the RangeCursor . For example:

    XAML

        

            

                

            

        

    Code

        foreach( IPlot plot in graph.AllPlots ) {

            var values = rangeCursor.RetrieveValues( plot );

            using( var xValues = values[0] )

            using( var yValues = (Buffer)values[1] ) {

                double average = yValues.Average( );

                string example = string.Format( "Plot {0} average over [{1:0}]: {2:0.##}", plot.Index, rangeCursor.ActualHorizontalRange, average );

                // ...

            }

        }

  • Hide the first and the last Division in the WPF chart axis

    I want to hide the default marker of the first and the last major division in an axis of a chart of WPF. I tried to extend RangeDivisionsMode and define my own class object to the MajorDivisions.Mode property on the axis. But even when I returns a list empty in RangeDivisionsMode.GetDivisions(...), the first and the last marker is drawn.

    Thanks in advance, Jonas

    The minimum and maximum labels are transmitted separately when displaying a scale (even if technical RangeDivisionsMode custom can be used for the minor divisions).

    There is no direct configuration option to hide extreme labels, but you can achieve this effect by initializing the LabelPresenter property on MajorDivisions by a custom implementation:

    class CustomFormatter : GeneralValueFormatter {

            protected override UIElement VisualizeCore( TData value, ValuePresenterArgs args, UIElement existingVisual ) {

                UIElement element = base.VisualizeCore( value, args, existingVisual );

    var axis = (Axis)args.Context;

                Range range = axis.Range;

                var comparer = range.Comparer;

                bool isExtreme =

                       comparer.Compare( range.Minimum, value ) == 0

                    || comparer.Compare( range.Maximum, value ) == 0;

                element.Opacity = isExtreme ? 0.0 : 1.0;

    return element;

            }

        }

  • Bug in reporter Panel updated with the property Value Chart

    Hi guys,.

    Defer to what the Panel update property is set to true and chart is updated with the help of node "Property value", data are not updated graphics. Capture of the block diagram and VI (2014) screen gasket.

    Is this a known bug, and is there any fix for it?

    Thank you

    Knockaert

    I have not tried running your code, but here are some possible solutions:

    1. There is a primitive to write the value of a control by index (added in ~ 2013). This is designed to be used others live too and should work like a local.
    2. You can send data using another way (like a queue, etc.).
    3. Use the Ctl Val.Set method.
    4. Do not use a chart. Use a chart and manage the buffer yourself. You can find some examples if you're looking for graph XY.
  • bar with diagonal lines pattern chart

    Hi all

    I need to create a bar chart where it will be filled with lines inside. The diagonal white lines has alternating with bands of another color chosen dynamically.

    I know we have itemrenderers and we can use it.

    I was able to fill the full bar with a picture

    But not able to reach the exact needs.

    Pls help...

    Hi Marco,.

    Use of the component below as an itemRenderer for your histogram, you will reach the desired output, you need.

    package components.renderers
    {
    import flash.display.Graphics;
    Import mx.charts.series.items.ColumnSeriesItem;
    Import mx.core.IDataRenderer;
    Import mx.core.UIComponent;
     
    SerializableAttribute public class BarColorItemRenderer extends UIComponent implements IDataRenderer
    {
    public static const colors: Array = [0 x 000000, 0 X 938953, 0X1F497D, 0XC0504D, 0X9BBB59, 0X8064A2, 0X4BACC6, 0XF79646, 0X7F7F7F, 0X548DD 4, 0 X 632423, 0X4F6128, 0XB2A2C7, 0X31859B, 0 X 974806, 0X20B2AA, 0XF5DEB3, 0XDDA0DD, 0XE9967A, 0X7FFFD 4];
    private var _chartItem: *;
        
    public void BarColorItemRenderer () {}
    Empty constructor.
    }

    public function get data (): object {}
    Return _chartItem;
    }

    public function set {data(value:Object):void}
    If (ColumnSeriesItem)
    {
    _chartItem = value as ColumnSeriesItem.
    }
    invalidateDisplayList();
    }
    override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {}
    super.updateDisplayList (unscaledWidth, unscaledHeight);
    var Graphics = g:Graphics;
    g.Clear ();
    g.beginFill (colors [(_chartItem == null)? 0:_chartItem.index]);
    g.drawRect (0, 0, unscaledWidth, unscaledHeight);
    g.lineStyle(2,0XFFFFFF,1);
    var barY: int = 10;
    var moveX:int = 10;
    moveY var: int = 0;
    var stripWidth:int = 10;
    While (barY< unscaledheight="" ||="" movey=""><>
    {
    g.moveTo (moveX, moveY);
    g.lineTo(0,barY);
      
    If ((moveX + stripWidth)<>
    {
    moveX += stripWidth
    }
    on the other
    {
    moveX = unscaledWidth;
    moveY += stripWidth.
    }
    barY += stripWidth.
    }
    g.endFill ();
    }
    }
    }

    Thank you

    Jean Claude Chari

  • WPF chart: formatting of the axis labels

    How to configure the chart to show only the first name label and the axis? I think that it is somehow needs to be done by changing the RangeLabeledDivisions.Mode property.

                         













    You can set the Mode on the MajorDivisions to a page count mode two:



            Mode="Count: 2" TickVisibility="Hidden">

                    ...

            

        

    This will show just the minimum and maximum divisions for the beach.

  • LabVIEW hangs with in the intensity chart

    Twice this morning, LV2010 weighed ("program is not repsonding") when I tried to put a graphic on my front intesity.  In one case, I copied the graphic in an example program OR my VI.  When I tried to reposition the chart on my forehead panael, LV unresponsive.  Same thing happened when I tried again; the second time, I have the graph of the intensity of the palette of tables and graphs.  I LV 2010, version 10.0f2 and windows XP.  Thank you.

    Hello!

    The following KnowledgeBase explains why this could happen.

    http://digital.NI.com/public.nsf/allkb/9A8FB888BFCED9658625721500434A31

    Basically, this table might contain a large amount of data, and when you move, LabVIEW must reorganize all this information in RAM as you move the chart. You can write smaller data, or save all data in a separate table in the table at the end of the execution so you can save it. If you want to view a chart later, simply enter it in a graph.

  • WPF chart: difficulty width of vertical axis

    How do I do that? Currently, it is automatically resized to fit label max tick.

    I just use TemplateValuePresenter as a simple XAML example only. When you set your own trainer of value, you can return any user interface element to display. For example, if you were derived from GeneralValueFormatter , you can use code like below wrap his design in a Viewbox :

    protected override UIElement VisualizeCore( TData value, ValuePresenterArgs args, UIElement existingVisual ) {

            var viewbox =

                   existingVisual as Viewbox

                ?? new Viewbox { MaxWidth = 16, StretchDirection = StretchDirection.DownOnly };

    viewbox.Child = base.VisualizeCore( value, args, viewbox.Child );

            return viewbox;

        }

    Your XAML code snippet, it seems you want to specify a .NET "0.00" format. In this case, you can use the StringFormat property provided by Binding :

  • of WPF XY scatter chart

    I'm trying to display a WPF graph where each data point corresponds to a constant fractional delta along the asis x. E.. g. (0.15, 1), (0.30, 5), (0.45, 3.6),...

    My best guess is that I want to draw an array of Points that contain values such as above because I do not understand how to inform the chart control that each value to plot represents a value of delta-X which is not 1 (e.g. 0.15).

    When I try to update the dependency property of the data source of the graph through data binding (for example to call the event handler property change with the name of the property of code-behind), I get the following exception:

    I have sought examples of graphics 2D point clouds using the WPF chart without success control. Note that this is a different problem from that of several plots on the same graph display.

    Thank you in advance for your help!

    -Paul.

    Currently, we have an example called 'XYPlotting' that shows dispersion of the data in the chart in WPF. You can find this with the WPF examples that have been installed with Measurement Studio.

    Pointis the most common type that provides data from point clouds, although like other types ComplexDouble or ChartCollection would also work (see how: map and graphic topic for a list of all supported data types).

    About the exception, this is the expected behavior during the initialization of a data type. Note that it is a "first chance exception", which means that this dialog box appears immediately when the exception is thrown, even if it is subsequently managed. If you continue execution, you will find that the exception is handled, and the graph shows data.

    "Warnings of exception are controlled in Visual Studio through the Exceptions dialog box, accessible by the Debug" Exceptions... menu. "First chance" corresponds to the column up; Unmanaged user represents the exceptions that spread to your code:

    To explain a bit more on the reason why the exception occurs: all the types supported by the chart controls is expandable and not fixed before hand. When a data type is encountered for the first time, we search to determine the best descriptor to use. The initial version of WPF controls, we chose to rely on the .NET, verification of the arguments type system generic, but since there is no method "such would be valid?" we must build the type and manage type load failures that occur. Because we cache the result, these exceptions do not often appear, but it is something we intend to improve in the future.

Maybe you are looking for