create a new page, using OOoBasic/Calc/chart2/ex3 as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
* データ範囲の変更 [#c6781087]
#contents
あるシート上で作成したチャートをコピーして別のシートに貼...
データ範囲を保持している LabeledDataSequence から範囲を取...
#code(basic){{
Sub ChartSeriesModify
oSheet = ThisComponent.getCurrentController().getActive...
sSheetName = oSheet.Name
oCharts = oSheet.getCharts()
oChart = oCharts.getByIndex(0).getEmbeddedObject()
oChart.lockControllers()
oDiagram = oChart.getFirstDiagram()
oDataProvider = oChart.getDataProvider()
oCoords = oDiagram.getCoordinateSystems()
oCoord = oCoords(0)
oChartTypes = oCoord.getChartTypes()
oChartType = oChartTypes(0)
' data series retain all of data used in the chart
oDataSeries = oChartType.getDataSeries()
For i = 0 To UBound(oDataSeries) step 1
oSeries = oDataSeries(i)
oSeqes = oSeries.getDataSequences()
Dim aData(UBound(oSeqes)) As Object
For j = 0 To UBound(oSeqes) step 1
oSeq = oSeqes(j)
oNewSeq = CreateUnoService(_
"com.sun.star.chart2.data.LabeledDataSequence")
oNewValues = nothing
oNewLabel = nothing
' get current data
oLabel = oSeq.getLabel()
oValues = oSeq.getValues()
If NOT IsNull(oLabel) Then
sLabelRole = oLabel.Role
sLabelDesc = oLabel.getSourceRangeRepresentation()
sAddr = split(sLabelDesc, ".")
sLabelDesc = sSheetName & "." & sAddr(1) ' on the...
' create new data with current sheet name
oNewLabel = CreateDataSequence(oDataProvider, sLa...
oNewSeq.setLabel(oNewLabel)
End If
If NOT IsNull(oValues) Then
sValRole = oValues.Role
sValDesc = oValues.getSourceRangeRepresentation()
sAddr = split(sValDesc, ".")
sValDesc = sSheetName & "." & sAddr(1) ' on the c...
oNewValues = CreateDataSequence(oDataProvider, sV...
oNewSeq.setValues(oNewValues)
End If
aData(j) = oNewSeq
Next
' set new data to existing series
oSeries.setData(aData)
oDataSeries(i) = oSeries
Next
' apply new data
oChartType.setDataSeries(oDataSeries)
oChart.unlockControllers()
End Sub
' creat new DataSequence from range representaion
' that provides real data and its role in the series
' oDataProvider: com.sun.star.chart2.data.XDataProvider
' sRangeRepresentation: range address e.g. Sheet1.A1:B2
' sRole: role is defined in com.sun.star.chart2.data.Data...
Function CreateDataSequence( _
oDataProvider As Object, _
sRangeRepresentation As String, sRole As String ) As ...
Dim oDataSequence As Object
On Error GoTo Handler
' create .chart2.data.DataSequence from range represent...
If oDataProvider._
createDataSequenceByRangeRepresentationPossible(sRa...
oDataSequence = oDataProvider._
createDataSequenceByRangeRepresentation(sRangeRep...
If NOT IsNull(oDataSequence) Then
oDataSequence.Role = sRole
End If
End If
Handler:
CreateDataSequence = oDataSequence
End Function
}}
End:
* データ範囲の変更 [#c6781087]
#contents
あるシート上で作成したチャートをコピーして別のシートに貼...
データ範囲を保持している LabeledDataSequence から範囲を取...
#code(basic){{
Sub ChartSeriesModify
oSheet = ThisComponent.getCurrentController().getActive...
sSheetName = oSheet.Name
oCharts = oSheet.getCharts()
oChart = oCharts.getByIndex(0).getEmbeddedObject()
oChart.lockControllers()
oDiagram = oChart.getFirstDiagram()
oDataProvider = oChart.getDataProvider()
oCoords = oDiagram.getCoordinateSystems()
oCoord = oCoords(0)
oChartTypes = oCoord.getChartTypes()
oChartType = oChartTypes(0)
' data series retain all of data used in the chart
oDataSeries = oChartType.getDataSeries()
For i = 0 To UBound(oDataSeries) step 1
oSeries = oDataSeries(i)
oSeqes = oSeries.getDataSequences()
Dim aData(UBound(oSeqes)) As Object
For j = 0 To UBound(oSeqes) step 1
oSeq = oSeqes(j)
oNewSeq = CreateUnoService(_
"com.sun.star.chart2.data.LabeledDataSequence")
oNewValues = nothing
oNewLabel = nothing
' get current data
oLabel = oSeq.getLabel()
oValues = oSeq.getValues()
If NOT IsNull(oLabel) Then
sLabelRole = oLabel.Role
sLabelDesc = oLabel.getSourceRangeRepresentation()
sAddr = split(sLabelDesc, ".")
sLabelDesc = sSheetName & "." & sAddr(1) ' on the...
' create new data with current sheet name
oNewLabel = CreateDataSequence(oDataProvider, sLa...
oNewSeq.setLabel(oNewLabel)
End If
If NOT IsNull(oValues) Then
sValRole = oValues.Role
sValDesc = oValues.getSourceRangeRepresentation()
sAddr = split(sValDesc, ".")
sValDesc = sSheetName & "." & sAddr(1) ' on the c...
oNewValues = CreateDataSequence(oDataProvider, sV...
oNewSeq.setValues(oNewValues)
End If
aData(j) = oNewSeq
Next
' set new data to existing series
oSeries.setData(aData)
oDataSeries(i) = oSeries
Next
' apply new data
oChartType.setDataSeries(oDataSeries)
oChart.unlockControllers()
End Sub
' creat new DataSequence from range representaion
' that provides real data and its role in the series
' oDataProvider: com.sun.star.chart2.data.XDataProvider
' sRangeRepresentation: range address e.g. Sheet1.A1:B2
' sRole: role is defined in com.sun.star.chart2.data.Data...
Function CreateDataSequence( _
oDataProvider As Object, _
sRangeRepresentation As String, sRole As String ) As ...
Dim oDataSequence As Object
On Error GoTo Handler
' create .chart2.data.DataSequence from range represent...
If oDataProvider._
createDataSequenceByRangeRepresentationPossible(sRa...
oDataSequence = oDataProvider._
createDataSequenceByRangeRepresentation(sRangeRep...
If NOT IsNull(oDataSequence) Then
oDataSequence.Role = sRole
End If
End If
Handler:
CreateDataSequence = oDataSequence
End Function
}}
Page: