Candle Series


Q: How can I remove weekends on Candle ODBC database Charts?


Don't select your table "Date" field in "Date" combobox of the database (or Dataset etc. in v5) datasource tab for the Candle Series. This will assign a different X value for each point (instead of the candle datetime value): 1,2,3,4,5,6.....

To set your date labels, select your table "Date" field in the "Labels" combobox in the datasource tab.


Q: How can I remove weekends programmatically?


The concept is essentially the same as that of the technique mentioned above in the sense that the X values for each point are changed from date values (i.e. values of the data Series) to numeric values (i.e. Series points). To do this programmatically first we have to set the XAxis DateTime to false:


TChart1.Series(0).XValues.DateTime = False
		

You should now configure the XAxis so that it displays Series points. Probably the easiest way to do this is by changing the Label Style property:


TChart1.Axis.Bottom.Labels.Style = talMark
		

From here you have two options, both of which assume that one of the fields in your database table contains the dates you want to publish, i.e. dates with the weekends already removed. The first option is to use the PointLabel property (here we're using ADO to bring data from the TeeChart Pro Database into the chart):


With Record
  .MoveFirst
  While Not .EOF
    TChart1.Series(0).Add .Fields("Salary"), .Fields("LastName"), clTeeColor
    TChart1.Series(0).PointLabel(t) = .Fields("Birth_Date")
    t = t + 1
    .MoveNext
  Wend
End With
	

The second option is to change the XAxis labels using the OnGetAxisLabel() event:


Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
If Axis = atBottom Then
With TChart1
  If .SeriesCount > 0 Then
    If .Series(0).Count > 0 Then
      If ValueIndex <> -1 Then
        LabelText = LabelLocations(ValueIndex)
      End If
    End If
  End If
 End With
End If
End Sub	

In this instance we have copied the data field into the global array LabelLocations to avoid having to open the database a second time.