Hi again
I have pasted my code in. What I am trying to do is... calculate the
interval between the first date and last date in the record set and
scale the x-axis accordingly.
so for example.. if the dates span only 30days.. then you scale the
x-axis by days. If the interval is.. say over 90 days..then scale by
months
Private Sub SetLineChartTimeScale(ByVal objDataTable As
DataTable, ByRef objChartSpace As
AxMicrosoft.Office.Interop.OWC.AxChartSpace)
'objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionBottom).NumberFormat
= "short date"
objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionBottom).NumberFormat
= "[$-F800]dddd, mmmm dd, yyyy"
'--------------------------------------------------------------------------
' Work out the span of the data
'--------------------------------------------------------------------------
Dim dteFirst As DateTime
Dim dteLast As DateTime
clsHistogram.GetDatasetSpanDates(Me.Isbasic, objDataTable,
dteFirst, dteLast)
'--------------------------------------------------------------------------
' Calculate the difference between the two dates
'--------------------------------------------------------------------------
Dim intInterval As Long
intInterval = DateDiff(DateInterval.Day, dteFirst,
dteLast)
'--------------------------------------------------------------------------
' Depending on the Interval scale the axis
'--------------------------------------------------------------------------
Dim objLabelTickUnitType As
Microsoft.Office.Interop.OWC.ChartAxisUnitTypeEnum
Dim objMarkUnitType As
Microsoft.Office.Interop.OWC.ChartAxisUnitTypeEnum
'--------------------------------------------------------------------------
' Set the max/min values
'--------------------------------------------------------------------------
'objChartSpace.Charts(0).Axes(0).Scaling.Maximum =
dteLast.ToLocalTime.ToOADate
'objChartSpace.Charts(0).Axes(0).Scaling.Minimum =
dteFirst.ToLocalTime.ToOADate
If intInterval <= 31 Then
'--------------------------------------------------------------------------
' If the data spans less than a month scale by days
'--------------------------------------------------------------------------
objLabelTickUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitDay
objMarkUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitDay
ElseIf intInterval > 31 And intInterval < 210 Then
'--------------------------------------------------------------------------
' If the data spans more than a month and less than
half a year scale by weeks
'--------------------------------------------------------------------------
objLabelTickUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitWeek
objMarkUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitWeek
ElseIf intInterval < 750 And intInterval > 180 Then
'--------------------------------------------------------------------------
' If the data spans 2 years allow it be scaled in
months
'--------------------------------------------------------------------------
objLabelTickUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitMonth
objMarkUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitMonth
Else
'--------------------------------------------------------------------------
' Anything larger scale by years
'--------------------------------------------------------------------------
objLabelTickUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitYear
objMarkUnitType =
OWC10.ChartAxisUnitTypeEnum.chAxisUnitYear
End If
If intInterval > 0 Then
'--------------------------------------------------------------------------
' Set the scale of the axis
'--------------------------------------------------------------------------
objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionCategory).TickLabelUnitType
= objLabelTickUnitType
objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionCategory).TickMarkUnitType
= objMarkUnitType
'--------------------------------------------------------------------------
' Set the label ticks to show each singular readings
'--------------------------------------------------------------------------
objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionCategory).GroupingUnitType
= OWC10.ChartAxisUnitTypeEnum.chAxisUnitDay
objChartSpace.Charts(0).Axes(OWC10.ChartAxisPositionEnum.chAxisPositionCategory).GroupingUnit
= 1
End If
End Sub
any help would be apprecaited. THanks