Fixed to allow data with more than 32,767 records, using Long instead of Integer.
This commit is contained in:
parent
b16a28f577
commit
6dd0d32097
@ -57,85 +57,24 @@ Sub subRunCorrelation As Object
|
||||
subReportCorrelation (ThisComponent, mRanges (0), mRanges (1))
|
||||
oSheet = oSheets.getByName (sSheetName & "_correl")
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, mRanges (0), mRanges (1))
|
||||
|
||||
' Makes the report sheet active.
|
||||
ThisComponent.getCurrentController.setActiveSheet (oSheet)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = 3510
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subReportCorrelation: Reports the Pearson’s correlation coefficient
|
||||
Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oSheets As Object, sSheetName As String
|
||||
Dim oSheets As Object, sSheetName As String, oTmpSheet As Object
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim nN As Long, sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
Dim aBorderDouble As New com.sun.star.table.BorderLine
|
||||
Dim sCellXLabel As String, sCellsXData As String
|
||||
Dim sCellYLabel As String, sCellsYData As String
|
||||
Dim sCellN As String, sCellR As String
|
||||
Dim sCellN As String, sCellR As String, sCellP As String
|
||||
|
||||
oSheets = oDoc.getSheets
|
||||
sSheetName = oDataXRange.getSpreadsheet.getName
|
||||
@ -245,9 +184,10 @@ Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
sCellR = fnGetLocalRangeName (oCell)
|
||||
oCell.setPropertyValue ("NumberFormat", nFormatF)
|
||||
oCell = oSheet.getCellByPosition (4, nRow)
|
||||
sFormula = "=TDIST(" & sCellR & "*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & "))" & ";" & sCellN & "-2;2)"
|
||||
sFormula = "=TDIST(ABS(" & sCellR & "*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & ")));" & sCellN & "-2;2)"
|
||||
oCell.setFormula (sFormula)
|
||||
oCell.setPropertyValue ("NumberFormat", nFormatP)
|
||||
sCellP = fnGetLocalRangeName (oCell)
|
||||
|
||||
' The foot notes of the test.
|
||||
nRow = nRow + 1
|
||||
@ -328,4 +268,188 @@ Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1)
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, nRow, oDataXRange, oDataYRange)
|
||||
|
||||
' Adds the linear regression line when there is a linear relation
|
||||
If oSheet.getCellRangeByName (sCellP).getValue < 0.05 Then
|
||||
' Refresh this sheet and draws the chart in advance.
|
||||
oTmpSheet = oDoc.getCurrentController.getActiveSheet
|
||||
oDoc.getCurrentController.setActiveSheet (oSheet)
|
||||
oDoc.getCurrentController.setActiveSheet (oTmpSheet)
|
||||
subAddLinearRegression(oSheet, oDataXRange, oDataYRange)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, nRow As Integer, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim nI As Integer, nY As Long
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Finds the Y position to place the chart.
|
||||
nY = 0
|
||||
For nI = 0 To nRow + 1
|
||||
nY = nY + oSheet.getRows.getByIndex (nI).getPropertyValue ("Height")
|
||||
Next nI
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = nY
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
'oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
'oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
With aPos
|
||||
.X = 1500
|
||||
.Y = 1000
|
||||
.Width = 7500
|
||||
.Height = 7500
|
||||
End With
|
||||
oDiagram.setDiagramPositionExcludingAxes (aPos)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
' Sets the data sequences for the X-axis and Y-axis
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subAddLinearRegression: Adds the linear regression line
|
||||
Sub subAddLinearRegression (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oChart As Object, oChartDoc As Object
|
||||
Dim oDrawPage As Object, oChartPageShape As Object
|
||||
Dim oDiagramSetShape As Object, oDiagramShape As Object
|
||||
Dim aDiagramSize As New com.sun.star.awt.Size
|
||||
Dim aDiagramPos As New com.sun.star.awt.Point
|
||||
Dim oDiagram As Object
|
||||
Dim oXAxis As Object, fXMin As Double, fXMax As Double
|
||||
Dim oYAxis As Object, fYMin As Double, fYMax As Double
|
||||
Dim oShape As Object, mDataX As Variant, mDataY As Variant
|
||||
Dim nI As Long, fSumX As Double, fSumY As Double
|
||||
Dim fSumXY As Double, fSumX2 As Double, nN As Long
|
||||
Dim fA As Double, fB As Double
|
||||
Dim fX0 As Double, fY0 As Double, fX1 As Double, fY1 As Double
|
||||
Dim aSize As New com.sun.star.awt.Size
|
||||
Dim aPos As New com.sun.star.awt.Point
|
||||
Dim aDash As New com.sun.star.drawing.LineDash
|
||||
|
||||
oChartDoc = oSheet.getCharts.getByIndex (0).getEmbeddedObject
|
||||
|
||||
oChartPageShape = oChartDoc.getDrawPage.getByIndex (0)
|
||||
oDiagramSetShape = oChartPageShape.getByIndex (1)
|
||||
oDiagramShape = oDiagramSetShape.getByIndex (0)
|
||||
aDiagramSize = oDiagramShape.getSize
|
||||
aDiagramPos = oDiagramShape.getPosition
|
||||
|
||||
oDiagram = oChartDoc.getDiagram
|
||||
oXAxis = oDiagram.getXAxis
|
||||
fXMin = oXAxis.getPropertyValue ("Min")
|
||||
fXMax = oXAxis.getPropertyValue ("Max")
|
||||
oYAxis = oDiagram.getYAxis
|
||||
fYMin = oYAxis.getPropertyValue ("Min")
|
||||
fYMax = oYAxis.getPropertyValue ("Max")
|
||||
|
||||
mDataX = oDataXRange.getCellRangeByPosition (0, 1, 0, oDataXRange.getRows.getCount - 1).getDataArray
|
||||
mDataY = oDataYRange.getCellRangeByPosition (0, 1, 0, oDataYRange.getRows.getCount - 1).getDataArray
|
||||
nN = UBound (mDataX) + 1
|
||||
fSumX = 0
|
||||
fSumY = 0
|
||||
fSumXY = 0
|
||||
fSumX2 = 0
|
||||
For nI = 0 To UBound (mDataX)
|
||||
fSumX = fSumX + mDataX (nI) (0)
|
||||
fSumY = fSumY + mDataY (nI) (0)
|
||||
fSumXY = fSumXY + mDataX (nI) (0) * mDataY (nI) (0)
|
||||
fSumX2 = fSumX2 + mDataX (nI) (0) * mDataX (nI) (0)
|
||||
Next nI
|
||||
fB = (fSumXY - fSumX * fSumY / nN) / (fSumX2 - fSumX * fSumX / nN)
|
||||
fA = (fSumY / nN) - fB * (fSumX / nN)
|
||||
fX0 = fXMin
|
||||
fY0 = fB * fX0 + fA
|
||||
If fY0 < fYMin Then
|
||||
fY0 = fYMin
|
||||
fX0 = (fY0 - fA) / fB
|
||||
End If
|
||||
If fY0 > fYMax Then
|
||||
fY0 = fYMax
|
||||
fX0 = (fY0 - fA) / fB
|
||||
End If
|
||||
fX1 = fXMax
|
||||
fY1 = fB * fX1 + fA
|
||||
If fY1 < fYMin Then
|
||||
fY1 = fYMin
|
||||
fX1 = (fY1 - fA) / fB
|
||||
End If
|
||||
If fY1 > fYMax Then
|
||||
fY1 = fYMax
|
||||
fX1 = (fY1 - fA) / fB
|
||||
End If
|
||||
|
||||
' Adds the linear regression line.
|
||||
oShape = oChartDoc.createInstance ("com.sun.star.drawing.LineShape")
|
||||
With aSize
|
||||
.Width = aDiagramSize.Width * (fX1 - fX0) / (fXMax - fXMin)
|
||||
.Height = -aDiagramSize.Height * (fY1 - fY0) / (fYMax - fYMin)
|
||||
End With
|
||||
oShape.setSize (aSize)
|
||||
With aPos
|
||||
.X = aDiagramPos.X + aDiagramSize.Width * fX0 / (fXMax - fXMin)
|
||||
.Y = aDiagramPos.Y + aDiagramSize.Height - aDiagramSize.Height * fY0 / (fYMax - fYMin)
|
||||
End With
|
||||
oShape.setPosition (aPos)
|
||||
oShape.setPropertyValue ("LineStyle", com.sun.star.drawing.LineStyle.DASH)
|
||||
With aDash
|
||||
.Style = com.sun.star.drawing.DashStyle.RECT
|
||||
.Dots = 1
|
||||
.DotLen = 197
|
||||
.Dashes = 0
|
||||
.DashLen = 0
|
||||
.Distance = 120
|
||||
End With
|
||||
oShape.setPropertyValue ("LineDash", aDash)
|
||||
oShape.setPropertyValue ("LineWidth", 100)
|
||||
oShape.setPropertyValue ("LineColor", RGB (255, 0, 0))
|
||||
|
||||
'oSheet.getDrawPage.add (oShape)
|
||||
oChartDoc.getDrawPage.add (oShape)
|
||||
End Sub
|
||||
|
@ -57,78 +57,17 @@ Sub subRunPairedTTest As Object
|
||||
subReportPairedTTest (ThisComponent, mRanges (0), mRanges (1))
|
||||
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, mRanges (0), mRanges (1))
|
||||
|
||||
' Makes the report sheet active.
|
||||
ThisComponent.getCurrentController.setActiveSheet (oSheet)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = 10000
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subReportPairedTTest: Reports the paired T-test
|
||||
Sub subReportPairedTTest (oDoc As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oSheets As Object, sSheetName As String
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim nN As Long, sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
@ -642,4 +581,79 @@ Sub subReportPairedTTest (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1)
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, nRow, oDataXRange, oDataYRange)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, nRow As Integer, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim nI As Integer, nY As Long
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Finds the Y position to place the chart.
|
||||
nY = 0
|
||||
For nI = 0 To nRow + 1
|
||||
nY = nY + oSheet.getRows.getByIndex (nI).getPropertyValue ("Height")
|
||||
Next nI
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = nY
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
With aPos
|
||||
.X = 1500
|
||||
.Y = 1000
|
||||
.Width = 7500
|
||||
.Height = 7500
|
||||
End With
|
||||
oDiagram.setDiagramPositionExcludingAxes (aPos)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
@ -84,7 +84,7 @@ Sub subReportIndependentTTest (oDoc As Object, oLabelColumn As Object, oScoreCol
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object, oTempDataRange As Object
|
||||
Dim nN As Integer, sFormula As String, sSP2 As String
|
||||
Dim nN As Long, sFormula As String, sSP2 As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
@ -576,14 +576,14 @@ End Sub
|
||||
|
||||
' fnCollectIndependentTTestData: Collects the data for the independent T-test.
|
||||
Function fnCollectIndependentTTestData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object
|
||||
Dim nRow As Integer, nNRow As Integer, sCellZMean As String, sCellsN As String
|
||||
Dim nRow As Long, nNRow As Long, sCellZMean As String, sCellsN As String
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim sCell As String, sLabel As String, sFormula As String
|
||||
Dim sCellXLabel As String, sCellsXData As String, sCellXMean As String
|
||||
Dim sXLabel As String, nNX As Integer
|
||||
Dim sXLabel As String, nNX As Long
|
||||
Dim sCellsXZData As String, sCellXZMean As String
|
||||
Dim sCellYLabel As String, sCellsYData As String, sCellYMean As String
|
||||
Dim sYLabel As String, nNY As Integer
|
||||
Dim sYLabel As String, nNY As Long
|
||||
Dim sCellsYZData As String, sCellYZMean As String
|
||||
|
||||
sCellXLabel = ""
|
||||
|
@ -901,14 +901,14 @@ End Sub
|
||||
|
||||
' fnCollectANOVAData: Collects the data for the ANOVA (Analyze of Variances).
|
||||
Function fnCollectANOVAData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object
|
||||
Dim nRow As Integer, nColumn As Integer, nI As Integer
|
||||
Dim nNRow As Integer, sCellZMean As String, sCellsN As String
|
||||
Dim nRow As Long, nColumn As Integer, nI As Integer
|
||||
Dim nNRow As Long, sCellZMean As String, sCellsN As String
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim sCell As String, sLabel As String, sFormula As String
|
||||
Dim nGroups As Integer, sLabels As String
|
||||
Dim mLabels () As String, mCellLabel () As String
|
||||
Dim mCellsData () As String, mCellMean () As String
|
||||
Dim mN () As Integer, mCellsZData () As String
|
||||
Dim mN () As Long, mCellsZData () As String
|
||||
Dim mCellZMean () As String
|
||||
|
||||
sLabels = " "
|
||||
@ -923,7 +923,7 @@ Function fnCollectANOVAData (oReportSheet As Object, oLabelColumn As Object, oSc
|
||||
|
||||
ReDim mLabels (nGroups - 1) As String, mCellLabel (nGroups - 1) As String
|
||||
ReDim mCellsData (nGroups - 1) As String, mCellMean (nGroups - 1) As String
|
||||
ReDim mN (nGroups - 1) As Integer, mCellsZData (nGroups - 1) As String
|
||||
ReDim mN (nGroups - 1) As Long, mCellsZData (nGroups - 1) As String
|
||||
ReDim mCellZMean (nGroups - 1) As String
|
||||
|
||||
sLabels = " "
|
||||
|
@ -68,7 +68,7 @@ Sub subReportChi2GoodnessOfFit (oDoc As Object, oColumnColumn As Object, oRowCol
|
||||
Dim mNames () As String, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer, nStartRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer, nFormatPct As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
|
@ -59,85 +59,24 @@ Sub subRunCorrelation As Object
|
||||
subReportCorrelation (ThisComponent, mRanges (0), mRanges (1))
|
||||
oSheet = oSheets.getByName (sSheetName & "_correl")
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, mRanges (0), mRanges (1))
|
||||
|
||||
' Makes the report sheet active.
|
||||
ThisComponent.getCurrentController.setActiveSheet (oSheet)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = 3510
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subReportCorrelation: Reports the Pearson’s correlation coefficient
|
||||
Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oSheets As Object, sSheetName As String
|
||||
Dim oSheets As Object, sSheetName As String, oTmpSheet As Object
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim nN As Long, sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
Dim aBorderDouble As New com.sun.star.table.BorderLine
|
||||
Dim sCellXLabel As String, sCellsXData As String
|
||||
Dim sCellYLabel As String, sCellsYData As String
|
||||
Dim sCellN As String, sCellR As String
|
||||
Dim sCellN As String, sCellR As String, sCellP As String
|
||||
|
||||
oSheets = oDoc.getSheets
|
||||
sSheetName = oDataXRange.getSpreadsheet.getName
|
||||
@ -247,9 +186,10 @@ Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
sCellR = fnGetLocalRangeName (oCell)
|
||||
oCell.setPropertyValue ("NumberFormat", nFormatF)
|
||||
oCell = oSheet.getCellByPosition (4, nRow)
|
||||
sFormula = "=TDIST(" & sCellR & "*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & "))" & ";" & sCellN & "-2;2)"
|
||||
sFormula = "=TDIST(ABS(" & sCellR & "*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & ")));" & sCellN & "-2;2)"
|
||||
oCell.setFormula (sFormula)
|
||||
oCell.setPropertyValue ("NumberFormat", nFormatP)
|
||||
sCellP = fnGetLocalRangeName (oCell)
|
||||
|
||||
' The foot notes of the test.
|
||||
nRow = nRow + 1
|
||||
@ -330,5 +270,189 @@ Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1)
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, nRow, oDataXRange, oDataYRange)
|
||||
|
||||
' Adds the linear regression line when there is a linear relation
|
||||
If oSheet.getCellRangeByName (sCellP).getValue < 0.05 Then
|
||||
' Refresh this sheet and draws the chart in advance.
|
||||
oTmpSheet = oDoc.getCurrentController.getActiveSheet
|
||||
oDoc.getCurrentController.setActiveSheet (oSheet)
|
||||
oDoc.getCurrentController.setActiveSheet (oTmpSheet)
|
||||
subAddLinearRegression(oSheet, oDataXRange, oDataYRange)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, nRow As Integer, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim nI As Integer, nY As Long
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Finds the Y position to place the chart.
|
||||
nY = 0
|
||||
For nI = 0 To nRow + 1
|
||||
nY = nY + oSheet.getRows.getByIndex (nI).getPropertyValue ("Height")
|
||||
Next nI
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = nY
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
'oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
'oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
With aPos
|
||||
.X = 1500
|
||||
.Y = 1000
|
||||
.Width = 7500
|
||||
.Height = 7500
|
||||
End With
|
||||
oDiagram.setDiagramPositionExcludingAxes (aPos)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
' Sets the data sequences for the X-axis and Y-axis
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subAddLinearRegression: Adds the linear regression line
|
||||
Sub subAddLinearRegression (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oChart As Object, oChartDoc As Object
|
||||
Dim oDrawPage As Object, oChartPageShape As Object
|
||||
Dim oDiagramSetShape As Object, oDiagramShape As Object
|
||||
Dim aDiagramSize As New com.sun.star.awt.Size
|
||||
Dim aDiagramPos As New com.sun.star.awt.Point
|
||||
Dim oDiagram As Object
|
||||
Dim oXAxis As Object, fXMin As Double, fXMax As Double
|
||||
Dim oYAxis As Object, fYMin As Double, fYMax As Double
|
||||
Dim oShape As Object, mDataX As Variant, mDataY As Variant
|
||||
Dim nI As Long, fSumX As Double, fSumY As Double
|
||||
Dim fSumXY As Double, fSumX2 As Double, nN As Long
|
||||
Dim fA As Double, fB As Double
|
||||
Dim fX0 As Double, fY0 As Double, fX1 As Double, fY1 As Double
|
||||
Dim aSize As New com.sun.star.awt.Size
|
||||
Dim aPos As New com.sun.star.awt.Point
|
||||
Dim aDash As New com.sun.star.drawing.LineDash
|
||||
|
||||
oChartDoc = oSheet.getCharts.getByIndex (0).getEmbeddedObject
|
||||
|
||||
oChartPageShape = oChartDoc.getDrawPage.getByIndex (0)
|
||||
oDiagramSetShape = oChartPageShape.getByIndex (1)
|
||||
oDiagramShape = oDiagramSetShape.getByIndex (0)
|
||||
aDiagramSize = oDiagramShape.getSize
|
||||
aDiagramPos = oDiagramShape.getPosition
|
||||
|
||||
oDiagram = oChartDoc.getDiagram
|
||||
oXAxis = oDiagram.getXAxis
|
||||
fXMin = oXAxis.getPropertyValue ("Min")
|
||||
fXMax = oXAxis.getPropertyValue ("Max")
|
||||
oYAxis = oDiagram.getYAxis
|
||||
fYMin = oYAxis.getPropertyValue ("Min")
|
||||
fYMax = oYAxis.getPropertyValue ("Max")
|
||||
|
||||
mDataX = oDataXRange.getCellRangeByPosition (0, 1, 0, oDataXRange.getRows.getCount - 1).getDataArray
|
||||
mDataY = oDataYRange.getCellRangeByPosition (0, 1, 0, oDataYRange.getRows.getCount - 1).getDataArray
|
||||
nN = UBound (mDataX) + 1
|
||||
fSumX = 0
|
||||
fSumY = 0
|
||||
fSumXY = 0
|
||||
fSumX2 = 0
|
||||
For nI = 0 To UBound (mDataX)
|
||||
fSumX = fSumX + mDataX (nI) (0)
|
||||
fSumY = fSumY + mDataY (nI) (0)
|
||||
fSumXY = fSumXY + mDataX (nI) (0) * mDataY (nI) (0)
|
||||
fSumX2 = fSumX2 + mDataX (nI) (0) * mDataX (nI) (0)
|
||||
Next nI
|
||||
fB = (fSumXY - fSumX * fSumY / nN) / (fSumX2 - fSumX * fSumX / nN)
|
||||
fA = (fSumY / nN) - fB * (fSumX / nN)
|
||||
fX0 = fXMin
|
||||
fY0 = fB * fX0 + fA
|
||||
If fY0 < fYMin Then
|
||||
fY0 = fYMin
|
||||
fX0 = (fY0 - fA) / fB
|
||||
End If
|
||||
If fY0 > fYMax Then
|
||||
fY0 = fYMax
|
||||
fX0 = (fY0 - fA) / fB
|
||||
End If
|
||||
fX1 = fXMax
|
||||
fY1 = fB * fX1 + fA
|
||||
If fY1 < fYMin Then
|
||||
fY1 = fYMin
|
||||
fX1 = (fY1 - fA) / fB
|
||||
End If
|
||||
If fY1 > fYMax Then
|
||||
fY1 = fYMax
|
||||
fX1 = (fY1 - fA) / fB
|
||||
End If
|
||||
|
||||
' Adds the linear regression line.
|
||||
oShape = oChartDoc.createInstance ("com.sun.star.drawing.LineShape")
|
||||
With aSize
|
||||
.Width = aDiagramSize.Width * (fX1 - fX0) / (fXMax - fXMin)
|
||||
.Height = -aDiagramSize.Height * (fY1 - fY0) / (fYMax - fYMin)
|
||||
End With
|
||||
oShape.setSize (aSize)
|
||||
With aPos
|
||||
.X = aDiagramPos.X + aDiagramSize.Width * fX0 / (fXMax - fXMin)
|
||||
.Y = aDiagramPos.Y + aDiagramSize.Height - aDiagramSize.Height * fY0 / (fYMax - fYMin)
|
||||
End With
|
||||
oShape.setPosition (aPos)
|
||||
oShape.setPropertyValue ("LineStyle", com.sun.star.drawing.LineStyle.DASH)
|
||||
With aDash
|
||||
.Style = com.sun.star.drawing.DashStyle.RECT
|
||||
.Dots = 1
|
||||
.DotLen = 197
|
||||
.Dashes = 0
|
||||
.DashLen = 0
|
||||
.Distance = 120
|
||||
End With
|
||||
oShape.setPropertyValue ("LineDash", aDash)
|
||||
oShape.setPropertyValue ("LineWidth", 100)
|
||||
oShape.setPropertyValue ("LineColor", RGB (255, 0, 0))
|
||||
|
||||
'oSheet.getDrawPage.add (oShape)
|
||||
oChartDoc.getDrawPage.add (oShape)
|
||||
End Sub
|
||||
</script:module>
|
@ -59,78 +59,17 @@ Sub subRunPairedTTest As Object
|
||||
subReportPairedTTest (ThisComponent, mRanges (0), mRanges (1))
|
||||
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, mRanges (0), mRanges (1))
|
||||
|
||||
' Makes the report sheet active.
|
||||
ThisComponent.getCurrentController.setActiveSheet (oSheet)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = 10000
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
|
||||
' subReportPairedTTest: Reports the paired T-test
|
||||
Sub subReportPairedTTest (oDoc As Object, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim oSheets As Object, sSheetName As String
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim nN As Long, sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
@ -644,5 +583,80 @@ Sub subReportPairedTTest (oDoc As Object, oDataXRange As Object, oDataYRange As
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1)
|
||||
oCells.setPropertyValue ("BottomBorder", aBorderDouble)
|
||||
|
||||
' Adds an X-Y diagram.
|
||||
subAddChart (oSheet, nRow, oDataXRange, oDataYRange)
|
||||
End Sub
|
||||
|
||||
' subAddChart: Adds a chart for the data
|
||||
Sub subAddChart (oSheet As Object, nRow As Integer, oDataXRange As Object, oDataYRange As Object)
|
||||
Dim nI As Integer, nY As Long
|
||||
Dim oCharts As Object, oChart As Object
|
||||
Dim oChartDoc As Object, oDiagram As Object
|
||||
Dim aPos As New com.sun.star.awt.Rectangle
|
||||
Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress
|
||||
Dim sTitle As String
|
||||
Dim oProvider As Object, oData As Object
|
||||
Dim sRange As String, mData () As Object
|
||||
|
||||
' Finds the Y position to place the chart.
|
||||
nY = 0
|
||||
For nI = 0 To nRow + 1
|
||||
nY = nY + oSheet.getRows.getByIndex (nI).getPropertyValue ("Height")
|
||||
Next nI
|
||||
|
||||
' Adds the chart
|
||||
With aPos
|
||||
.X = 0
|
||||
.Y = nY
|
||||
.Width = 10000
|
||||
.Height = 10000
|
||||
End With
|
||||
mAddrs (0) = oDataXRange.getRangeAddress
|
||||
mAddrs (1) = oDataYRange.getRangeAddress
|
||||
oCharts = oSheet.getCharts
|
||||
oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False)
|
||||
oChart = oCharts.getByName (oSheet.getName)
|
||||
oChartDoc = oChart.getEmbeddedObject
|
||||
|
||||
BasicLibraries.loadLibrary "XrayTool"
|
||||
oDiagram = oChartDoc.createInstance ( _
|
||||
"com.sun.star.chart.XYDiagram")
|
||||
oDiagram.setPropertyValue ("Lines", False)
|
||||
oDiagram.setPropertyValue ("HasXAxisGrid", False)
|
||||
oDiagram.setPropertyValue ("HasYAxisGrid", False)
|
||||
sTitle = oDataXRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle)
|
||||
sTitle = oDataYRange.getCellByPosition (0, 0).getString
|
||||
oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle)
|
||||
oDiagram.getXAxis.setPropertyValue ("Min", 0)
|
||||
oDiagram.getYAxis.setPropertyValue ("Min", 0)
|
||||
With aPos
|
||||
.X = 1500
|
||||
.Y = 1000
|
||||
.Width = 7500
|
||||
.Height = 7500
|
||||
End With
|
||||
oDiagram.setDiagramPositionExcludingAxes (aPos)
|
||||
oChartDoc.setDiagram (oDiagram)
|
||||
|
||||
oProvider = oChartDoc.getDataProvider
|
||||
mData = oChartDoc.getDataSequences
|
||||
sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (0).setLabel (oData)
|
||||
sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-x"
|
||||
mData (0).setValues (oData)
|
||||
sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
mData (1).setLabel (oData)
|
||||
sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName")
|
||||
oData = oProvider.createDataSequenceByRangeRepresentation (sRange)
|
||||
oData.Role = "values-y"
|
||||
mData (1).setValues (oData)
|
||||
|
||||
oChartDoc.setPropertyValue ("HasLegend", False)
|
||||
End Sub
|
||||
</script:module>
|
@ -86,7 +86,7 @@ Sub subReportIndependentTTest (oDoc As Object, oLabelColumn As Object, oScoreCol
|
||||
Dim mNames () As String, nI As Integer, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object, oTempDataRange As Object
|
||||
Dim nN As Integer, sFormula As String, sSP2 As String
|
||||
Dim nN As Long, sFormula As String, sSP2 As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
@ -578,14 +578,14 @@ End Sub
|
||||
|
||||
' fnCollectIndependentTTestData: Collects the data for the independent T-test.
|
||||
Function fnCollectIndependentTTestData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object
|
||||
Dim nRow As Integer, nNRow As Integer, sCellZMean As String, sCellsN As String
|
||||
Dim nRow As Long, nNRow As Long, sCellZMean As String, sCellsN As String
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim sCell As String, sLabel As String, sFormula As String
|
||||
Dim sCellXLabel As String, sCellsXData As String, sCellXMean As String
|
||||
Dim sXLabel As String, nNX As Integer
|
||||
Dim sXLabel As String, nNX As Long
|
||||
Dim sCellsXZData As String, sCellXZMean As String
|
||||
Dim sCellYLabel As String, sCellsYData As String, sCellYMean As String
|
||||
Dim sYLabel As String, nNY As Integer
|
||||
Dim sYLabel As String, nNY As Long
|
||||
Dim sCellsYZData As String, sCellYZMean As String
|
||||
|
||||
sCellXLabel = ""
|
||||
|
@ -903,14 +903,14 @@ End Sub
|
||||
|
||||
' fnCollectANOVAData: Collects the data for the ANOVA (Analyze of Variances).
|
||||
Function fnCollectANOVAData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object
|
||||
Dim nRow As Integer, nColumn As Integer, nI As Integer
|
||||
Dim nNRow As Integer, sCellZMean As String, sCellsN As String
|
||||
Dim nRow As Long, nColumn As Integer, nI As Integer
|
||||
Dim nNRow As Long, sCellZMean As String, sCellsN As String
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim sCell As String, sLabel As String, sFormula As String
|
||||
Dim nGroups As Integer, sLabels As String
|
||||
Dim mLabels () As String, mCellLabel () As String
|
||||
Dim mCellsData () As String, mCellMean () As String
|
||||
Dim mN () As Integer, mCellsZData () As String
|
||||
Dim mN () As Long, mCellsZData () As String
|
||||
Dim mCellZMean () As String
|
||||
|
||||
sLabels = " "
|
||||
@ -925,7 +925,7 @@ Function fnCollectANOVAData (oReportSheet As Object, oLabelColumn As Object, oSc
|
||||
|
||||
ReDim mLabels (nGroups - 1) As String, mCellLabel (nGroups - 1) As String
|
||||
ReDim mCellsData (nGroups - 1) As String, mCellMean (nGroups - 1) As String
|
||||
ReDim mN (nGroups - 1) As Integer, mCellsZData (nGroups - 1) As String
|
||||
ReDim mN (nGroups - 1) As Long, mCellsZData (nGroups - 1) As String
|
||||
ReDim mCellZMean (nGroups - 1) As String
|
||||
|
||||
sLabels = " "
|
||||
|
@ -70,7 +70,7 @@ Sub subReportChi2GoodnessOfFit (oDoc As Object, oColumnColumn As Object, oRowCol
|
||||
Dim mNames () As String, nSheetIndex As Integer
|
||||
Dim oSheet As Object, oColumns As Object, nRow As Integer, nStartRow As Integer
|
||||
Dim oCell As Object, oCells As Object, oCursor As Object
|
||||
Dim nN As Integer, sFormula As String
|
||||
Dim sFormula As String
|
||||
Dim sNotes As String, nPos As Integer
|
||||
Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer, nFormatPct As Integer
|
||||
Dim aBorderSingle As New com.sun.star.table.BorderLine
|
||||
|
Loading…
Reference in New Issue
Block a user