2014-11-02 58 views
0

我想要改變數據點的大小,這些數據點的製作如下所示。LibreOffice Calc XYDiagram in BASIC:設置數據點的大小

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。

回答

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 

會產生: enter image description here