I have a chart
with type columns
. How will I add a background color to the Y Axis? like the gray color in this graph? Is this possible? I am using Chart Control
for Winforms from Visual Studio 2015. My data is from SQL.
Code to populate Chart:
chart1.DataSource = dtSalesChart;
foreach (DataRow row in dtSalesChart.Rows)
{
Series S = new Series(row["Period"].ToString());
chart1.Series.Add(S);
}
for (int j = 1; j < dtSalesChart.Columns.Count; j++)
{
for (int i = 0; i < dtSalesChart.Rows.Count; i++)
{
chart1.Series[i].Points.AddXY(dtSalesChart.Columns[j].ColumnName,
dtSalesChart.Rows[i][j].ToString());
}
}
chart1.Series[0].Color = Color.FromArgb(15, 130, 154);
chart1.Series[1].Color = Color.FromArgb(117, 193, 205);
Title title = chart1.Titles.Add("ChartTitle");
title.Text = "Sales By Month";
title.Font = new Font("Tahoma", 12, FontStyle.Bold);
title.ForeColor = Color.FromArgb(32, 77, 137);
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.White;
chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.WhiteSmoke;
chart1.DataBind();
I want to add the gray background in the Y Axis like below :