Click here to Skip to main content
15,123,923 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:

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.
Updated 15-Feb-16 16:51pm
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