Top > OOoBasic > Calc > chart2 > RegressionCurve

* 回帰曲線 [#g4e0ba4d]
曲線に対応したサービスをインスタンス化して追加します。

|*名前|*|
|名前|サービス名|h
|直線|com.sun.star.comp.chart2.LinearRegressionCurve|
|指数|com.sun.star.comp.chart2.ExponentialRegressionCurve|
|対数|com.sun.star.comp.chart2.LogarithmicRegressionCurve|
|平均|com.sun.star.comp.chart2.MeanValueRegressionCurve|
||com.sun.star.comp.chart2.PotentialRegressionCurve|


#code(basic){{
Function AddRegressionCurveExample
  oSheets = ThisComponent.getSheets()
  oObj1 = oSheets.getByIndex(0)
  oCharts = oObj1.getCharts()
  
  oObj2 = oCharts.getByIndex(0)
  oEmbeddedObject = oObj2.getEmbeddedObject()
  
  oFirstDiagram = oEmbeddedObject.getFirstDiagram()
  oCoordinateSystems = oFirstDiagram.getCoordinateSystems()
  oXCoordinateSystem = oCoordinateSystems(0)
  
  oChartTypes = oXCoordinateSystem.getChartTypes()
  oXChartType = oChartTypes(0)
  sChartType = oXChartType.getChartType()
  
  oDataSeries = oXChartType.getDataSeries()
  oXDataSeries = oDataSeries(0)
  
  ' Get X and Y data sequence
  aXSeries = nothing
  aYSeries = nothing
  
  oDataSequences = oXDataSeries.getDataSequences()
  for i = 0 to ubound(oDataSequences) step 1
    oXLabeledDataSequence = oDataSequences(i)
    oValues = oXLabeledDataSequence.getValues()
  
    sRole = oValues.Role
    if sRole = "values-x" then
      aXSeries = oValues.getData()
    elseif sRole = "values-y" then
      aYSeries = oValues.getData()
    end if
  next
  ' if x or y data series is empty, error
  
  ' create regression curve and add it to the data series
  oCurve = CreateUnoService("com.sun.star.comp.chart2.LinearRegressionCurve")
  oCalculator = oCurve.getCalculator()
  oCalculator.recalculateRegression(aXSeries, aYSeries)
  
  oXDataSeries.addRegressionCurve(oCurve)
End Function
}}

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes