[Solved] Create Chart Using Data From Rows
Posted: Fri Jun 18, 2021 5:35 pm
Hello,
I am trying to create a macro that produces a series of charts on a large dataset. I am not very experienced so I tried adapting the sample code from https://wiki.openoffice.org/w/images/e/ ... o3.0.0.pdf which is
and I think this can get me what I need pretty much everything I need, except that the data is brought in from the columns instead of the rows, producing a bunch of short lines on the graph instead of one long one. I cannot change the format of the dataset because that data is copy/pasted in by multiple people. I have tried reading the IDL reference and my attempts at implementation failed.
Thanks in advance for your help.
I am trying to create a macro that produces a series of charts on a large dataset. I am not very experienced so I tried adapting the sample code from https://wiki.openoffice.org/w/images/e/ ... o3.0.0.pdf which is
Code: Select all
Dim Doc As Object
Dim Charts As Object
Dim Chart as Object
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
Doc = StarDesktop.CurrentComponent
Charts = Doc.Sheets(0).Charts
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 8
RangeAddress(0).EndRow = 1
Charts.addNewByName("MyChart", Rect, RangeAddress(0), True, True)
Chart = Charts.getByName("MyChart").embeddedObject
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
Chart.Diagram.Wall.FillColor = RGB(255,255,255)
Chart.Diagram.HasXAxisGrid = True
Chart.Diagram.HasYAxisGrid = True
Chart.Diagram.YAxis.Min = 0
Chart.Diagram.YAxis.Max = 100
Chart.Diagram.HasXAxisTitle = True
Chart.diagram.XAxisTitle.String = "Tests"
Thanks in advance for your help.