After looking at your code, I'm not sure about the DataBindXY used in a loop versus the AddXY method. It does appear that the Refresh method is missing.
Here is a method I use to display a stacked bar chart to display success versus error to show error rates.
public static void ErrorRateChart(Chart chartControl, DateTime startDate, DateTime endDate, Int64 projectTypeID = 0)
{
try
{
chartControl.Titles.Clear();
chartControl.Legends.Clear();
chartControl.Series.Clear();
SummaryEntityList errRate = StatusReport.GetErrorRate(projectTypeID, startDate, endDate);
if (errRate != null)
{
chartControl.Legends.Add("Failed");
chartControl.Legends.Add("Succeeded");
chartControl.Legends[0].Position.Auto = false;
chartControl.Legends[0].Position.X = 0;
chartControl.Legends[0].Position.Y = 0;
chartControl.Legends[0].Position.Width = 30;
chartControl.Legends[0].Position.Height = 15;
chartControl.ChartAreas[0].AxisY.Title = "Success Rate (%)";
chartControl.ChartAreas[0].AxisY.TitleFont = new Font("Arial", 11, FontStyle.Regular);
Series seriesSucceeded = chartControl.Series.Add("Succeeded");
seriesSucceeded.ChartType = SeriesChartType.StackedBar100;
seriesSucceeded.IsValueShownAsLabel = true;
foreach (SummaryEntity item in errRate)
{
seriesSucceeded.Points.AddXY(item.Project, item.Succeeded);
}
Series seriesFailed = chartControl.Series.Add("Failed");
seriesFailed.ChartType = SeriesChartType.StackedBar100;
seriesFailed.IsValueShownAsLabel = true;
foreach (SummaryEntity item in errRate)
{
seriesFailed.Points.AddXY(item.Project, item.Failed);
}
chartControl.Refresh();
}
}
catch (Exception ex)
{
ErrorLogWriter.ErrorLog = ErrorLogWriter.ErrorLog.Write(ex);
throw;
}
}