Page 1 of 1
Quick control Help - AutomaticMinimum
Posted: Tue Jan 11, 2005 6:09 pm
by 6922017
I have a dataset that records a date/Time and a Value and we have a website that a user can query a date range. TeeChart Graphs a line graph see
http://www.miamiconservancy.org/Water_R ... 01/11/2005
The problem is that the data is received on an event driven basis, so we could have 100 records for a weekend and then for the rest of teh year only have one or so records per day. The cart takes all the values and does not evenly distribut by the date so that a year comprising of 12 months needs to be divided between 12 months or 12 points and not the total number of records evenly spaced. I though the command for that was automaticMinumim, but I tried that and it did not help. We simply want an Even date distribution regardless of the number of records.
Thanks
Jason
Posted: Wed Jan 12, 2005 5:52 pm
by Pep
Hi Jason,
I'm not sure if I understand what you want to do. In case you only want to show one axis label (date-time) for each month you have to set an increment for bottom axis. You can use similar code to the following :
Code: Select all
With TChart1
.Series(0).XValues.DateTime = True
.Axis.Bottom.Increment = TChart1.GetDateTimeStep(dtOneMonth)
.Axis.Bottom.Labels.Style = talValue
.Axis.Bottom.Labels.Angle = 90
.Axis.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy hh:mm"
End With
Posted: Wed Jan 12, 2005 6:40 pm
by 6922017
We need to evenly space the records between dates no matter how many we get for one small time interval. Currently it evenly spaces the records so if we were to get 100 records for July and only 3 in August and September then We would like to have the Axis automatically adjst teh graph so that the dates are spaced with a "spike" in the line graph for July. The query selects all the records between a date range. Here is the code for that page:
<!--METADATA NAME="TeeChart Pro v5 ActiveX Control" TYPE="TypeLib" UUID="{B6C10482-FB89-11D4-93C9-006008A7EED4}"-->
<!-- #include file="../../../MCD-STAFF/Includes/connect.inc" -->
<%
Response.Expires = 60
Response.Clear
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Response.ContentType = "image/jpeg"
Dim Cn2
Set cn2 = Server.CreateObject ("ADODB.Connection")
cn2.Open ConnectionStringAccessToSQL
response.buffer=true
dim h, w, Duration
if isEmpty(request("Duration")) or isNull(request("Duration")) then
Duration = "Daily"
Else
Duration = request("Duration")
End if
datestart = request("datestart")
dateend = request("Dateend")
SensorId = request("SensorID")
if isEmpty(request("SensorID")) or isNull(request("SensorID")) then
datestart = "02/13/2000"
dateend = "02/18/2003"
SensorId = 4980
End if
ChartType = 1
h=350
w=550
Response.BinaryWrite(RunChart)
Function RunChart()
dim img
dim Chart
dim MyVar
'Create Chart
Set Chart = CreateObject("TeeChart.TChart")
'Setup Series
Chart.AddSeries(scLine)
Chart.Series(0).Marks.Visible=flase
Chart.Series(0).Color=vbYellow
Chart.Series(0).HorizontalAxis=10
Chart.Series(0).Name="Level"
Chart.Walls.Left.Transparent=True
Chart.Walls.Left.Color=RGB(35,70,128)
Chart.Aspect.View3D=0 '1 for Yes
Chart.Panel.Gradient.StartColor= RGB(255,255,255)
Chart.Panel.Gradient.EndColor=RGB(255,255,255)
Chart.Axis.Left.Title.Caption="Stage Height (Ft)"
Chart.AddSeries(scLine)
Chart.Series(0).Marks.Visible=False
Chart.Series(0).asLine.LinePen.Width = 1
Chart.Series(0).asLine.Pointer.Draw3D = True
Chart.Series(0).asLine.Pointer.Brush.Color = RGB(34,150,123)
Chart.Legend.Visible=False
Chart.Axis.Bottom.Labels.Angle=90
Chart.Height=h
Chart.Width=w
Chart.Panel.Gradient.Visible=True
Chart.Header.Text(0)="Stage Values"
Chart.Header.Font.Bold=True
Chart.Axis.Bottom.Title.Caption="Date"
Chart.Axis.Bottom.Title.Font.Bold=True
Chart.Axis.Left.Title.Font.Bold=True
Chart.Header.Font.Height=14
Chart.Axis.Left.AutomaticMinimum = True
Set RSt = Server.CreateObject("ADODB.RecordSet")
SQL = "select [Data Value] as Data_Value,[Date/Time] as Date_Time FROM Stage_Data WHERE ([Sensor Id] = '" & SensorID & "') AND ([Data Type] = 'S') "
SQL = SQL & " AND ([Date/Time] > '" & DateStart & "') AND ([Date/Time] < '" & dateEnd & "') ORDER BY [Date/Time] "
If Duration = "" then Duration = "Daily"
'Response.write SQL
'response.write "SQL: " & SQL
'response.flush
RSt.open sql,cn2,1,1
while not rst.eof
Chart.Series(0).Add " " & rst("Data_Value"), rst("Date_Time") ,RGB(34,150,123)
Chart.Series(0).LabelsSource=rst("Date_Time")
rst.movenext
wend
'Cleanup and set Chart to send to browser
Rst.close
Cn2.close
Set Rst=nothing
Set Cn2=nothing
img=Chart.Export.Stream(stJpeg)
'img=Chart.Export.asPNG.SaveToStream
'Chart.Export.Stream(stJpeg)
Set Chart=nothing
RunChart=img
end function
%>
Posted: Fri Jan 14, 2005 10:10 am
by Pep
Hi Jason,
ok, in that case, I think a good example which shows how you can space your data however you like could be the one included into the Demo Features project under :
All Features -> Welcome ! -> Chart Styles -> Financial -> Candle -> Axis labels no WeekEnds.
Posted: Fri Jan 14, 2005 1:01 pm
by 6922017
I am not sure I follow what you are telling me to do. I am looking at my demo files that came with Ver 5 and there appears to be nothing matching what you are telling me to go to. I loaded the Example so maybe you can give me a direct link
http://www.miamiconservancy.org/TeeChar ... SPHome.htm
Thanks
Jason
Posted: Tue Jan 18, 2005 12:45 am
by Pep
Hi Jason,
if you're using the TeeChart Pro v5 you can see the Demo I'm referencing openning the Demo Features project (included in the Teechart installation, also there's a link through Programs->..) under :
Welcome ! -> New Features -> Series -> Candle -> Axis Labels no Weekends
Posted: Wed Jan 19, 2005 6:38 pm
by 6922017
Thanks for your continued help, however I must be completely blind, becuse I still can not find what project you are talking about. There are no shortcuts under the Start > Programs however I CAN go to the folder where it was installed (and there are tons of files and examples) but I can not find anything labled Demo Features. I found a VB exmaple labled Demo, but obviously I am using ASP. I even did a search in the entire install directory and did not find anything. I have the "Example" running on our stire (I posted the link in my last post) Please shed some light. Thanks
Posted: Thu Jan 20, 2005 11:36 am
by narcis
Hi Jason,
Installing TeeChart using the installer it creates an entry in the Start Menu>Programs where you should find this information. However, you can download this demo
here
Posted: Tue Jan 25, 2005 8:26 pm
by 6922017
Thanks again, however I am running TeeChart 5 and this was not installed. I have downloaded the program (thanks) it appears to be a Vb application. When I click to view source it only has a "configure" button. When I click it is says please locate the TeeChart 6 Demo files. Well as you can guess I don't and since this appears to be VB and not VB Script or ASp I am wondering if it will even work. Please advise.
Thanks
Jason
Posted: Wed Jan 26, 2005 3:53 pm
by Pep
Hi Jason,
yes, you could use similar code like the following (VB) :
Code: Select all
Private Sub Check1_Click()
If Check1.Value = 1 Then
AddAsNoWeekend
Else
AddAsDatetime
End If
End Sub
Private Sub Form_Load()
AddAsNoWeekend
End Sub
Private Sub TChart1_OnAfterDraw()
Dim i
If NotDateTime = True Then
With TChart1
' Contain output within Chart rectangle
.Canvas.ClipRectangle .Axis.Left.Position, _
.Axis.Top.Position, _
.Axis.Right.Position, _
.Axis.Bottom.Position
'.Canvas.Font.Bold = True
.Canvas.Font.color = vbYellow
For i = 0 To .Series(0).Count - 1
If Weekday(DateValue(.Series(0).PointLabel(i))) = 2 Then
.Canvas.RotateLabel .Series(0).CalcXPos(i - 1) + ((.Series(0).CalcXPos(i) - .Series(0).CalcXPos(i - 1)) / 2) - 5, .Axis.Bottom.Position - 10, "eg. Weekend", 90
End If
Next i
End With
End If
End Sub
Private Sub AddAsDatetime()
Dim tmpopen, tmp As Integer
' This option simulates a sequential datetime Axis
' Candle Series
NotDateTime = False
TChart1.RemoveAllSeries
TChart1.AddSeries (scCandle)
TChart1.Axis.Bottom.Labels.Angle = 90
With TChart1.Series(0)
.Clear
tmpopen = 1000 + Rnd(100)
For t = 0 To 14
tmp = Int(100 * Rnd - 50)
.asCandle.AddCandle Format(Now - 15, "000000") + t, tmpopen, tmpopen + 20, tmpopen - 20, tmpopen + tmp
tmpopen = tmpopen + tmp
Next t
End With
End Sub
Private Sub AddAsNoWeekend()
'Create an array of example dates
Dim myDates(14) As Variant
Dim StartDate As Date
' If this were to have a database datasource it would be simpler
' as you could use Series(xx).LabelsSource
' If using ADO Recordset the following principle would apply, replacing the
' Array with a step-through the Recordset
NotDateTime = True
StartDate = Now - 15
For i = 0 To 13
While (Weekday(StartDate) = 1) Or (Weekday(StartDate) = 7)
StartDate = StartDate + 1
Wend
myDates(i) = Format(StartDate, "d-mmm-yyyy")
StartDate = StartDate + 1
Next i
TChart1.RemoveAllSeries
TChart1.AddSeries scCandle
With TChart1.Series(0)
.XValues.DateTime = False
.Clear
tmpopen = 1000 + Rnd(100)
For t = 0 To 8
tmp = Int(100 * Rnd - 50)
.asCandle.AddCandle 1 + t, tmpopen, tmpopen + 20, tmpopen - 20, tmpopen + tmp
.PointLabel(t) = myDates(t)
tmpopen = tmpopen + tmp
Next t
End With
End Sub
In a web application using VBScript the use of the TChart1_OnAfterDraw() event is a little more complicated and cannot be used in the same manner. To work around this you will have to use the technique descibed in ASP Server examples in the example called "Page showing 4 different export formats" - the first of these, the TeeChart Native Tee template one, has text written to its left axis. The code that does this can be seen in the compareOutput.inc file under C:\Inetpub\wwwroot\TeeChart5.