I am trying to bind a DataTable
with a MS Chart. The Chart contains two series, that are two columns of the DataTable
. I am using VB in Visual Studio 2010. Here is my code:
Public tableTempJDL As DataTable = New DataTable("TempJDL")
'tableTempJDL is then filled
With Me.ChartBHKW
.DataSource = tableTempJDL
.Series(0).Name = oGebäude.Art
.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Spline
.Series(1).Name = oBHKW.Modell
.Series(1).ChartType = DataVisualization.Charting.SeriesChartType.Spline
.Series(0).XValueMember = Convert.ToString(tableTempJDL.Columns("Stunden"))
.Series(0).YValueMembers = Convert.ToString(tableTempJDL.Columns("PthObjekt"))
.Series(1).XValueMember = Convert.ToString(tableTempJDL.Columns("Stunden"))
.Series(1).YValueMembers = Convert.ToString(tableTempJDL.Columns("PthBHKW"))
.DataBind() '<-- ArgumentOutOfRangeException
End With
I get an ArgumentOutOfRangeException
error: "Only 1 Y values can be set for this data series". And this even though I have two series in my Chart settings.
I would like to avoid to build the chart myself, and I really need two series, not two points for each XValue.