I want to create line chart by datagridview I need red colour plot line for negative values and green for positive values. I write the code but I get only green colour for all data points.
foreach (DataGridViewRow row in dgvReport.Rows)
{
decimal val = 0;
val = Convert.ToDecimal(row.Cells[8].Value.ToString());
if (val < 0)
{
Dchart.Series[0].Color = System.Drawing.Color.Red;
}
if (val > 0)
{
Dchart.Series[0].Color = System.Drawing.Color.Green;
}
Dchart.Series[0].Points.AddXY(row.Cells[0].Value.ToString(), row.Cells[8].Value.ToString());
Dchart.ChartAreas[0].AxisX.Interval = 3;
}