Start New Discussion within our Software Development Community

Hello,

Im working with visiual Studio 2010 in a Windows Form Application using C#.
I created a DataSet (Project / Add Component / Data / DataSet) Then Creat a new Table(worktable) and add 3 Columns(one,two,three) to it.
The Forms Window got a DataGridView wich is connected to to the DataSet (DataGridview properties Datasource: workTableBindingSource) This works fine the DataGridView shows the correct actual Data in the DataSet.
But in the the Chart it doesen't.
I set the Chart Datasource to the same as in the Gridview. Then i open the Series Editor go to Series1. In the properties for YValueMember i can select one of the Columns but in the YValueMember i can't??? Why?

If i write it in code then if i try to bind the DataSet to a Spline Chart the error:
*(Data points insertion error. Only 2 Y values can be set for this data series,Parameter name: dataSource) * shows up.

        private void chart1_Click(object sender, EventArgs e)
        {
            chart1.DataSource = dataSet3.workTable;
            chart1.Series.Add("Wirkenergie");
            chart1.Series["Wirkenergie"].YValuesPerPoint = 1;
            chart1.Series["Wirkenergie"].XValueMember = "Time";
            chart1.Series["Wirkenergie"].YValueMembers = "Index";
            chart1.DataBind();
        }

Here a snippet to fill the DataSet

                DataRow workRow = dataSet3.workTable.NewRow();
                workRow["Index"] = tempIndex;
                workRow["Active Power"] = tempActivePower;
                workRow["Time"] = time;
                dataSet3.workTable.Rows.InsertAt(workRow, 0);

Maybe you can help me i don't get it.

Thanks

if you're still looking for a solution to this take a look at this link.

It's a walk through of how to databind a chart in both C#.NET and VB.NET.

This article has been dead for over six months. Start a new discussion instead.