Skip to content

Commit

Permalink
Merge pull request #8526 from MeSophie/RenameDialogissue8488
Browse files Browse the repository at this point in the history
Added Add Jitter check box to the Describe > Graphs >Scatterplot dialog
  • Loading branch information
lloyddewit authored Sep 8, 2023
2 parents 7836334 + 3cafbab commit 4010200
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 13 deletions.
100 changes: 88 additions & 12 deletions instat/dlgScatterPlot.Designer.vb

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

52 changes: 51 additions & 1 deletion instat/dlgScatterPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ Public Class dlgScatterPlot
Private clsScaleColourViridisFunction As New RFunction
Private clsAnnotateFunction As New RFunction
Private clsGeomRugFunction As New RFunction
Private clsGeomJitterFunction As New RFunction
'Parameter names for geoms
Private strFirstParameterName As String = "geomfunc"
Private strGeomSmoothParameterName As String = "geom_smooth"
Private strGeomTextRepelParameterName As String = "geom_text_repel"
Private strGeomParameterNames() As String = {strFirstParameterName, strGeomSmoothParameterName, strGeomTextRepelParameterName}
Private strGeomJitterParameterName As String = "geom_jitter"
Private strGeomParameterNames() As String = {strFirstParameterName, strGeomJitterParameterName, strGeomSmoothParameterName, strGeomTextRepelParameterName}

Private Sub dlgScatterPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If bFirstLoad Then
Expand Down Expand Up @@ -117,6 +119,11 @@ Public Class dlgScatterPlot
ucrChkAddRugPlot.AddParameterPresentCondition(False, "geom_rug", False)
ucrChkAddRugPlot.AddToLinkedControls({ucrNudSize, ucrInputSides}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)

ucrChkJitter.SetText("Jitter")
ucrChkJitter.AddParameterPresentCondition(True, "geom_jitter")
ucrChkJitter.AddParameterPresentCondition(False, "geom_jitter", False)
ucrChkJitter.AddToLinkedControls({ucrNudHeigth, ucrNudWidth}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="0.40")

ucrSaveScatterPlot.SetPrefix("scatter_plot")
ucrSaveScatterPlot.SetSaveType(strRObjectType:=RObjectTypeLabel.Graph,
strRObjectFormat:=RObjectFormat.Image)
Expand All @@ -129,6 +136,18 @@ Public Class dlgScatterPlot
ucrNudSize.Increment = 0.1
ucrNudSize.DecimalPlaces = 1

ucrNudHeigth.SetParameter(New RParameter("height", 5))
ucrNudHeigth.Maximum = 0.5
ucrNudHeigth.Minimum = 0
ucrNudHeigth.Increment = 0.01
ucrNudHeigth.DecimalPlaces = 2

ucrNudWidth.SetParameter(New RParameter("width", 6))
ucrNudWidth.Maximum = 0.5
ucrNudWidth.Minimum = 0
ucrNudWidth.Increment = 0.01
ucrNudWidth.DecimalPlaces = 2

ucrInputSides.SetParameter(New RParameter("sides", 1))
dctSidesOptions.Add("Bottom and left", Chr(34) & "bl" & Chr(34))
dctSidesOptions.Add("Top, right and bottom", Chr(34) & "trb" & Chr(34))
Expand All @@ -149,6 +168,8 @@ Public Class dlgScatterPlot
ucrInputSides.SetDropDownStyleAsNonEditable()

ucrNudSize.SetLinkedDisplayControl(lblSize)
ucrNudWidth.SetLinkedDisplayControl(lblWidth)
ucrNudHeigth.SetLinkedDisplayControl(lblHeith)
ucrInputSides.SetLinkedDisplayControl(lblSides)
End Sub

Expand All @@ -160,6 +181,7 @@ Public Class dlgScatterPlot
clsRaesFunction = New RFunction
clsGeomSmoothFunction = New RFunction
clsGeomRugFunction = New RFunction
clsGeomJitterFunction = New RFunction

