Page 1 of 1

Binding a Chart to a Datatable

Posted: Wed Aug 13, 2008 10:14 pm
by 8739068
When I bind a tchart to a datatable like what is in the TChart for .NET
Example application at "Welcome !\Datasets\Data table XY Series"

I see that if I go to the Chart Editor and go to the Data tab that no data points are shown.

1. Can I not see the data in the Data tab of the chart editor? or is this a bug?
2. If I add a DragMarks tool and assign it to my series and have it only edit the Y values. When I change a points Y value by dragging, does it update the underlying DataTable? If not how can I make it do this?

Re: Binding a Chart to a Datatable

Posted: Thu Aug 14, 2008 9:44 am
by Chris
Hello,
Mike Jones wrote:When I bind a tchart to a datatable like what is in the TChart for .NET
Example application at "Welcome !\Datasets\Data table XY Series"

I see that if I go to the Chart Editor and go to the Data tab that no data points are shown.
Mmmm, the following code seems to work ok here using the latest release:

Code: Select all

    public Form3()
    {
      InitializeComponent();
      InitializeChart();
    }

    private Steema.TeeChart.Styles.Line series;
    Steema.TeeChart.TChart tChart1; 

    private void InitializeChart()
    {
      tChart1 = new Steema.TeeChart.TChart();
      tChart1.Dock = DockStyle.Fill;
      this.Controls.Add(tChart1);

      series = new Line(tChart1.Chart);
      series.DataSource = GetData();
      series.XValues.DataMember = "X";
      series.YValues.DataMember = "Y";

      tChart1.DoubleClick+=new EventHandler(tChart1_DoubleClick);
    }

    private DataSet GetData()
    {
      DataSet TeeDataSet = new DataSet();
      DataTable TeeDataTable = new DataTable();

      DataRow newRow;

      DataColumn xval = new DataColumn("X", typeof(double));
      DataColumn yval = new DataColumn("Y", typeof(double));

      TeeDataTable.Columns.Add(xval);
      TeeDataTable.Columns.Add(yval);

      for (int i = 0; i < 10; i++)
      {
        newRow = TeeDataTable.NewRow();
        newRow[xval] = i;
        newRow[yval] = i;
        TeeDataTable.Rows.Add(newRow);
      }

      TeeDataSet.Tables.Add(TeeDataTable);
      return TeeDataSet;

    }

    void tChart1_DoubleClick(object sender, EventArgs e)
    {
      tChart1.ShowEditor();
    }
Does this work ok at your end?

Your example works but mine doesn't

Posted: Thu Aug 14, 2008 7:05 pm
by 8739068
Found that the example TeeChart for .NET application at Welcome !\Datasets\Using the Designtime Editor. Press the "Edit DataSource button to bring up Chart Editor. Press the Data button. Notice there is nothing there.

Can you test with my example. It is uploaded it is in ChartBinding.zip.

Run the project and press the Bind #1 button. Then use the mouse to drag a point up or down. I would like to see the value in the datagridview to update after I drag a point.

While trying to understand the behavior of TChart I went to the Chart Editor dialog and wanted to look at the data to see if dragging points would update the data. In my example I see no points on the Data tab in the Chart Editor Dialog. I definitely see that the datagridview is not getting updated.

Is there an event that will fire after a user drags a point and then I can somehow refresh the datagridview with the new value?

I expected that if I data bound a TeeChart series to a datatable that dragging points would update the datatable automatically through the databinding. Obviously that is not working in my example

Really in need of some suggestions

Posted: Tue Aug 19, 2008 2:01 pm
by 8739068
I really need the DragPoints tool to edit an underlying DataTable. I have a Steema.TeeChart.Styles.Line series bound to the datatable.

Also, I have the datatable bound to a datagridview. I have found a way to get the chart to update if I change a value in the datagridview. I would like the dragpoints to be used to edit the datatable as well. I really don't see any good way to do this.

I am hoping you might have some ideas on how I could do this. This need is very immediate for me. We do have the source code so if there are any suggestions you might have that might involve modifying our version of the source that would be great.

Posted: Thu Aug 21, 2008 10:34 am
by Pep
Hello Mike,

so, if I understand the problem is that the DataTable tool is not updated once a point has been dragged ? I've just tried it here using the latest v3 and worked fine.

Not using the Data Table tool

Posted: Thu Aug 21, 2008 2:38 pm
by 8739068
I am talking about binding to a System.Data.DataTable where I bind the DataColumns to Line Series XValues.DataMember and YValues.DataMember. The Line Series DataSource property is set to the System.Data.DataTable.

Just as the sample of code above shows.

When I drag a point I want to underlying datasource to be updated. I should be able to look at the System.Data.DataTable and see the corresponding value to be updated. That is the definition of true databinding. It does not appear that TChart is implementing databinding fully. TChart will use the data source provided but TChart will not update that data source after a point has been dragged using the DragPoint tool.

Very close to a solution

Posted: Thu Aug 21, 2008 5:04 pm
by 8739068
I stumbled upon the DragPoint Drag event. This event signature looks like

Code: Select all

dragPoint1_Drag(Steema.TeeChart.Tools.DragPoint sender, int index)
The Sender parameter has a member, Series, yet it is null even though there is a private variable called "theSeries" that is set to the series that the drag point tool is assigned to.

I found that I needed to set the Series property for the dragpoint tool, however it seems that if I didn't the dragpoint tool will operate on a series. It defaulted to some series, yet it the sender parameter gave me no way tell me what series it is operating on. It obviously knows internally but does not give me access to that information.

Any feedback would be appreciated.

Posted: Mon Aug 25, 2008 9:47 am
by narcis
Hello Mike,

I'm afraid what you request is not possible for now. I've added your request to the wish-list to be considered for inclusion in future releases.