diff --git a/instat/UcrGeomListWithAes.vb b/instat/UcrGeomListWithAes.vb index ef4c78eb9c2..2fee80b1525 100644 --- a/instat/UcrGeomListWithAes.vb +++ b/instat/UcrGeomListWithAes.vb @@ -300,6 +300,14 @@ Public Class ucrGeomListWithParameters SetReceiverColour() End Sub + Private Sub AddRFunctionParameter(parentFunction As RFunction, paramName As String, paramValue As String) + Dim clsProductFunction As New RFunction + clsProductFunction.SetPackageName("ggmosaic") + clsProductFunction.SetRCommand("product") + clsProductFunction.AddParameter(paramName, paramValue, bIncludeArgumentName:=False) + parentFunction.AddParameter(paramName, clsRFunctionParameter:=clsProductFunction) + End Sub + Public Sub UpdateGlobalAndLocalAesFromInter() Dim clsRelevantAesFunction As New RFunction 'Will be used in the partially mandatory aes filling method below. Dim clsCurrentAesFunction As RFunction @@ -342,6 +350,64 @@ Public Class ucrGeomListWithParameters clsCurrentAesFunction = clsLocalAesFunction End If + If clsGeomFunction.strRCommand = "geom_mosaic" Then + Dim xParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") + Dim condsParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "conds") + + If xParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(xParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "x", strArgNameValue) + End If + + If condsParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(condsParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "conds", strArgNameValue) + End If + + Dim xParameterGlobalIndex As Integer = clsGlobalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") + Dim condsParameterGlobalIndex As Integer = clsGlobalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "conds") + + If xParameterGlobalIndex >= 0 Then + Dim strArgNameValue = clsGlobalAesFunction.clsParameters(xParameterGlobalIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "x", strArgNameValue) + End If + + If condsParameterGlobalIndex >= 0 Then + Dim strArgNameValue = clsGlobalAesFunction.clsParameters(condsParameterGlobalIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "conds", strArgNameValue) + End If + End If + + If clsGeomFunction.strRCommand = "geom_mosaic_jitter" Then + Dim xParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") + Dim condsParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "conds") + + If xParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(xParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "x", strArgNameValue) + End If + + If condsParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(condsParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "conds", strArgNameValue) + End If + End If + + If clsGeomFunction.strRCommand = "geom_mosaic_text" Then + Dim xParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") + Dim condsParameterIndex As Integer = clsLocalAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "conds") + + If xParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(xParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "x", strArgNameValue) + End If + + If condsParameterIndex >= 0 Then + Dim strArgNameValue = clsLocalAesFunction.clsParameters(condsParameterIndex).strArgumentValue + AddRFunctionParameter(clsCurrentAesFunction, "conds", strArgNameValue) + End If + End If + 'This is a temporary solution to issue which should be solved with geoms 'This adds "" aes for x or y when no variables are mapped to them for geoms which require it, either adding to the global or local aes. If clsGeomFunction.strRCommand = "geom_boxplot" OrElse clsGeomFunction.strRCommand = "geom_dotplot" OrElse clsGeomFunction.strRCommand = "geom_violin" Then diff --git a/instat/ucrGeom.vb b/instat/ucrGeom.vb index 48dd0d564fd..0ab53b768c2 100644 --- a/instat/ucrGeom.vb +++ b/instat/ucrGeom.vb @@ -150,6 +150,8 @@ Public Class ucrGeom Dim clsgeom_lollipop As New Geoms Dim clsgeom_map As New Geoms Dim clsgeom_mosaic As New Geoms + Dim clsgeom_mosaic_text As New Geoms + Dim clsgeom_mosaic_jitter As New Geoms Dim clsgeom_parallel_slopes As New Geoms Dim clsgeom_path As New Geoms Dim clsgeom_point As New Geoms @@ -1457,10 +1459,10 @@ Public Class ucrGeom clsgeom_mosaic.SetGeomPackage("ggmosaic") clsgeom_mosaic.strGeomName = "geom_mosaic" 'mandatory - 'clsgeom_mosaic.AddAesParameter("x", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) - 'clsgeom_mosaic.AddAesParameter("fill", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) - 'clsgeom_mosaic.AddAesParameter("conds", strIncludedDataTypes:={"factor"}) - 'clsgeom_mosaic.AddAesParameter("weight", strIncludedDataTypes:={"numeric"}) + clsgeom_mosaic.AddAesParameter("x", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic.AddAesParameter("fill", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic.AddAesParameter("conds", strIncludedDataTypes:={"factor"}) + clsgeom_mosaic.AddAesParameter("weight", strIncludedDataTypes:={"numeric"}) 'adding layerParameters clsgeom_mosaic.AddLayerParameter("divider", "editablelist", "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", lstParameterStrings:={Chr(34) & "vspine" & Chr(34), Chr(34) & "hspine" & Chr(34), Chr(34) & "vbar" & Chr(34), Chr(34) & "hbar" & Chr(34), "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", "ggmosaic::mosaic(" & Chr(34) & "v" & Chr(34) & ")", "ggmosaic::ddecker()"}) @@ -1473,6 +1475,44 @@ Public Class ucrGeom clsgeom_mosaic.AddLayerParameter("show.legend", "list", "TRUE", lstParameterStrings:={"NA", "TRUE", "FALSE"}) lstAllGeoms.Add(clsgeom_mosaic) + clsgeom_mosaic_jitter.SetGeomPackage("ggmosaic") + clsgeom_mosaic_jitter.strGeomName = "geom_mosaic_jitter" + 'mandatory + clsgeom_mosaic_jitter.AddAesParameter("x", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_jitter.AddAesParameter("fill", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_jitter.AddAesParameter("conds", strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_jitter.AddAesParameter("color", strIncludedDataTypes:={"numeric"}) + + 'adding layerParameters + clsgeom_mosaic_jitter.AddLayerParameter("divider", "editablelist", "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", lstParameterStrings:={Chr(34) & "vspine" & Chr(34), Chr(34) & "hspine" & Chr(34), Chr(34) & "vbar" & Chr(34), Chr(34) & "hbar" & Chr(34), "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", "ggmosaic::mosaic(" & Chr(34) & "v" & Chr(34) & ")", "ggmosaic::ddecker()"}) + clsgeom_mosaic_jitter.AddLayerParameter("offset", "numeric", "0.01", lstParameterStrings:={2, 0, 1}) 'not sure if it goes beyond 1 + clsgeom_mosaic_jitter.AddLayerParameter("stat", "editablelist", Chr(34) & "mosaic" & Chr(34), lstParameterStrings:={Chr(34) & "mosaic" & Chr(34)}) ' Made this editable because am not sure what other stats go here + clsgeom_mosaic_jitter.AddLayerParameter("position", "editablelist", Chr(34) & "identity" & Chr(34), lstParameterStrings:={Chr(34) & "identity" & Chr(34)}) ' Made this editable because am not sure what other positions go here + clsgeom_mosaic_jitter.AddLayerParameter("colour", "colour", Chr(34) & "black" & Chr(34)) + clsgeom_mosaic_jitter.AddLayerParameter("size", "numeric", "1", lstParameterStrings:={1, 1}) + clsgeom_mosaic_jitter.AddLayerParameter("na.rm", "boolean", "FALSE") + clsgeom_mosaic_jitter.AddLayerParameter("show.legend", "list", "TRUE", lstParameterStrings:={"NA", "TRUE", "FALSE"}) + lstAllGeoms.Add(clsgeom_mosaic_jitter) + + clsgeom_mosaic_text.SetGeomPackage("ggmosaic") + clsgeom_mosaic_text.strGeomName = "geom_mosaic_text" + 'mandatory + clsgeom_mosaic_text.AddAesParameter("x", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_text.AddAesParameter("fill", bIsMandatory:=True, strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_text.AddAesParameter("conds", strIncludedDataTypes:={"factor"}) + clsgeom_mosaic_text.AddAesParameter("weight", strIncludedDataTypes:={"numeric"}) + + 'adding layerParameters + clsgeom_mosaic_text.AddLayerParameter("divider", "editablelist", "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", lstParameterStrings:={Chr(34) & "vspine" & Chr(34), Chr(34) & "hspine" & Chr(34), Chr(34) & "vbar" & Chr(34), Chr(34) & "hbar" & Chr(34), "ggmosaic::mosaic(" & Chr(34) & "h" & Chr(34) & ")", "ggmosaic::mosaic(" & Chr(34) & "v" & Chr(34) & ")", "ggmosaic::ddecker()"}) + clsgeom_mosaic_text.AddLayerParameter("offset", "numeric", "0.01", lstParameterStrings:={2, 0, 1}) 'not sure if it goes beyond 1 + clsgeom_mosaic_text.AddLayerParameter("stat", "editablelist", Chr(34) & "mosaic" & Chr(34), lstParameterStrings:={Chr(34) & "mosaic" & Chr(34)}) ' Made this editable because am not sure what other stats go here + clsgeom_mosaic_text.AddLayerParameter("position", "editablelist", Chr(34) & "identity" & Chr(34), lstParameterStrings:={Chr(34) & "identity" & Chr(34)}) ' Made this editable because am not sure what other positions go here + clsgeom_mosaic_text.AddLayerParameter("colour", "colour", Chr(34) & "black" & Chr(34)) + clsgeom_mosaic_text.AddLayerParameter("size", "numeric", "1", lstParameterStrings:={1, 1}) + clsgeom_mosaic_text.AddLayerParameter("na.rm", "boolean", "FALSE") + clsgeom_mosaic_text.AddLayerParameter("show.legend", "list", "TRUE", lstParameterStrings:={"NA", "TRUE", "FALSE"}) + lstAllGeoms.Add(clsgeom_mosaic_text) + clsgeom_parallel_slopes.SetGeomPackage("moderndive") clsgeom_parallel_slopes.SetGeomName("geom_parallel_slopes") 'Mandatory Aesthetics