線で結ばれた点の束で表されるデータをプロットしようとしています。しかし、プロットを行うと、ドットが表示されているだけで、線は見えません。何が問題なのかわかりません。これが私のコードで、これがLineAndMarkerプロッタの開始方法です。
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);
}
}
基本的な考え方は単純です。プロッタを作成してから、データと色のみを更新します。赤い点が分離しているだけですが、緑やそれらの点を結ぶ色の線は見当たりませんでした。私は混乱しています。誰が私が間違ったことを指摘できますか?どうもありがとう。