2014-03-26 119 views
0

我在WPF中使用D3(動態數據顯示)。我有代碼來繪製一個動態線圖這裏是我的代碼片段。如何在d3中繪製不同顏色的圖形wpf

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); 
      } 

從上面的代碼我能夠繪製單color.when previousCloseprice > animatedY[counter]動畫圖形時,這種情況真就改變線的顏色,但它轉換全線color.I想圖表行應該是組合紅色和綠色根據條件

回答

0

如果要在線圖上顯示兩種不同的顏色,應簡單地將此線圖劃分爲兩行。然後顯示這兩行,並定義正確的顏色。

相關問題