last day (19 days later) » 

18:03
0
Q: how to draw colored lines on a graph depending on the data

5tkaunsuccessfully trying to draw lines between the bubbles, depending on their movement. if the next value in the array is greater than the previous one, a green line will be drawn between them, but if the next value is less than the previous one, a red line will be drawn. I wrote a loop, but it doe...

TaW
TaW
Line charts will always connect all points. So, it may be simpler to use only one Series for those extra lines. You can color each line separately by coloring its 2nd point. Or you can add transparent points to skip segments. Modify the is else clauses to always add a point to each series, but some with a transparent color..
if (i<ipp.Length-1) {int p = series_2.Points.AddXY(ipp[i], pgc[i]); series_2.Points[p].Color = ipp[i + 1] > ipp[i] ? Color.Green : Color.Red;} - Puttin this in the 1st loop and omitting the 2nd one should work..
it’s just super, draws as I wanted it, excellent. But there is a small point, does not connect with the last point prnt.sc/sbft8t is it posible to add in the end off array empty value, or somthink like that?
TaW
TaW
Ah, yes, I think I messed it up a little. Try this int p = series_2.Points.AddXY(ipp[i], pgc[i]); if (i<ipp.Length-1) {int p = series_2.Points.AddXY(ipp[i], pgc[i]); if (i <ipp.Length-1) series_2.Points[p].Color = ipp[i - 1] > ipp[i] ? Color.Green : Color.Red;}
The index was outside the bounds of the array :D
and i cant understand why i have that prnt.sc/sbg308 if value of 2012 lessthan 2013, but its drawing red
if i use that code above i have an error like https://prnt.sc/sbg7tw
if i change ipp[i - 1] to i+1 i have i more better result, but without line between last point, and some problem with a line between 2012-2013
TaW
TaW
A typo, but you'll have to debug this yourself - This seems to work here. Note the change in the codition.: `int p = series_2.Points.AddXY(ipp[i], pgc[i]);
if (i> 0) series_2.Points[p].Color = pgc[i - 1] <= pgc[i] ? Color.Green : Color.Red;}`
18:12
i dont know, maybe i write somethink wronge, but i have same
oh, i got it
i shoud change it if (i < ipp.Length - 1) to if (i < ipp.Length)
and it works awesome prnt.sc/sbgcxz
you helped me a lot again.
very grateful, kind man)
TaW
TaW
19:04
cool. night..

  last day (19 days later) »