Page 1 of 1

manually adding data to series with dates along the X Axis

Posted: Wed Nov 08, 2006 1:10 pm
by 9637403
I need to be able to add bars to an error bar series where my x axis is a date so I need an add method like

Code: Select all

errorbar.add(x as date,y as double,errorvalue as double,text as string,colour as System.Drawing.Color)
there doesn't appear to be one... closest I can find is

Code: Select all

errorbar.add(x as double,y as double,errorvalue as double,text as string,colour as System.Drawing.Color)
which means I'll need to create a string for my date and convert my date into a double... this will be a real pain...

There are a number of series types that do not appear to allow dates, bubble is another one, if I have a date along the xaxis I can;t specify the radius...

is this an oversight or is there another way to add the data I need?

Posted: Wed Nov 08, 2006 4:50 pm
by narcis
Hi Adrian,

You don't need to convert a date to a double manually, you can use DateTime.Parse method like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			Random val = new Random();

			errorBar1.Add(DateTime.Parse("1/1/2007"), val.Next(), "First Bar", Color.Red);
			errorBar1.Add(DateTime.Parse("2/1/2007"), val.Next(), "Second Bar", Color.Blue);
			errorBar1.Add(DateTime.Parse("3/1/2007"), val.Next(), "Third Bar", Color.Yellow);

			tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Value;			
		}

Posted: Fri Nov 10, 2006 12:49 am
by 9637403
I think you have missed my point.

Here is another example.

I want to create a arrow chart. I have a data table with 4 columns

startdate,startusers,enddate,endusers

startdate and enddate are date types, startusers and endusers are of type double.

I want an arrow pointing from point (startdate,startusers) to point (enddate,endusers).

There isn't an ADD method that allows

date,double,date,double

Posted: Fri Nov 10, 2006 9:06 am
by narcis
Hi Adrian,
I think you have missed my point.


If I'm not wrong you asked for that:
I need to be able to add bars to an error bar series where my x axis is a date so I need an add method like

Code:

errorbar.add(x as date,y as double,errorvalue as double,text as string,colour as System.Drawing.Color)
In my humble opinion, my previous message replied to that request. However now you say:
I want to create a arrow chart. I have a data table with 4 columns

startdate,startusers,enddate,endusers

startdate and enddate are date types, startusers and endusers are of type double.

I want an arrow pointing from point (startdate,startusers) to point (enddate,endusers).
Could you please let me know the exact series style you wish to use for your chart and we'll try to give an answer to your request?

Thanks in advance.

Posted: Fri Nov 10, 2006 11:26 pm
by 9637403
Hi there,
There are several series which do not cater for adding the key values in a single ADD method. ERRORBAR is just one example, i.e. there is no ADD method of the following signature.

Code: Select all

errorbar.add(x as date,y as double,errorvalue as double,text as string,colour as System.Drawing.Color) 
BUBBLE is another one that I have to code around like

Code: Select all

iPoint = serBubble.Add(row(XValueName), CDbl(row(YValueName)))

serBubble.RadiusValues.Item(iPoint) = row(Radius)  ' add the radius
In this case I have to add the radius in separately to the initial add because there is no ADD method that allows a DATE and the radius.

I'm loading the data from a data table where the X column is of type DATETIME.

Alternatively I can use a statement like

Code: Select all

If TypeOf row(StartXValues) Is Date Then
   dStartXValues = row(StartXValues).tooadate
Else
   dStartXValues = row(StartXValues)
End If

iPoint = serArrow.Add(dStartXValues, dStartYValues, dEndXValues, dEndYValues)
Which converts the date to a double first... this is what I meant by converting the date.

I'm using tCHART in a generic reporting tool so I have very little idea or control of what my users want to include in their charts... It would be a great idea it ALL series types with X and Y axis allow ALL numeric types on both X and Y as well as DATE time types and allows specification of the other key metrics (such as Radius for the bubble etc.) in a single ADD method.

In the short term I've figured out ways to code around the problems I'm having.

Cheers..

Posted: Mon Nov 13, 2006 9:49 am
by narcis
Hi Adrian,

Have you looked to all bubble series add method overloads? There are a number of them which admit radius as a parameter. Regarding the DateTime values to double you can do something like this:

Code: Select all

			bubble1.XValues.DateTime = true;

			bubble1.Add(DateTime.Parse("1/1/2007").ToOADate(), 2, 5);
			bubble1.Add(DateTime.Parse("1/2/2007").ToOADate(), 3, 3);
			bubble1.Add(DateTime.Parse("1/3/2007").ToOADate(), 4, 1);	
This code snippet converts DateTime values to double using ToOADate method a double y value and a double radius.