Я пытаюсь построить данные, представленные связкой точек, связанных с линиями. Однако, когда я делаю сюжет, я могу видеть только отображаемые точки, но я не вижу никаких строк. Я не знаю, в чем проблемы. Вот мой код, и это, как инициируется LineAndMarker плоттер:LineAndMarker <MarkerPointsGraph> видны только маркеры, но нет строк?
public SignalStatsDisplay()
{
InitializeComponent();
plotter.Legend.Remove();
_initialChildrenCount = plotter.Children.Count;
int count = plotter.Children.Count;
//do not remove the initial children
if (count > _initialChildrenCount)
{
for (int i = count - 1; i >= _initialChildrenCount; i--)
{
plotter.Children.RemoveAt(i);
}
}
_nColorChannels = 4;
// _lineprofileColor = new Color[4];
// _lineprofileColor[0] = Colors.Transparent;
//_lineprofileColor[1] = Colors.Red;
// _lineprofileColor[2] = Colors.Black;
// _lineprofileColor[3] = Colors.Blue;
LineAndMarker<MarkerPointsGraph> lam = new LineAndMarker<MarkerPointsGraph>();
CirclePointMarker pm = new CirclePointMarker { Size = 5, Fill = Brushes.Red };
if (_nColorChannels > 0) // plotter init
{
_dataX = new List<int[]>();
_dataY = new List<int[]>();
int[] dataXOneCh = new int[1];
int[] dataYOneCh = new int[1];
dataXOneCh[0] = 0;
dataYOneCh[0] = 0;
for (int i = 0; i < 4; i++)
{
_dataX.Add(dataXOneCh); // data x-y mapping init
_dataY.Add(dataYOneCh);
EnumerableDataSource<int> xOneCh = new EnumerableDataSource<int>(dataXOneCh);
EnumerableDataSource<int> yOneCh = new EnumerableDataSource<int>(dataYOneCh);
xOneCh.SetXMapping(xVal => xVal);
yOneCh.SetXMapping(yVal => yVal);
CompositeDataSource dsOneCh = new CompositeDataSource(xOneCh, yOneCh);
lam = plotter.AddLineGraph(dsOneCh,
(new Pen(Brushes.Green, 2)),
new CirclePointMarker { Size = 5, Fill = Brushes.Yellow },
(new PenDescription("Data")));
}
plotter.FitToView();
}
else
{
return;
}
}
и вот как данные динамического отображения обновляется:
public void RedrawSignalAnalysisPlot()
{
int startIndex = _initialChildrenCount;
if ((_nColorChannels > 0) && (_dataX != null) && (_dataY != null))
{
CompositeDataSource[] dsCh = new CompositeDataSource[_nColorChannels];
//for (int i = 0; i < 4; i++) // color reset
// {
// ((LineGraph)plotter.Children.ElementAt(startIndex + i)).LinePen = new Pen(new SolidColorBrush(Colors.Transparent), 1);
// }
for (int i = 0; i < 1; 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()
{
((PointsGraphBase)plotter.Children.ElementAt(startIndex + i + 1)).DataSource = ds;
//((CirclePointMarker)plotter.Children.ElementAt(startIndex + i + 1)).Pen = new Pen(new SolidColorBrush(Colors.Green), 1);
};
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, UpdateData);
}
}
Action PlotFitToView = delegate()
{
plotter.FitToView();
};
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, PlotFitToView);
}
}
Основная идея проста: создать плоттер, то только обновлять данные и цвет. Я вижу только красные точки, разделенные друг с другом, но я не видел никаких зеленых или любых цветовых линий, соединяющих эти точки. Я запутался. Кто-нибудь может указать, где я ошибся? Большое спасибо.