WPFでD3(動的データ表示)を使用しています。ここに動的折れ線グラフを描画するコードがあります。これが私のコード スニペットです。
for (int counter = 0; counter < animatedX.Count; counter++)
{
Chart.Trade trade = new Chart.Trade(animatedX[counter], animatedY[counter]);
Color currentLineColor = Colors.Green;
if (previousCloseprice > animatedY[counter])
{
currentLineColor = Colors.Red;
}
Dispatcher.BeginInvoke(new Action(() =>
{
chartLine.LinePen = new Pen(new SolidColorBrush(currentLineColor), 3);
}));
_chartValue.AppendAsync(Dispatcher, trade);
Thread.Sleep(100);
}
上記のコードから、単色でアニメーション グラフを描画できます。previousCloseprice > animatedY[counter]
この条件が true の場合、線の色が変更されますが、線全体の色が変換されます。調子