ChartLayout Property

Microsoft Office Web Components Visual Basic

Returns or sets the layout for all the charts in the specified chart workspace. Read/write ChartChartLayoutEnum .

expression.ChartLayout

expression    Required. An expression that returns a ChartSpace object.

Because the chart workspace can contain one or more charts, you can use both the ChartLayout and ChartWrapCount properties to specify how multiple charts are positioned. The ChartLayout property makes it possible to create custom chart arrangements, such as three charts positioned horizontally in a single row.

There are two distinct layout types for charts:

ChChartLayoutHorizontal    Charts are positioned horizontally from left to right until the number of charts specified by the ChartWrapCount property is reached. When this occurs, a new row is created below the active row and the positioning process begins again at the left. This method continues (wrapping every ChartWrapCount number) until all charts have been placed.

ChChartLayoutVertical    Charts are positioned vertically from top to bottom until the number of charts specified by the ChartWrapCount property is reached. When this occurs, a new column is created to the right of the active column and positioning begins again at the top. This method continues (wrapping every ChartWrapCount number of charts) until all charts have been placed.

Example

This example sets the ChartWrapCount and ChartLayout properties and then adds six additional charts to the specified chart workspace.

Sub AddCharts()
    Dim chtChart
    Dim chConstants
    Dim iCtr
     
    Set chConstants = ChartSpace1.Constants
    
    ' Set the chart workspace so that a row or column
    ' of charts is created for every two charts
    ' in the chart workspace.
    ChartSpace1.ChartWrapCount = 2
    
    ' Set the chart workspace so that the charts are laid our horizontally.
    ' Since this code adds six charts to the chart workspace and the 
    ' ChrtWrapCount property has been set to wrap every two charts,
    ' then the code results in three rows of two charts.
    ChartSpace1.ChartLayout = chConstants.chChartLayoutHorizontal
    
    For iCtr = 1 To 6
        ' Add a chart to the chart workspace.
        Set chtChart = ChartSpace1.Charts.Add
        
        ' Enable the chart title.
        chtChart.HasTitle = True
        
        ' Add a title to the chart that indicates the order
        ' in which the chart was created.
        chtChart.Title.Caption = "Chart # " & iCtr
        
        ' Specify that the chart is to be a line chart.
        chtChart.Type = chConstants.chChartTypeLine        
    Next
End Sub