Powerpoint Chart中的多级轴 [英] Multi level axis in Powerpoint Chart
问题描述
我正在创建一个VSTO加载项,其中包括为某些年度数据创建折线图。该数据每周包含数据点。我希望横轴可以按月分组。此链接说明了分组: https://www.pdastats.com/news/archives/750
I'm creating a VSTO add-in that among other things is supposed to create a line chart for some annual data. This data contains datapoints on a weekly basis. I would like the horizontal axis to be grouped in months. This link llustrates the grouping: https://www.pdastats.com/news/archives/750
但是我找不到任何东西关于这是否可能的VSTO文件。据我所知,系列只需要为X轴采用一维数值。有没有人有这方面的经验?
I can't however find anything in the VSTO documentations about whether this is possible or not. As far as I can tell a Series only takes a 1-dimensional array of values for the X-axis. Does anyone have any experience with this?
推荐答案
你好,
这是VBA代码:
Sub CreateChart()
Dim myChart As Chart
Dim gChartData As ChartData
Dim gWorkBook As Excel.Workbook
Dim gWorkSheet As Excel.Worksheet
' Create the chart and set a reference to the chart data.
Set myChart = ActivePresentation.Slides(1).Shapes.AddChart.Chart
myChart.ChartType = xlLine
Set gChartData = myChart.ChartData
' Set the Workbook and Worksheet references.
Set gWorkBook = gChartData.Workbook
Set gWorkSheet = gWorkBook.Worksheets(1)
' Add the data to the workbook.
gWorkSheet.ListObjects("Table1").Resize gWorkSheet.Range("A1:C13")
gWorkSheet.Range("Table1[[#Headers],[Series 1]]").Value = "X"
gWorkSheet.Range("A2").Value = "2015"
gWorkSheet.Range("A3:A7").ClearContents
gWorkSheet.Range("A8").Value = "2016"
gWorkSheet.Range("A9:A13").ClearContents
gWorkSheet.Range("B2").Value = "7/15/2015"
gWorkSheet.Range("B3").Value = "8/15/2015"
gWorkSheet.Range("B2:B3").AutoFill Destination:=gWorkSheet.Range("B2:B13")
gWorkSheet.Range("B2:B13").NumberFormat = "d-mmm"
gWorkSheet.Range("Table1[[#Headers],[Series 2]]").Value = "Y"
gWorkSheet.Range("C2").Value = "100"
gWorkSheet.Range("C3").Value = "150"
gWorkSheet.Range("C2:C3").AutoFill Destination:=gWorkSheet.Range("C2:C13")
myChart.SeriesCollection(1).Delete
myChart.FullSeriesCollection(1).Values = "=Sheet1!
C
2:
这篇关于Powerpoint Chart中的多级轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!