0

I would like to know on how to change color for a certain value ranges for Y axis in chart component . (c# , Windows forms )

If I use this

chart1.Series["Series1"].Points[2].Color = Color.Orange;

I can see the change in color (orange) x axis for the range 2 but I need in Y axis.

enter image description here

TaW
  • 53,122
  • 8
  • 69
  • 111
sassy
  • 1
  • 3
  • I think that you can take a look to this answer: http://stackoverflow.com/questions/26729843/c-sharp-change-color-in-chart – Krom Apr 26 '17 at 09:29
  • 1
    You mean the y-axis itself but only parts of it?? You will have to draw that of maybe weak one or more VerticalLineAnnotations.. Or do you mean the DataPoints? What ChartType does your series have? – TaW Apr 26 '17 at 09:51
  • 1
    [This post, explaining how to color line sections above an y-value](http://stackoverflow.com/questions/21001202/how-do-i-fill-everything-over-a-straight-line-and-under-a-curve/37488737?s=1|8.1956#37488737) may be of interest. – TaW Apr 26 '17 at 10:21
  • In the Y axis , I have set values as 10 , 20 , 30 , 40 , 50 and more . while fetching the data I need the change of colors for points more than 30 . Please let me know If have to be more clear – sassy Apr 26 '17 at 10:28
  • http://stackoverflow.com/questions/29302663/how-to-change-chart-series-color may be give some idea – user688 Apr 26 '17 at 10:37
  • 1
    I have edited my question with a sample image – sassy Apr 26 '17 at 11:38
  • If you know that __no line segment crosses__ those ranges, ie all crossings are happening __at__ a datapoint you can set each datapoint to the proper color. But if some segments do cross the ranges you need to __ownerdraw__ the lines. My link shows you how..! - If the former is true, say so and i'll show you an example. For the later case the linked post can easily be adapted from filling the area to drawing colored lines.. – TaW Apr 26 '17 at 15:25
  • For case 1 this is a start: `foreach (var dp in someSeries.Points) if (dp.YValues[0] > 20) dp.Color = Color.Red;` – TaW Apr 26 '17 at 17:35

0 Answers0