create a new page, using OOoBasic/Calc/chart2/ex1 as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
* 例1 [#z4b83470]
最も基本的なものとして
+新たなチャートを作成
+種類を変更
+新しいデータ範囲を設定
する例です。すべて chart2 モジュールを利用するようにしま...
簡単な表から 3Dの円グラフを作成します。範囲は Sheet1.A1:B...
&ref(chart_ex1.png,nolink);
#contents
#code(basic){{
Sub Chart_ex1
oDoc = ThisComponent
' charts container of the first sheet
oCharts = oDoc.getSheets().getByIndex(0).getCharts()
Dim aRange(1) As New com.sun.star.table.CellRangeAddress
Dim aRectangle As New com.sun.star.awt.Rectangle
sChartName = "Chart2"
aRectangle = make_Rectangle(1300, 1300, 7000, 5000)
If oCharts.hasByName(sChartName) Then
oCharts.removeByName(sChartName)
End If
' adds new chart
oCharts.addNewByName(sChartName,aRectangle,aRange,False...
' get newly created chart
oChart = oCharts.getByName(sChartName).getEmbeddedObjec...
' diagram of the css.chart2
oDiagram = oChart.getFirstDiagram()
' create template and set to it
oChartTypeManager = oChart.getChartTypeManager()
oChartTypeTemplate = oChartTypeManager.createInstance( _
"com.sun.star.chart2.template.ThreeDPie")
oChartTypeTemplate.changeDiagram(oDiagram)
' DataProvider is used to make new data source
oDataProvider = oChart.getDataProvider()
' coordinates belongs the diagram
oCoords = oDiagram.getCoordinateSystems()
oCoord = oCoords(0)
' chart types belonging the coordinate
oChartTypes = oCoord.getChartTypes()
oChartType = oChartTypes(0)
' create new datasource from arguments
' valid names of arguments are defined in
' css.chart2.data.TabularDataProviderArguments service
Dim aProps(3) As New com.sun.star.beans.PropertyValue
aProps(0).Name = "CellRangeRepresentation"
aProps(0).Value = "Sheet1.A1:B3"
aProps(1).Name = "DataRowSource"
aProps(1).Value = com.sun.star.chart.ChartDataRowSource...
aProps(2).Name = "FirstCellAsLabel"
aProps(2).Value = False
aProps(3).Name = "HasCategories"
aProps(3).Value = True
oDataSource = oDataProvider.createDataSource(aProps)
' change data of the diagram
Dim aArgs(0) As New com.sun.star.beans.PropertyValue
aArgs(0).Name = "HasCategories"
aArgs(0).Value = True
oChartTypeTemplate.changeDiagramData(oDiagram, oDataSou...
End Sub
Function make_Rectangle( _
nX As Long, nY As Long, _
nWidth As Long, nHeight As Long ) _
As com.sun.star.awt.Rectangle
Dim aRectangle As New com.sun.star.awt.Rectangle
With aRectangle
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
make_Rectangle = aRectangle
End Function
}}
表示されるチャートは色が手動で作成したものと少し違います...
With oDiagram
.D3DSceneAmbientColor = 13421772
.D3DSceneLightColor2 = 3355443
.D3DSceneShadowSlant = 0
End With
End:
* 例1 [#z4b83470]
最も基本的なものとして
+新たなチャートを作成
+種類を変更
+新しいデータ範囲を設定
する例です。すべて chart2 モジュールを利用するようにしま...
簡単な表から 3Dの円グラフを作成します。範囲は Sheet1.A1:B...
&ref(chart_ex1.png,nolink);
#contents
#code(basic){{
Sub Chart_ex1
oDoc = ThisComponent
' charts container of the first sheet
oCharts = oDoc.getSheets().getByIndex(0).getCharts()
Dim aRange(1) As New com.sun.star.table.CellRangeAddress
Dim aRectangle As New com.sun.star.awt.Rectangle
sChartName = "Chart2"
aRectangle = make_Rectangle(1300, 1300, 7000, 5000)
If oCharts.hasByName(sChartName) Then
oCharts.removeByName(sChartName)
End If
' adds new chart
oCharts.addNewByName(sChartName,aRectangle,aRange,False...
' get newly created chart
oChart = oCharts.getByName(sChartName).getEmbeddedObjec...
' diagram of the css.chart2
oDiagram = oChart.getFirstDiagram()
' create template and set to it
oChartTypeManager = oChart.getChartTypeManager()
oChartTypeTemplate = oChartTypeManager.createInstance( _
"com.sun.star.chart2.template.ThreeDPie")
oChartTypeTemplate.changeDiagram(oDiagram)
' DataProvider is used to make new data source
oDataProvider = oChart.getDataProvider()
' coordinates belongs the diagram
oCoords = oDiagram.getCoordinateSystems()
oCoord = oCoords(0)
' chart types belonging the coordinate
oChartTypes = oCoord.getChartTypes()
oChartType = oChartTypes(0)
' create new datasource from arguments
' valid names of arguments are defined in
' css.chart2.data.TabularDataProviderArguments service
Dim aProps(3) As New com.sun.star.beans.PropertyValue
aProps(0).Name = "CellRangeRepresentation"
aProps(0).Value = "Sheet1.A1:B3"
aProps(1).Name = "DataRowSource"
aProps(1).Value = com.sun.star.chart.ChartDataRowSource...
aProps(2).Name = "FirstCellAsLabel"
aProps(2).Value = False
aProps(3).Name = "HasCategories"
aProps(3).Value = True
oDataSource = oDataProvider.createDataSource(aProps)
' change data of the diagram
Dim aArgs(0) As New com.sun.star.beans.PropertyValue
aArgs(0).Name = "HasCategories"
aArgs(0).Value = True
oChartTypeTemplate.changeDiagramData(oDiagram, oDataSou...
End Sub
Function make_Rectangle( _
nX As Long, nY As Long, _
nWidth As Long, nHeight As Long ) _
As com.sun.star.awt.Rectangle
Dim aRectangle As New com.sun.star.awt.Rectangle
With aRectangle
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
make_Rectangle = aRectangle
End Function
}}
表示されるチャートは色が手動で作成したものと少し違います...
With oDiagram
.D3DSceneAmbientColor = 13421772
.D3DSceneLightColor2 = 3355443
.D3DSceneShadowSlant = 0
End With
Page: