plotter是一个DynamicDataDisplay.ChatterPlot变量。它添加了几行代码,如下所示:
LineGraph lgChA = plotter.AddLineGraph(dsChA, Colors.Red, 1, "Data");
LineGraph lgChB = plotter.AddLineGraph(dsChB, Colors.Green, 1, "Data");曲线图是实时更新的,所以我只更新数据源,如下所示:
if (_dataXChA != null && _dataXChA.Length > 1)
{
EnumerableDataSource<double> xChA = new EnumerableDataSource<double>(_dataXChA);
xChA.SetXMapping(xVal => xVal);
if (_dataYChA != null && _dataYChA.Length == _dataXChA.Length)
{
EnumerableDataSource<double> yChA = new EnumerableDataSource<double>(_dataYChA);
yChA.SetYMapping(yVal => yVal);
CompositeDataSource dsChA = new CompositeDataSource(xChA, yChA);
//((LineGraph)plotter.brus = dsChA;
((LineGraph)plotter.Children.ElementAt(startIndex)).DataSource = dsChA;
plotter.FitToView();
}
}
if (_dataXChB != null && _dataXChB.Length > 1)
{
EnumerableDataSource<double> xChB = new EnumerableDataSource<double>(_dataXChB);
xChB.SetXMapping(xVal => xVal);
if (_dataYChB != null && _dataYChB.Length == _dataXChB.Length)
{
EnumerableDataSource<double> yChB = new EnumerableDataSource<double>(_dataYChB);
yChB.SetYMapping(yVal => yVal);
CompositeDataSource dsChB = new CompositeDataSource(xChB, yChB);
((LineGraph)plotter.Children.ElementAt(startIndex + 1)).DataSource = dsChB;
plotter.FitToView();
}
}但是我想知道,除了更新数据点之外,我还可以改变LineGraph变量的画笔颜色吗?我想它应该放在像plotter.XXX.color这样的地方吧?
发布于 2013-02-13 00:53:22
所以基本上,我通过在每次重新分配颜色之前将颜色设置为透明来解决这个问题。如下所示:
for (int i = 0; i < LiveImage.MAX_CHANNELS; i++) // color reset
{
((LineGraph)plotter.Children.ElementAt(startIndex + i)).LinePen = new Pen(new SolidColorBrush(Colors.Transparent), 1);
}重点不是添加任何折线图。
发布于 2013-01-04 15:37:38
您可以像这样更改线条的颜色:
LineGraph lgChA = plotter.AddLineGraph(dsChA, Colors.Red, 1, "Data");
Pen newColour = new Pen(Brushes.Red, 1.0);
//or whatever colour you want to change it to, second parameter is line thickness
lgChA.LinePen = newColour;然后,您的线条将更新为您给它的笔的颜色。
https://stackoverflow.com/questions/14142940
复制相似问题