ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Graphics with dates
Posted by glory82 on Mar-17-2011 07:04
hello,

I need to do a graphics that show me dates.  In the yAxis, in format h:m:s (20:00:01) and a number in XAxis and the data to graph are date in format h:m:s (20:00:01).

How can I do that?

Thanks for you help.

  Re: Graphics with dates
Posted by Peter Kwan on Mar-17-2011 17:03
Hi glory82,

You just need to use dates as the x and y coordinates, and use Axis.setLabelFormat to format the axis label. For example:

Set layer = c.addLineLayer(anArrayOfDates, ...)
Call layer.setXData(anotherArrayOfDates)

Call c.xAxis().setLabelFormat("{value|hh:nn:ss}")
Call c.yAxis().setLabelFormat("{value|hh:nn:ss}")

Hope this can help.

Regards
Peter Kwan

  Re: Graphics with dates
Posted by glory82 on Mar-19-2011 07:28
Hi,

Thank for your answer, but the format it doesn't work because the page show me this error in the code of the graphic:

"ChartDirector error '800a8000'
Error converting argument 1 to type class DoubleArray
"
This is the code for the vector:
Re dim DataFechaInf(12)
DataFechaInf(a) =  hour(FechaProySup)&":"&minute(FechaProySup)&":"&second(FechaProySup)

I dont know what can I do.

Thanks for you help.

  Re: Graphics with dates
Posted by Peter Kwan on Mar-19-2011 12:12
Hi glory82,

Note that anArrayOfDates mean an array containing dates. A date means a date as according to the VB/VBScript language syntax. For your case, you are using text strings (the "&" operating is the text string concatenation operator), not a date.

In fact, it seems FechaProySup in your code is a date. Why do you just simply use:

DataFechaInf(a) = FechaProySup

If the above still does not solve the problem, would you mind to inform me of your charting code, so that I know how your chart is configured and which line generates the error.

Regards
Peter Kwan

  Re: Graphics with dates
Posted by glory82 on Mar-26-2011 05:29
Attachments:
Hi,

Thanks for your answer. I could show the hours in format h:m:s
(Call c.yAxis().setLabelFormat("{value|hh:nn:ss}"))

However, I need to show in the y axis, all the hours (0:00 to 23:00). I dont understand why the graphic show me just some dates.

I send the code and the print screen with the graphic and the datas that I want to graphic.

Thanks for you help.
graphic.JPG
dates graphics code.txt
'*************************************CREACION DEL GRAFICO PROYECCION POR PUNTO******************************	
	Set cd = CreateObject("ChartDirector.API")
	
	'------Create an XYChart object of size 600 x 300 pixels, with a light blue (EEEEFF)-----
	'------background, black border, 1 pxiel 3D border effect and rounded corners-----------
	Set c = cd.XYChart(770, 470, &Heeeeff, &H000000, 1)
	Call c.setRoundedFrame()
						
	'------Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white background.----
	'------Turn on both horizontal and vertical grid lines with light grey color (0xcccccc)-----
	Call c.setPlotArea(80, 58, 600, 350, &Hffffff, -1, -1, &Hcccccc, &Hcccccc)
						
	'------Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 9 pts----
	'------Arial Bold font. Set the background and border color to Transparent.-----------
	Call c.addLegend(50, 30, False, "arialbd.ttf", 9).setBackground(cd.Transparent)
						
	'------Add a title box to the chart using 15 pts Times Bold Italic font, on a light blue---
	'------(CCCCFF) background with glass effect. white (0xffffff) on a dark red (0x800000)----
	'------background, with a 1 pixel 3D border.---------------------------------------------
	Call c.addTitle("PROYECCION DE CICLO COCINAS", "timesbi.ttf", 15).setBackground(&Hccccff, &H000000, cd.glassEffect())
					
	'-------Add a title to the y axis------------
	Call c.yAxis().setTitle("Fecha")
		
	'-------Add a title to the x axis-----------
	Call c.xAxis().setTitle("Cto")
				
	'-------Display 1 out of 3 labels on the x-axis.----
	Call c.xAxis().setLabelStep(1)
						
	'-------Add a line layer to the chart-----------
	Set layer = c.addLineLayer2()
						
	'---------Set the default line width to 2 pixels-------
	Call layer.setLineWidth(2)
	
	'---------Set the labels on the x axis by spreading the labels evenly between the first point-----
	'---------(index = 0) and the last point (index = noOfPoints - 1)-------------
	'Call c.yAxis().setLinearScale(0,23,1)

	'--------Add the three data sets to the line layer. For demo purpose, we use a dash line-----
	'--------color for the last line-----------
	'--------Add the first line. Plot the points with a 7 pixel square symbol-----------
	' Add the first line. Plot the points with a 7 pixel square symbol
	Call layer.addDataSet(DataFechaSup, &Hcf4040, "Limite Sup")
	'Call layer.addDataSet(DataFechaTar, &H008800, "Target")
	'Call layer.addDataSet(DataFechaInf, &H3333ff, "Limite Inf")
	
	'-------Set the labels on the x axis.--------
	Call c.xAxis().setLabels(DataCto)
	Call c.yAxis().setLabelFormat("{value|hh:nn:ss}")
									
	'---------Output the chart----------
	chart2URL = c.makeSession(Session, "chart2")

  Re: Graphics with dates
Posted by Peter Kwan on Mar-26-2011 15:23
Hi glory82,

The graph shows you a limited time range, because your data are with a limited time range. For example, if your data are from 3/24/2011 17:00:00 to 3/25/2011 04:00:00, the the y-axis will only show that time range. It will not automatically show other time. For example, it will not automatically show the date/time for 3/11/2011 12:00:00 because it is not within the date/time range of your data.

Because you ask ChartDirector for format the axis label as hh:nn:ss, so it would not show the date part in the axis labels.

If you want to include date/time not in your data, you may use Axis.setDateScale to configure the axis range. For example, if you want to show from 3/24/2011 12:00:00 to 3/25/2011 12:00:00, you may use:

startTime = DateSerial(2011, 3, 24) + TimeSerial(12, 0, 0)
endTime = DateSerial(2011, 3, 25) + TimeSerial(12, 0, 0)

Call c.yAxis().setDateScale(startTime, endTime)

Hope this can help.

Regards
Peter Kwan

  Re: Graphics with dates
Posted by glory82 on Mar-29-2011 05:53
Hi,

Thank for your help.

A last question:
The code that you send me, show me the time every 2 hours. How can I do for show the time every 1 hour?

Thank for all your help.

  Re: Graphics with dates
Posted by Peter Kwan on Mar-30-2011 01:33
Hi glory82,

Please use:

Call c.yAxis().setDateScale(startTime, endTime, 86400)

The axis will now have a tick every 86400 seconds (1 hour = 86400 seconds).

Hope this can help.

Regards
Peter Kwan