LabelSource (Formatting Problem)
Posted: Mon Jan 19, 2004 10:06 pm
What I am doing is graphing data out of a very large ADO Recordset.
In this program you can graph multiple Y – Axis’s on the Left and Right Axis. The X-Axis (bottom) value is always based off of Date/Time but the labels for the X-Axis could be either Date/Time Based or Based off of another Fields value. I am currently setting the LabelSource property to another field besides time in the Recordset. The field in the Recordset is declared as a single but the value is formatted in the Database to only two decimal places. When I graph this out the Labels on the X-Axis have like 12 Decimal places and I can not format them down to two decimal places. If the Value in the Recordset /Database is a whole number but still declared as a single then the labels come out like they should with no decimal places.
By the way I even went into the database and manually formatted the channels to 2 decimal places before I loaded it into the chart and it still did the same thing. For some reason it does not like labels that are assigned as values with decimal places.
Here is some sample code
Left Axis
MainForm.TChart1.Axis.Bottom.Labels.Style = taltext ‘ Only if it is not Date/Time on X-Axis Labels
MainForm.TChart1.AddSeries (scFastLine)
With MainForm.TChart1.Series(SeriesCount - 1)
.DataSource = MainForm.AdodcDataViewer.Recordset
.Active = True
.VerticalAxis = aRightAxis
.DatasourceType = dstAllRecords
.asFastLine.DrawAllPoints = False
.ColorEachPoint = False
.XValues.Order = loNone
.YValues.Order = loNone
' check to see if it is time based or not
If StrComp(XAxisName, "TimeStamp", vbTextCompare) = 0 Then
.XValues.DateTime = True
Else
.XValues.DateTime = False
End If
.YValues.ValueSource = ChannelCollection(i).ChannelName (Field In Recrordset)
.XValues.ValueSource = "TimeStamp" ' (Field In Recordset)
.LabelsSource = XAxisName ' (Field in recordset not Date/Time)
end
Thanks for all of your help,
Craig MacLeod
In this program you can graph multiple Y – Axis’s on the Left and Right Axis. The X-Axis (bottom) value is always based off of Date/Time but the labels for the X-Axis could be either Date/Time Based or Based off of another Fields value. I am currently setting the LabelSource property to another field besides time in the Recordset. The field in the Recordset is declared as a single but the value is formatted in the Database to only two decimal places. When I graph this out the Labels on the X-Axis have like 12 Decimal places and I can not format them down to two decimal places. If the Value in the Recordset /Database is a whole number but still declared as a single then the labels come out like they should with no decimal places.
By the way I even went into the database and manually formatted the channels to 2 decimal places before I loaded it into the chart and it still did the same thing. For some reason it does not like labels that are assigned as values with decimal places.
Here is some sample code
Left Axis
MainForm.TChart1.Axis.Bottom.Labels.Style = taltext ‘ Only if it is not Date/Time on X-Axis Labels
MainForm.TChart1.AddSeries (scFastLine)
With MainForm.TChart1.Series(SeriesCount - 1)
.DataSource = MainForm.AdodcDataViewer.Recordset
.Active = True
.VerticalAxis = aRightAxis
.DatasourceType = dstAllRecords
.asFastLine.DrawAllPoints = False
.ColorEachPoint = False
.XValues.Order = loNone
.YValues.Order = loNone
' check to see if it is time based or not
If StrComp(XAxisName, "TimeStamp", vbTextCompare) = 0 Then
.XValues.DateTime = True
Else
.XValues.DateTime = False
End If
.YValues.ValueSource = ChannelCollection(i).ChannelName (Field In Recrordset)
.XValues.ValueSource = "TimeStamp" ' (Field In Recordset)
.LabelsSource = XAxisName ' (Field in recordset not Date/Time)
end
Thanks for all of your help,
Craig MacLeod