ucrSelectorForScatter.Reset()
ucrSelectorForScatter.SetGgplotFunction(clsBaseOperator)
Expand All @@ -172,6 +194,7 @@ Public Class dlgScatterPlot
toolStripMenuItemRugOptions.Enabled = False
toolStripMenuItemSmoothOptions.Enabled = False
toolStripMenuItemTextrepelOptions.Enabled = False
toolStripMenuItemJitterOptions.Enabled = False

clsBaseOperator.SetOperation("+")
clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRggplotFunction, iPosition:=0)
Expand All @@ -196,6 +219,11 @@ Public Class dlgScatterPlot
clsGeomRugFunction.SetRCommand("geom_rug")
clsGeomRugFunction.AddParameter("size", 0.5, iPosition:=0)

clsGeomJitterFunction.SetPackageName("ggplot2")
clsGeomJitterFunction.SetRCommand("geom_jitter")
clsGeomJitterFunction.AddParameter("width", 0.4, iPosition:=0)
clsGeomJitterFunction.AddParameter("height", 0.4, iPosition:=1)

clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone())
clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone()
clsYlabsFunction = GgplotDefaults.clsYlabTitleFunction.Clone()
Expand Down Expand Up @@ -239,6 +267,11 @@ Public Class dlgScatterPlot
ucrChkWithSE.SetRCode(clsGeomSmoothFunction, bReset)
ucrChkAddRugPlot.SetRCode(clsBaseOperator, bReset)
ucrNudSize.SetRCode(clsGeomRugFunction, bReset)
If bReset Then
ucrChkJitter.SetRCode(clsBaseOperator, bReset)
End If
ucrNudHeigth.SetRCode(clsGeomJitterFunction, bReset)
ucrNudWidth.SetRCode(clsGeomJitterFunction, bReset)
ucrInputSides.SetRCode(clsGeomRugFunction, bReset)
End Sub

Expand Down Expand Up @@ -275,6 +308,19 @@ Public Class dlgScatterPlot
toolStripMenuItemRugOptions.Enabled = ucrChkAddRugPlot.Checked
End Sub

Private Sub ucrChkJitter_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkJitter.ControlValueChanged
If ucrChkJitter.Checked Then
clsGeomJitterFunction.AddParameter("width", ucrNudWidth.GetText, iPosition:=0)
clsGeomJitterFunction.AddParameter("height", ucrNudHeigth.GetText, iPosition:=1)
clsBaseOperator.AddParameter(strGeomJitterParameterName, clsRFunctionParameter:=clsGeomJitterFunction, iPosition:=2)
clsBaseOperator.RemoveParameterByName(strFirstParameterName)
Else
clsBaseOperator.AddParameter(strFirstParameterName, clsRFunctionParameter:=clsRScatterGeomFunction, iPosition:=2)
clsBaseOperator.RemoveParameterByName(strGeomJitterParameterName)
End If
toolStripMenuItemJitterOptions.Enabled = ucrChkJitter.Checked
End Sub

Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click, toolStripMenuItemPlotOptions.Click
sdgPlots.SetRCode(clsNewOperator:=ucrBase.clsRsyntax.clsBaseOperator, clsNewGlobalAesFunction:=clsRaesFunction,
clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction,
Expand Down Expand Up @@ -304,6 +350,10 @@ Public Class dlgScatterPlot
EnableDisableOptions(clsLabelFunction)
End Sub

Private Sub toolStripMenuItemJitterOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemJitterOptions.Click
EnableDisableOptions(clsGeomJitterFunction)
End Sub

Private Sub EnableDisableOptions(clsTempFunction As RFunction)
'SetupLayer sends the components storing the plot info (clsRaesFunction, clsRggplotFunction, ...) of dlgScatteredPlot through to sdgLayerOptions where these will be edited.
sdgLayerOptions.SetupLayer(clsNewGgPlot:=clsRggplotFunction, clsNewGeomFunc:=clsTempFunction,
Expand Down

0 comments on commit 4010200

Please sign in to comment.