Page 1 of 1

Binding Data

Posted: Mon Aug 22, 2005 9:59 am
by 9527959
Hi,

I am trying to create a simple chart that maps a price against a date. I am using the folowing code:

Code: Select all

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	Dim Chart1 As Steema.TeeChart.Chart

	'Add in a series and fill it   
	Chart1 = WebChart1.Chart()
	Chart1.Aspect.View3D = False
	Dim Line1 As New Steema.TeeChart.Styles.Line(Chart1)

	'Add a SeriesToolTip to the Chart 
	Dim dt As DataTable
	dt = GetChartData()

	Line1.YValues.DataMember = dt.Columns("LastTrade").ToString()
	Line1.XValues.DataMember = dt.Columns("Date").ToString
	Line1.DataSource = dt

End Sub
The GetChartData function returns a valid datatable, but I get the error "Input string was not in a correct format." when I try to set the datasource.

Any help appreciated.

Regards


Taff

Posted: Mon Aug 22, 2005 11:05 am
by narcis
Hi Taff,

You can try replacing:

Code: Select all

   Line1.YValues.DataMember = dt.Columns("LastTrade").ToString() 
   Line1.XValues.DataMember = dt.Columns("Date").ToString 
   Line1.DataSource = dt 
for:

Code: Select all

   Line1.DataSource = dt
   Line1.YValues.DataMember = "LastTrade"; 
   Line1.XValues.DataMember = "Date";
If it doesn't work you should also post GetChartData() code. You could also have a look at the ADO.NET tutorial available at the TeeChart program group.

Posted: Tue Jan 03, 2006 5:07 pm
by 9637357
Hi, I get the same error when I try to bind data to the chart.
My code is as follows:

fastLine1.DataSource = ds.Tables[0].DefaultView;
fastLine1.XValues.DataMember = ds.Tables[0].Columns["DATE"].ToString();
fastLine1.XValues.DateTime=true;
fastLine1.YValues.DataMember = ds.Tables[0].Columns["YVALUE"].ToString();

I get the error

Server Error in '/SampleApplication' Application.
--------------------------------------------------------------------------------

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 107: fastLine1.DataSource = ds.Tables[0].DefaultView;
Line 108: fastLine1.YValues.DataMember = ds.Tables[0].Columns["YVALUE"].ToString();
Line 109: fastLine1.XValues.DataMember = ds.Tables[0].Columns["DATE"].ToString();
Line 110: fastLine1.XValues.DateTime=true;
Line 111:


Source File: c:\inetpub\wwwroot\sampleapplication\chart1.aspx.cs Line: 109

Stack Trace:


[FormatException: Input string was not in a correct format.]
System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info) +0
System.Double.Parse(String s, NumberStyles style, IFormatProvider provider) +208
System.Convert.ToDouble(String value, IFormatProvider provider) +32
System.String.System.IConvertible.ToDouble(IFormatProvider provider) +5
System.Convert.ToDouble(Object value) +36
Steema.TeeChart.Styles.Series.Add(DataView view) +772
Steema.TeeChart.Data.DataSeriesSource.TryRefreshData(Series s) +214
Steema.TeeChart.Styles.Series.FillFromDataSource() +379
Steema.TeeChart.Styles.Series.CheckDataSource() +19
Steema.TeeChart.Styles.ValueList.set_DataMember(String value) +52
SampleApplication.chart1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\sampleapplication\chart1.aspx.cs:109
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Please let me know if you have solved this issue and if yes, How?
Thanks.

Posted: Tue Jan 03, 2006 8:23 pm
by 9524350
I had the same error message when binding dataset table to one Candle serie.

To solve this probled I created a datatable with the correct column type (Complete example below).
Since this moment, it works correcly.

I hope it helps.

Best regards.

Code sample:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim DataSet_Obj As New DataSet
Dim DataRow_Obj As DataRow

Dim Tag_Serie_Candle As Steema.TeeChart.Styles.Candle

DataSet_Obj.Tables.Add("CandleTable")
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Date", System.Type.GetType("System.DateTime")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Open", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Close", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("High", System.Type.GetType("System.Double")))
DataSet_Obj.Tables("CandleTable").Columns.Add( _
New DataColumn("Low", System.Type.GetType("System.Double")))

DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:00:00")
DataRow_Obj("Low") = 100
DataRow_Obj("Close") = 110
DataRow_Obj("Open") = 120
DataRow_Obj("High") = 130
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:10:00")
DataRow_Obj("Low") = 105
DataRow_Obj("Close") = 115
DataRow_Obj("Open") = 125
DataRow_Obj("High") = 135
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)
DataRow_Obj = Nothing
DataRow_Obj = DataSet_Obj.Tables("CandleTable").NewRow()
DataRow_Obj("Date") = CDate("01/01/2005 10:20:00")
DataRow_Obj("Low") = 120
DataRow_Obj("Close") = 130
DataRow_Obj("Open") = 140
DataRow_Obj("High") = 150
DataSet_Obj.Tables("CandleTable").Rows.Add(DataRow_Obj)

Tag_Serie_Candle = New Steema.TeeChart.Styles.Candle
TChart1.Series.Add(Tag_Serie_Candle)

Tag_Serie_Candle.DataSource = DataSet_Obj.Tables("CandleTable")
Tag_Serie_Candle.OpenValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Open").ToString()
Tag_Serie_Candle.CloseValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Close").ToString()
Tag_Serie_Candle.DateValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Date").ToString()
Tag_Serie_Candle.DateValues.DateTime = True
Tag_Serie_Candle.HighValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("High").ToString()
Tag_Serie_Candle.LowValues.DataMember = DataSet_Obj.Tables("CandleTable").Columns("Low").ToString()
Tag_Serie_Candle.LabelMember = "Test ACTL"
Tag_Serie_Candle.CheckDataSource()
End Sub