How to set data series in rows programmingly?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
winchell
Posts: 10
Joined: Thu Mar 31, 2022 5:45 am

How to set data series in rows programmingly?

Post by winchell »

Hi i am new to libre office, currently, i am working on a chart generation task.
I want to use row as data series, please check the attchment.

But how can i do it in code like C#?
Attachments
Capture.PNG
Capture.PNG (9.26 KiB) Viewed 769 times
OpenOffice 7.3 on Windows 10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to set data series in rows programmingly?

Post by FJCC »

Here is some OpenOffice Basic code that makes a chart with two data series in the range C2:I8 on the first sheet.

Code: Select all

Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
Dim Rect As New com.sun.star.awt.Rectangle

Rect.X = 100 
Rect.Y = 200 
Rect.Width = 18000
Rect.Height = 9000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 2
RangeAddress(0).StartRow = 1
RangeAddress(0).EndColumn = 8
RangeAddress(0).EndRow = 2
oSheet = ThisComponent.Sheets.getByIndex(0)
Charts = oSheet.Charts

Charts.addNewByName("MyChart", Rect, RangeAddress(), False, False)
Chart = Charts.getByName("MyChart").EmbeddedObject

Chart.Diagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.ROWS
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply