This is a migrated thread and some comments may be shown as answers.

Problems with custom databinding data tables to chart ds

3 Answers 73 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
travis
Top achievements
Rank 1
travis asked on 12 Oct 2011, 01:38 PM
Visual Studio 2011 / VB.net  / framework v4


I am missing something regarding the databinding process for winforms chart controls. In the following example I've used a rad chart inside a custom control but this behavior has been detected elsewhere in my efforts to dynamically and programatically render a databound radchart.

I'm using data tables and I'm using the programtic approach. I am using a data table that contains three columns:  series_id (string) , val (float), oa_time (float) and binding it to a chart control that is embedded into a newly instantiated custom control.

The process goes like this:

Populate the data table with series_id, oa time and val  (string,double,double).

Create a new control, assign the chart control inside the control the datagroupcolumn "series_id"
databind the chart control to the datatable

inside the custom control I have added a handler to the databound event of the chart (using the .load event of the control).

I fire the databind event and in the handler, assign each series (there is only suposed to be one) the following properties:
s(x).dataycolumn ="val"
s(x).dataxcolumn = "oa_time"



Each time I did this I would get unexpected results. Specifically it appeard to use the "series_id" column for the y val.  After a bit I realized that what I was probably seeing was the default bindings at work.

I hope the custom control doesnt throw this off too much because I was getting the exact same issue prior moving to a custom control approach  The reason for adding the chart to a custom control was so I could have a nice clean way of capturing the databound event for each dynamically created chart. 

My work around (and evidence that my column overrides are not working) is to use a typed datatable and specify a column order and then leave the datagroup and datay datax columns to their "default" values  (ie I dont specifiy anything).  If i position the oa_time,val and series_id values appropriately in the typed datattable's column-ordinal positions using the designer, I can get away with the default bindings and render my charts.

I have tried this inside and out of custom controls.  The only commonality between the two testing conditions being the controls were always created programatically in vb.code.  I'm guessing that I'm missing an event that is not contained in the documentation.


Thanks a lot in advance

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 17 Oct 2011, 11:35 AM
Hello Travis,

There's no need to wire to the DataBound event of the Chart just to map the Series DataXColumn. This can be done in Page_Load.
I've attached a sample that demonstrates it. Note that RadChart does not support DateTime values directly. DateTime values should be converted to their OLE Automation equivalents using the ToOADate() method. 

Regards,
Evgenia
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
travis
Top achievements
Rank 1
answered on 18 Oct 2011, 03:08 PM
thank you for this sample.  Yes, I am all over the oa date automation stuff.  The issue I have is partially sorted.  I do indeed explictly specify the datacolumn property,  However the yval property and xval is being implicitly defined based (apparantly) on the ordinal positioning of my datatable's column order.  If I try to set them in the databind event I get unexpected results. 

My workaround has been to effectively channel all my  datatables into a single typed datatable.  This leaves things generic enough I can work with it but I effectively can not databind to tables using explicit declarations of the .DataYColumn and .DataXColumn when placing the radchart inside a custom made control (or otherwise programatically).

0
Evgenia
Telerik team
answered on 21 Oct 2011, 12:51 PM
Hello Travis,

Could you please send us your sample runnable project so that we will be able to inspect it locally and advise you better based on the code?

Greetings,
Evgenia
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
Chart (obsolete as of Q1 2013)
Asked by
travis
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
travis
Top achievements
Rank 1
Share this question
or