Top > OOoBasic > Calc > chart2 > RegressionCurve

回帰曲線 Edit

曲線に対応したサービスをインスタンス化して追加します。

名前サービス名
直線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
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
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