I am using DynamicDataDisplay to plot my real-time signal. I would like to have both markers and lines showing up on my chart, so I think I should use LineAndMarker<MarkerPointsGraph>; When x-y data are updated, my logic is to only update the date source, not adding more graph lines. In that case I still got the performance if the data are large and update is quick. My question is: I don't see a DataSource domain for LineAndMarker<MarkerPointsGraph>, so I have no idea how I can update data? Here is an example in which I used LineGraph instead of LineAndMarker<MarkerPointsGraph>; But LineGraph does not seem to handle markers.

for (int i = 0; i < _nColorChannels; i++)
{
    if (_dataX[i].Length == _dataY[i].Length)
    {
        EnumerableDataSource<int> xOneCh = new EnumerableDataSource<int>(_dataX[i]);
        xOneCh.SetXMapping(xVal => xVal);
        EnumerableDataSource<int> yOneCh = new EnumerableDataSource<int>(_dataY[i]);
        yOneCh.SetYMapping(yVal => yVal);
        CompositeDataSource ds = new CompositeDataSource(xOneCh, yOneCh);

        Action UpdateData = delegate()
        {
            ((LineGraph)plotter.Children.ElementAt(startIndex + i)).DataSource = ds;

        };

        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                               UpdateData);
    }
}

Any suggestions is appreciated. Thank you. Nick

A little update: It seems MarkerPointsGraph has DataSource, but how do I create MarkerPointsGraph instance that can AddLineGraph()? Something like how the LineGraph version is created:

LineGraph lg = new LineGraph();
lg = plotter.AddLineGraph(dsOneCh, _lineprofileColor[i], marker, "Data");
有帮助吗?

解决方案

Something like this:

if (_dataX[i].Length == _dataY[i].Length)
                    {
                        EnumerableDataSource<int> xOneCh = new EnumerableDataSource<int>(_dataX[i]);
                        xOneCh.SetXMapping(xVal => xVal);
                        EnumerableDataSource<int> yOneCh = new EnumerableDataSource<int>(_dataY[i]);
                        yOneCh.SetYMapping(yVal => yVal);
                        CompositeDataSource ds = new CompositeDataSource(xOneCh, yOneCh);

                        Action UpdateData = delegate()
                        {

                            ((PointsGraphBase)plotter.Children.ElementAt(startIndex + i + 1)).DataSource = ds; 

                        };

                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, UpdateData);
                }

Cast it to PointsGraphBase

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top