2016-05-10 5 views
0

Я пытаюсь создать гистограмму, но имею ее горизонтально ориентированную. Пока я могу сделать его вертикальным только со следующим кодом. Я копал вокруг, а человеческие источники показывали только вертикальную ориентацию. Есть ли способ Изменение ориентации диаграммы в Excel VBA

Sub test_tic_count_graph() 

    Dim chtTicCount As chart 
    Dim ticCountGraph As Worksheet 

    Set ticCountGraph = ActiveWorkbook.Sheets("ticCountGraph") 
    Set chtTicCount = ticCountGraph.Shapes.AddChart(xlColumnClustered).chart 

    With chtTicCount 

        .SetSourceData Source:=ticCountGraph.Range("A1:B9") 


        ''Activating the xlValue so we can refer to x-y values. 
        .HasAxis(xlValue, xlPrimary) = True 
        .HasAxis(xlValue, xlSecondary) = True 

        .Legend.Font.Size = 10 
        '' Sets legend position 100 points from top. 
        .Legend.Top = 100 


        ''Label the X - axis. Note it's xlCategory. 
        With .Axes(xlValue, xlPrimary) 
         .HasTitle = True 
         .AxisTitle.Text = "DEVICE" 
         .AxisTitle.Font.Size = 10 

         '' Modify tickmark labels font size. 
         .TickLabels.Font.Size = 10 

        End With 

        '' Label the Y - axis. Note it's xlValue. 
        With .Axes(xlCategory, xlPrimary) 
         .HasTitle = True 
         ''.AxisTitle.Text = "CPU %" 
         .AxisTitle.Font.Size = 10 
         .TickLabels.Font.Size = 10 
         ''.MaximumScale = 1 

        End With 

      End With 

    End Sub 

ответ

0

xlColumnClustered это значение ChartType свойство для вертикальных полос. Вы, вероятно, хотите xlBarClustered для горизонтальных баров.