• The added line is THIS COLOR.
  • The deleted line is THIS COLOR.
* 回帰曲線 [#g4e0ba4d]


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
  ' 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)
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