GroupingUnit Property

Microsoft Office Web Components Visual Basic

expression.GroupingUnit

expression    Required. An expression that returns a ChAxis object.

Example

This example converts the first chart in Chartspace1 to a line chart, then formats the category axis so that the values are grouped by month. The average value of each month is displayed on the chart.

Sub FormatTimeScaling()

    Dim chConstants
    Dim axCategory

    Set chConstants = ChartSpace1.Constants

    ' Change the chart to a Line chart.
    ChartSpace1.Charts(0).Type = chConstants.chChartTypeLine

    ' Set a variable to the category axis.
    Set axCategory = ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionCategory)

    ' Specify that you will determine the grouping settings of the
    ' axis. Note that this line of code is necessary only if the
    ' GroupingType property for the axis has been previously set to
    ' chAxisGroupingNone.
    axCategory.GroupingType = chConstants.chAxisGroupingManual

    ' Group the category axis by month.
    axCategory.GroupingUnitType = chConstants.chAxisUnitMonth

    ' Create a new grouping for every month.
    axCategory.GroupingUnit = 1

    ' Display the average of the items in each group.
    axCategory.GroupingTotalFunction = chConstants.chFunctionAvg

    ' A tick label is displayed for every month.
    axCategory.TickLabelUnitType = chConstants.chAxisUnitMonth

    ' A tick mark is displayed for every three months.
    axCategory.TickMarkUnitType = chConstants.chAxisUnitQuarter

End Sub