Skip to content

Commit

Permalink
Merge pull request #8842 from Vitalis95/Scatter8836
Browse files Browse the repository at this point in the history
Improvement in scatterplot, when x is a factor
  • Loading branch information
N-thony authored Feb 27, 2024
2 parents 7df5e4c + a1dd3bd commit f1ef6a2
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions instat/dlgScatterPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Public Class dlgScatterPlot
Private clsRScatterGeomFunction, clsLabelFunction As New RFunction
Private clsRaesFunction As New RFunction
Private clsLocalRaesFunction As New RFunction
Private clsGroupAesFuction As New RFunction
Private clsGroupAesVarFuction As New RFunction
Private clsBaseOperator As New ROperator
Private bFirstLoad As Boolean = True
Private bReset As Boolean = True
Expand Down Expand Up @@ -294,6 +296,9 @@ Public Class dlgScatterPlot
clsFacetColOp = New ROperator
clsPipeOperator = New ROperator
clsGroupByFunction = New RFunction
clsGroupAesFuction = New RFunction
clsGroupAesVarFuction = New RFunction


ucrInputStation.SetName(strFacetWrap)
ucrInputStation.bUpdateRCodeFromControl = True
Expand Down Expand Up @@ -336,6 +341,12 @@ Public Class dlgScatterPlot
clsLabelFunction.SetPackageName("ggrepel")
clsLabelFunction.SetRCommand("geom_text_repel")

clsGroupAesFuction.SetPackageName("ggplot2")
clsGroupAesFuction.SetRCommand("aes")

clsGroupAesVarFuction.SetPackageName("ggplot2")
clsGroupAesVarFuction.SetRCommand("aes")

clsGeomRugFunction.SetPackageName("ggplot2")
clsGeomRugFunction.SetRCommand("geom_rug")
clsGeomRugFunction.AddParameter("size", 0.5, iPosition:=0)
Expand Down Expand Up @@ -688,6 +699,7 @@ Public Class dlgScatterPlot
Private Sub ucr1stFactorReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucr1stFactorReceiver.ControlValueChanged, ucrReceiverX.ControlValueChanged
AddRemoveFacets()
AddRemoveGroupBy()
AddRemoveGroupAesVar()
End Sub

Private Sub GetParameterValue(clsOperator As ROperator)
Expand Down Expand Up @@ -739,4 +751,35 @@ Public Class dlgScatterPlot
SetPipeAssignTo()
End Sub

Private Sub AddRemoveGroupAesVar()
clsGroupAesFuction.RemoveParameterByName("group")
clsGroupAesVarFuction.RemoveParameterByName("group")
clsGeomSmoothFunction.RemoveParameterByName("group_aes")
clsGeomSmoothFunction.RemoveParameterByName("group_aes1")
If Not ucrReceiverX.IsEmpty AndAlso ucrReceiverX.strCurrDataType = "factor" OrElse ucrReceiverX.strCurrDataType = "ordered,factor" Then
If Not ucrFactorOptionalReceiver.IsEmpty AndAlso ucrFactorOptionalReceiver.strCurrDataType = "factor" OrElse ucrFactorOptionalReceiver.strCurrDataType = "ordered,factor" Then
' Add group parameter with variable names
clsGroupAesFuction.AddParameter("group", ucrFactorOptionalReceiver.GetVariableNames(False), iPosition:=0)
clsGeomSmoothFunction.AddParameter("group_aes1", clsRFunctionParameter:=clsGroupAesFuction, bIncludeArgumentName:=False)
clsGroupAesVarFuction.RemoveParameterByName("group")
clsGeomSmoothFunction.RemoveParameterByName("group_aes")
Else
' Add group parameter without variable names
clsGroupAesVarFuction.AddParameter("group", 1, iPosition:=0)
clsGeomSmoothFunction.AddParameter("group_aes", clsRFunctionParameter:=clsGroupAesVarFuction, bIncludeArgumentName:=False)
clsGroupAesFuction.RemoveParameterByName("group")
clsGeomSmoothFunction.RemoveParameterByName("group_aes1")
End If
Else
' Remove group parameters
clsGroupAesFuction.RemoveParameterByName("group")
clsGroupAesVarFuction.RemoveParameterByName("group")
clsGeomSmoothFunction.RemoveParameterByName("group_aes")
clsGeomSmoothFunction.RemoveParameterByName("group_aes1")
End If
End Sub

Private Sub ucrFactorOptionalReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrFactorOptionalReceiver.ControlValueChanged
AddRemoveGroupAesVar()
End Sub
End Class

0 comments on commit f1ef6a2

Please sign in to comment.