Click here to Skip to main content
15,069,297 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Using C# and MS Chart Controls for Dot Net.

I have charts setup to display an 'area' style graph. I want all the area below the 0 index line to be displayed in RED, everything above it in green.



How do I paint all data below the line red?

What I have tried:

I have figured out how to paint the points below the line in red using this code:

C#
foreach (DataPoint dp in chart1.Series["Change"].Points)
  if (dp.YValues[0] < 0)
    dp.Color = Color.Red;


The problem with this is that any negative value heading positive will be painted green so some green is shown below the line.
Posted
Updated 15-Feb-16 15:51pm
v2
Comments
Maciej Los 15-Feb-16 17:02pm
   
Please, type full name of chart.
Member 11709930 17-Feb-16 18:05pm
   
Not sure what you mean?
The chart type is 'area'
chart1.Series["Change"].ChartType = SeriesChartType.Area;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900