0

I want to change the data point's size which result from making an XYDiagram as follows.

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

Rect.X = 0
Rect.Y = 6666 * (x/3)

Rect.Width = 16500
Rect.Height = 6666

RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = x+1
RangeAddress(0).StartRow = 1
RangeAddress(0).EndColumn = x+2
RangeAddress(0).EndRow = y-1

ThisComponent.Sheets(0).Charts.addNewByName(mode, Rect, RangeAddress(), False, False)
ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram _ = ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.createInstance("com.sun.star.chart.XYDiagram")

ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram.HasXAxisTitle = True
ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram.XAxisTitle.String ="Ratio"

ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram.HasYAxisTitle = True
ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram.YAxisTitle.String ="Cost"

ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Diagram.getDataRowProperties(1).lines = false

ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.HasLegend = False

ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.HasMainTitle = True
ThisComponent.Sheets(0).Charts.getByName(mode).embeddedObject.Title.String = mode

This code will generate a XY scatter plot correctly, but the points are too big. Given the nature of the data I am graphing I want the code to make the points small automatically instead of me changing size for every graphs generated. Does anyone know how to edit the data point size? I searched how to do this for a few days but I can't find it, it seems not many people are using libreoffice calc basic.

user3064869
  • 530
  • 1
  • 6
  • 19

1 Answers1

1

Seems as if you have the code example from here: https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Charts_in_Spreadsheets So read also this: https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/UNO_Tools#Debugging_tools and get a debugging tool. With such a tool you can examine the objects, you have gotten.

I use XRAY tool and in my example I examine the Chart.Diagram. There I have found https://www.openoffice.org/api/docs/common/ref/com/sun/star/chart/LineDiagram.html#SymbolSize and https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/Size.html.

So the following code:

 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 = ThisComponent
 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 = 1
 RangeAddress(0).EndRow = 11

 with Charts
  if not .hasByName("MyChart") then .addNewByName("MyChart", Rect, RangeAddress(), True, True)
  Chart = .getByName("MyChart").embeddedObject
 end with
 Chart.Diagram = Chart.createInstance("com.sun.star.chart.XYDiagram")
 'xray Chart.Diagram

 Dim Size as new com.sun.star.awt.Size
 with Size
  .Height = 150
  .Width = 150
 end with

 Chart.Diagram.SymbolSize = Size

will produce: enter image description here

Axel Richter
  • 56,077
  • 6
  • 60
  • 87