0

I am using D3(Dynamic Data Display) in WPF. I have code to draw a dynamic line graph here is my code snippet.

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

From the above code I am able to draw animated graph with single color.when previousCloseprice > animatedY[counter] when this condition true it change the line color but it convert the whole line color.I want the chart line should be combination of red and green color according to to the condition

madan
  • 773
  • 13
  • 38

1 Answers1

0

If you want to display on linegraph with two different color, you should simply divide this line graph in 2 different lines. Then you display those two lines and you define the correct colors.

Jean Col
  • 522
  • 5
  • 16