I am plotting a Microsoft System.Web.UI.DataVisualization.Charting.Chart with three series (two columns and an overlaying line). It appears that the y axis upper bound is auto calculated based on the data range in the first series added to the chart. Subsequently any series does not get rendered when its y value is greater than the first series y value. In this instance I would like it to use the maximum value from any series.
The series are added to the chart via a generic method:
foreach (var s in model.Series)
{
var chartSeries = new Series(s.Title);
chartSeries.ChartType = s.Type;
chartSeries.Color = s.DrawColour;
// add the data to the series
foreach (DataRow row in data.Tables[0].Rows)
{
chartSeries.Points.AddXY(row[model.XAxis.DataColumnName], row[s.ColumnName]);
}
// does the series name come from a column? if not use the plain text. if the column has a caption use it, otherwise the column name.
chartSeries.Name = data.Tables[0].Columns.Contains(s.Title) ? String.IsNullOrEmpty(data.Tables[0].Columns[s.Title].Caption) ? data.Tables[0].Columns[s.Title].Caption : data.Tables[0].Columns[s.Title].ColumnName : s.Title;
chart.Series.Add(chartSeries);
}
If I reverse the order the series are added to the chart then the plot area is correct, however the line series sits behind the columns.
Any ideas? Thanks.