Skip to content

Commit

Permalink
Merge pull request #1029 from maxwellfundi/tidyingUpBoxplot
Browse files Browse the repository at this point in the history
finalised boxplot
  • Loading branch information
dannyparsons committed Mar 10, 2016
2 parents bb7595d + d993380 commit 42cdab0
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 132 deletions.
157 changes: 67 additions & 90 deletions instat/dlgBoxPlot.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 59 additions & 39 deletions instat/dlgBoxPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,42 @@ Public Class dlgBoxplot
Private clsRggplotFunction As New RFunction
Private clsRgeom_boxplotFunction As New RFunction
Private clsRaesFunction As New RFunction
Private bFirstLoad As Boolean = True

Private Sub dlgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ucrBase.clsRsyntax.SetOperation("+")
clsRggplotFunction.SetRCommand("ggplot")
clsRgeom_boxplotFunction.SetRCommand("geom_boxplot")
clsRaesFunction.SetRCommand("aes")
clsRaesFunction.AddParameter("x", "") ' Empty string is default x value in case no factor is chosen
clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) ' Empty string is default x value in case no factor is chosen
clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction)
SetOperator()
ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction)
ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_boxplotFunction)

ucrBase.iHelpTopicID = 102
ucrBase.clsRsyntax.iCallType = 0

ucrYvariableReceiver.Selector = ucrSelectorBoxPlot
ucrYvariableReceiver.SetMeAsReceiver()
ucrByFactorsReceiver.Selector = ucrSelectorBoxPlot
ucrByFactorsReceiver.SetDataType("factor")
ucrSecondFactorReceiver.Selector = ucrSelectorBoxPlot
ucrSecondFactorReceiver.SetDataType("factor")

sdgPlots.SetRSyntax(ucrBase.clsRsyntax)
sdgBoxPlot.SetBoxPlotFunction(clsRgeom_boxplotFunction)
autoTranslate(Me)
ucrBase.OKEnabled(False)

If bFirstLoad Then
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If

End Sub

Private Sub SetOperator()
Public Sub SetOperator()
Dim clsTempOp As New ROperator
Dim clsTempRFunc As New RFunction
If chkHorizontalBoxplot.Checked Then
Expand All @@ -48,65 +63,70 @@ Public Class dlgBoxplot
clsTempRFunc.SetRCommand("coord_flip")
ucrBase.clsRsyntax.SetOperatorParameter(True, clsOp:=clsTempOp)
ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsTempRFunc)
End If
End Sub
Private Sub SetDefaults()
ucrSelectorBoxPlot.Reset()
ucrSelectorBoxPlot.Focus()
ucrYvariableReceiver.SetMeAsReceiver()
sdgBoxPlot.SetDefaults()
TestOkEnabled()

End Sub

Private Sub TestOkEnabled()
If Not ucrYvariableReceiver.IsEmpty Then
ucrBase.OKEnabled(True)
Else
ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction)
ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_boxplotFunction)
ucrBase.OKEnabled(False)
End If
End Sub
Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.ShowDialog()
End Sub

Private Sub ucrByFactorsReceiver_Enter(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.Enter
ucrByFactorsReceiver.SetMeAsReceiver()
End Sub

Private Sub ucrSelectorBoxPlot_DataFrameChanged() Handles ucrSelectorBoxPlot.DataFrameChanged
clsRggplotFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorBoxPlot.ucrAvailableDataFrames.clsCurrDataFrame)
End Sub

Private Sub ucrByFactorsReceiver_Leave(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.Leave
clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False))
Private Sub ucrYvariableReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrYvariableReceiver.SelectionChanged
If Not ucrYvariableReceiver.IsEmpty Then
clsRaesFunction.AddParameter("y", ucrYvariableReceiver.GetVariableNames(False))
ucrByFactorsReceiver.SetMeAsReceiver()
Else
clsRaesFunction.RemoveParameterByName("y")
End If
TestOkEnabled()
End Sub

Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged
SetOperator()
Private Sub ucrByFactorsReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.SelectionChanged
ReopenDialog()
End Sub
Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged

Private Sub chkNotchedBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkNotchedBoxplot.CheckedChanged
If chkNotchedBoxplot.Checked Then
clsRgeom_boxplotFunction.AddParameter("notch", "TRUE")
If Not ucrSecondFactorReceiver.IsEmpty Then
clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False))
ucrYvariableReceiver.SetMeAsReceiver()
Else
clsRgeom_boxplotFunction.RemoveParameterByName("notch")
clsRaesFunction.RemoveParameterByName("fill")
End If
End Sub

Private Sub chkVariableWidth_CheckedChanged(sender As Object, e As EventArgs) Handles chkVariableWidth.CheckedChanged
If chkVariableWidth.Checked Then
clsRgeom_boxplotFunction.AddParameter("varwidth", "TRUE")
Private Sub ReopenDialog()
If Not ucrByFactorsReceiver.IsEmpty Then
clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False))
Else
clsRgeom_boxplotFunction.RemoveParameterByName("varwidth")
clsRaesFunction.AddParameter("x", Chr(34) & Chr(34))
End If
End Sub

Private Sub ucrYvariableReceiver_Leave(sender As Object, e As EventArgs) Handles ucrYvariableReceiver.Leave
If Not (ucrYvariableReceiver.GetVariableNames = "") Then
clsRaesFunction.AddParameter("y", ucrYvariableReceiver.GetVariableNames(False))
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub

Private Sub ucrSecondFactorReceiver_Leave(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.Leave
clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False))
Private Sub cmdBoxPlotOptions_Click(sender As Object, e As EventArgs) Handles cmdBoxPlotOptions.Click
sdgBoxPlot.ShowDialog()
End Sub

Private Sub ucrSecondFactorReceiver_Enter(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.Enter
ucrSecondFactorReceiver.SetMeAsReceiver()
Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
End Sub

Private Sub cmdBoxPlotOptions_Click(sender As Object, e As EventArgs) Handles cmdBoxPlotOptions.Click
sdgBoxPlot.ShowDialog()
Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged
SetOperator()
End Sub
End Class
Loading

0 comments on commit 42cdab0

Please sign in to comment.