Hi,
I want to plot a collection of double values against date time. Is it possible to specify the data source property of a series rather than making use of the add or add range function?(Because i have some bulk data to plot in series, about 1 sec interval data of 8 hours).
I was able to plot a collection of y values against its index by specifying data source as a collection. But i want to plot it against date time.
Is there any simple way rather than adding each element.
Thanks,
Vijay.
How to specify data source with datetime values.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Vijay,
Yes, you can find an example of datasource using DateTime values here.
I also recommend you to read Tutorial8 - ADO.NET Database Access. You'll find the tutorials at TeeChart's program group.
Yes, you can find an example of datasource using DateTime values here.
I also recommend you to read Tutorial8 - ADO.NET Database Access. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hello Narcís,
For example,
public class Data
{
public double Value { get; set; }
public DateTime Time { get; set; }
public string Unit { get; set; }
}
public class Values : Collection<Data>
{
//
}
I have created an object of Values class and added some Data objects to it.
In tchart. is it possible to bind these Values instance like this,
tChart.Series[0].XValues.DateTime = true;
tChart.Series[0].XValues.DataMember = "Time";
tChart.Series[0].YValues.DataMember = "Value";
tChart.Series[0].DataSource = values;
I was able to bind it but i was forced to implement IConvertible in Data class.
But in real scenario, my Data object does not implement IConvertible (It is of a third party). Any solution?
For example,
public class Data
{
public double Value { get; set; }
public DateTime Time { get; set; }
public string Unit { get; set; }
}
public class Values : Collection<Data>
{
//
}
I have created an object of Values class and added some Data objects to it.
In tchart. is it possible to bind these Values instance like this,
tChart.Series[0].XValues.DateTime = true;
tChart.Series[0].XValues.DataMember = "Time";
tChart.Series[0].YValues.DataMember = "Value";
tChart.Series[0].DataSource = values;
I was able to bind it but i was forced to implement IConvertible in Data class.
But in real scenario, my Data object does not implement IConvertible (It is of a third party). Any solution?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi vijay,
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Why? Could you please send us a full example project we can run "as-is" to reproduce the problem here?I was able to bind it but i was forced to implement IConvertible in Data class.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
vijay,
The ToDouble overload here is the ToDouble(object value), the source of which looks like this:
Here you can see that the value has to implement the IConvertible interface.
So, the only thing you can do, I'm afraid, is to iterate through the members of your Value class and add them into TChart using the Series.Add(...) overloads in the normal way, e.g.
No, if you can't modify your Data object then you won't be able to get this to work. As your Values class implements IList, it is added to the chart in the overload Steema.TeeChart.Styles.Series.Add(IList list), the source of which looks like this:vijay wrote:If i didn't implement IConvertible it will throw an exception
"Unable to cast Data to IConvertible"
Code: Select all
public void Add(IList list)
{
for (int t = 0; t < list.Count; t++)
Add(Convert.ToDouble(list[t]));
}
Code: Select all
public static double ToDouble(object value)
{
if (value != null)
{
return ((IConvertible) value).ToDouble(null);
}
return 0.0;
}
So, the only thing you can do, I'm afraid, is to iterate through the members of your Value class and add them into TChart using the Series.Add(...) overloads in the normal way, e.g.
Code: Select all
tChart1.Series.Add(fastLine);
this.GetData();
Data[] array = values.ToArray<Data>();
foreach (Data d in array)
{
tChart1.Series[0].Add(d.Time, d.Value);
}
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/