Help
I'm trying to display information about specific points a chart by using the SeriesClick event. I can display values for any series[x].YValues attribute but the minute I try to display the value of the XValues attribute I get the following error:
Invalid cast from Double to DateTime.
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.InvalidCastException: Invalid cast from Double to DateTime.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidCastException: Invalid cast from Double to DateTime.]
System.Double.System.IConvertible.ToDateTime(IFormatProvider provider) +72
System.Convert.ToDateTime(Double value) +51
NMBNTS03SPC._Default.WebChart1_ClickSeries(Object sender, Series s, Int32 valueIndex, EventArgs e) in c:\documents and settings\jholmes\vswebcache\uk501701o\nmbnts03spc\default.aspx.cs:159
Steema.TeeChart.Web.WebChart.Steema.TeeChart.IChart.DoClickSeries(Object sender, Series s, Int32 valueIndex, MouseEventArgs e) +36
Steema.TeeChart.Chart.DoMouseDown(Boolean IsDoubleClick, MouseEventArgs e) +358
Steema.TeeChart.Web.WebChart.CreatePictureFile(HtmlTextWriter writer) +568
Steema.TeeChart.Web.WebChart.Render(HtmlTextWriter output) +10
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1929
I have tried the following:
private void WebChart1_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, System.EventArgs e)
{
Steema.TeeChart.Chart tChart=((WebChart)sender).Chart;
lblProduct.Text = tChart.Series[4].YValues[valueIndex].ToString("0");
lblActual.Text = tChart.Series[0].YValues[valueIndex].ToString("0.00");
lblTarget.Text = tChart.Series[1].YValues[valueIndex].ToString("0.00");
lblUSL.Text = tChart.Series[2].YValues[valueIndex].ToString("0.00");
lblLSL.Text = tChart.Series[3].YValues[valueIndex].ToString("0.00");
lblTime.Text = Convert.ToDateTime(tChart.Series[4].XValues[valueIndex]).ToString();
}
Any assistance would be greatly appreciated.
Jim
System.InvalidCastException:Invalid cast from Double to Date
-
- Newbie
- Posts: 10
- Joined: Fri Nov 15, 2002 12:00 am
- Location: Scotland
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Jim,
Instead of:
Try:
Instead of:
Code: Select all
lblTime.Text = Convert.ToDateTime(tChart.Series[4].XValues[valueIndex]).ToString();
Code: Select all
lblTime.Text = DateTime.FromOADate(tChart.Series[4].XValues[valueIndex]).ToLongDateString();
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
-
- Newbie
- Posts: 10
- Joined: Fri Nov 15, 2002 12:00 am
- Location: Scotland