0

我想更改由制作 XYDiagram 产生的数据点的大小,如下所示。

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

此代码将正确生成 XY 散点图,但点太大。鉴于我正在绘制的数据的性质,我希望代码自动使点变小,而不是我为每个生成的图形更改大小。有谁知道如何编辑数据点大小?我搜索了几天如何做到这一点,但我找不到它,似乎没有多少人在使用 libreoffice calc basic。

4

1 回答 1

0

好像你有来自这里的代码示例:https ://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Charts_in_Spreadsheets 所以请阅读:https ://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/UNO_Tools #Debugging_tools并获取调试工具。使用这样的工具,您可以检查您已经得到的对象。

我使用 XRAY 工具,在我的示例中我检查了 Chart.Diagram。在那里我找到了https://www.openoffice.org/api/docs/common/ref/com/sun/star/chart/LineDiagram.html#SymbolSizehttps://www.openoffice.org/api/docs/ common/ref/com/sun/star/awt/Size.html

所以下面的代码:

 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

将产生: 在此处输入图像描述

于 2014-11-05T15:18:44.127 回答