【问题标题】:How to plot a graph with different colors in d3 wpf如何在 d3 wpf 中绘制具有不同颜色的图形
【发布时间】:2014-03-26 10:11:26
【问题描述】:

我在 WPF 中使用 D3(动态数据显示)。我有绘制动态折线图的代码,这里是我的代码 sn-p。

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 &gt; animatedY[counter] 当这种情况为真时,它会改变线条颜色但它会转换整个线条颜色。我希望图表线条应该是红色和视情况为绿色

【问题讨论】:

    标签: c# wpf dynamic-data-display


    【解决方案1】:

    如果你想用两种不同的颜色在折线图上显示,你应该简单地将这个折线图分成两条不同的线。然后显示这两行并定义正确的颜色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-13
      • 1970-01-01
      • 1970-01-01
      • 2020-12-10
      • 2016-12-13
      • 2012-07-26
      相关资源
      最近更新 更多