From 281bcd29a54330bf5231f09da15e14a0f1537e7b Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Mon, 17 Jul 2023 08:42:34 +0100 Subject: [PATCH 01/10] minor change --- instat/dlgGeneralForGraphics.Designer.vb | 30 ++++++++++++-- instat/dlgGeneralForGraphics.vb | 52 ++++++++++++++++++++---- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/instat/dlgGeneralForGraphics.Designer.vb b/instat/dlgGeneralForGraphics.Designer.vb index 4dcf27bbb47..ed117757e07 100644 --- a/instat/dlgGeneralForGraphics.Designer.vb +++ b/instat/dlgGeneralForGraphics.Designer.vb @@ -50,6 +50,8 @@ Partial Class dlgGeneralForGraphics Me.ucrGraphicsSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrAdditionalLayers = New instat.ucrAdditionalLayers() Me.ucrBase = New instat.ucrButtons() + Me.ucrChkUseasNumeric = New instat.ucrCheck() + Me.ucrChkDisplayasFactor = New instat.ucrCheck() Me.SuspendLayout() ' 'cmdOptions @@ -78,7 +80,7 @@ Partial Class dlgGeneralForGraphics ' Me.lblFillOrColor.AutoSize = True Me.lblFillOrColor.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblFillOrColor.Location = New System.Drawing.Point(264, 231) + Me.lblFillOrColor.Location = New System.Drawing.Point(264, 316) Me.lblFillOrColor.Name = "lblFillOrColor" Me.lblFillOrColor.Size = New System.Drawing.Size(57, 13) Me.lblFillOrColor.TabIndex = 4 @@ -133,7 +135,7 @@ Partial Class dlgGeneralForGraphics ' Me.ucrFillOrColourReceiver.AutoSize = True Me.ucrFillOrColourReceiver.frmParent = Me - Me.ucrFillOrColourReceiver.Location = New System.Drawing.Point(262, 246) + Me.ucrFillOrColourReceiver.Location = New System.Drawing.Point(262, 331) Me.ucrFillOrColourReceiver.Margin = New System.Windows.Forms.Padding(0) Me.ucrFillOrColourReceiver.Name = "ucrFillOrColourReceiver" Me.ucrFillOrColourReceiver.Selector = Nothing @@ -181,15 +183,35 @@ Partial Class dlgGeneralForGraphics Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrBase.Location = New System.Drawing.Point(6, 464) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 9 ' + 'ucrChkUseasNumeric + ' + Me.ucrChkUseasNumeric.AutoSize = True + Me.ucrChkUseasNumeric.Checked = False + Me.ucrChkUseasNumeric.Location = New System.Drawing.Point(262, 233) + Me.ucrChkUseasNumeric.Name = "ucrChkUseasNumeric" + Me.ucrChkUseasNumeric.Size = New System.Drawing.Size(100, 23) + Me.ucrChkUseasNumeric.TabIndex = 20 + ' + 'ucrChkDisplayasFactor + ' + Me.ucrChkDisplayasFactor.AutoSize = True + Me.ucrChkDisplayasFactor.Checked = False + Me.ucrChkDisplayasFactor.Location = New System.Drawing.Point(262, 280) + Me.ucrChkDisplayasFactor.Name = "ucrChkDisplayasFactor" + Me.ucrChkDisplayasFactor.Size = New System.Drawing.Size(100, 23) + Me.ucrChkDisplayasFactor.TabIndex = 21 + ' 'dlgGeneralForGraphics ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(416, 519) + Me.Controls.Add(Me.ucrChkDisplayasFactor) + Me.Controls.Add(Me.ucrChkUseasNumeric) Me.Controls.Add(Me.cmdTheme) Me.Controls.Add(Me.cmdFacets) Me.Controls.Add(Me.ucrSave) @@ -226,4 +248,6 @@ Partial Class dlgGeneralForGraphics Friend WithEvents ucrSave As ucrSave Friend WithEvents cmdTheme As Button Friend WithEvents cmdFacets As Button + Friend WithEvents ucrChkDisplayasFactor As ucrCheck + Friend WithEvents ucrChkUseasNumeric As ucrCheck End Class diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index 4a6c454a5f2..7a2a01c04c3 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -87,6 +87,17 @@ Public Class dlgGeneralForGraphics ucrReceiverX.SetParameterIsString() ucrReceiverX.SetValuesToIgnore({Chr(34) & Chr(34)}) ucrReceiverX.bAddParameterIfEmpty = True + 'ucrReceiverX.SetLinkedDisplayControl(ucrChkUseasNumeric) + + ucrChkUseasNumeric.SetParameter(New RParameter("circular", 4)) + ucrChkUseasNumeric.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + ucrChkUseasNumeric.SetText("Use as Numeric") + ucrChkUseasNumeric.SetLinkedDisplayControl(ucrChkDisplayasFactor) + + ucrChkDisplayasFactor.SetParameter(New RParameter("circular", 4)) + ucrChkDisplayasFactor.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + ucrChkDisplayasFactor.SetText("Display as Factor") + 'ucrChkDisplayasFactor.SetLinkedDisplayControl(ucrChkDisplayasFactor) ucrFillOrColourReceiver.Selector = ucrGraphicsSelector ucrFillOrColourReceiver.SetIncludedDataTypes({"factor"}) @@ -100,6 +111,7 @@ Public Class dlgGeneralForGraphics ucrSave.SetCheckBoxText("Save Graph") ucrSave.SetDataFrameSelector(ucrGraphicsSelector.ucrAvailableDataFrames) ucrSave.SetAssignToIfUncheckedValue("last_graph") + 'VariableXType() End Sub Private Sub SetDefaults() @@ -157,12 +169,16 @@ Public Class dlgGeneralForGraphics ucrGraphicsSelector.SetRCode(clsGgplotFunction, bReset) ucrVariablesAsFactorForGraphics.SetRCode(clsGlobalAesFunction, bReset) ucrReceiverX.SetRCode(clsGlobalAesFunction, bReset) + ucrChkUseasNumeric.SetRCode(clsGlobalAesFunction, bReset) + ucrChkDisplayasFactor.SetRCode(clsGlobalAesFunction, bReset) ucrFillOrColourReceiver.SetRCode(clsGlobalAesFunction, bReset) ucrSave.SetRCode(clsBaseOperator, bReset) + VariableXType() End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() + VariableXType() SetRCodeForControls(True) TestOKEnabled() End Sub @@ -219,12 +235,7 @@ Public Class dlgGeneralForGraphics sdgPlots.EnableLayersTab() End Sub - Private Sub ucrVariablesAsFactorForGraphics_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorForGraphics.ControlValueChanged, ucrReceiverX.ControlValueChanged, ucrFillOrColourReceiver.ControlValueChanged - If Not ucrReceiverX.IsEmpty Then - clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) - Else - clsGlobalAesFunction.RemoveParameterByName("x") - End If + Private Sub ucrVariablesAsFactorForGraphics_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorForGraphics.ControlValueChanged, ucrFillOrColourReceiver.ControlValueChanged If Not ucrVariablesAsFactorForGraphics.IsEmpty Then clsGlobalAesFunction.AddParameter("y", ucrVariablesAsFactorForGraphics.GetVariableNames(False), iPosition:=1) Else @@ -237,7 +248,34 @@ Public Class dlgGeneralForGraphics End If End Sub - Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlContentsChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged + Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlValueChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrChkUseasNumeric.ControlValueChanged, ucrChkDisplayasFactor.ControlValueChanged TestOKEnabled() + VariableXType() End Sub + + Private Sub VariableXType() + 'ucrChkDisplayasFactor.Visible = False + 'ucrChkUseasNumeric.Visible = False + If Not ucrReceiverX.IsEmpty Then + 'clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) + 'If {"factor", "character"}.Contains(ucrReceiverX.strCurrDataType) Then + ' ucrChkUseasNumeric.Visible = True + 'ElseIf {"numeric", "integer"}.Contains(ucrReceiverX.strCurrDataType) OrElse {"date"}.Contains(ucrReceiverX.strCurrDataType) Then + ' ucrChkUseasNumeric.Visible = False + 'End If + If ucrReceiverX.strCurrDataType = "numeric" Then + ucrChkUseasNumeric.Checked = True + ucrChkUseasNumeric.Visible = True + Else + ucrChkUseasNumeric.Visible = False + End If + Else + clsGlobalAesFunction.RemoveParameterByName("x") + ucrChkDisplayasFactor.Visible = False + ucrChkUseasNumeric.Visible = False + End If + + End Sub + + End Class \ No newline at end of file From 68efa074ccf31f8087eedbce783ab362b674e905 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Mon, 17 Jul 2023 15:23:56 +0100 Subject: [PATCH 02/10] minor change --- instat/dlgGeneralForGraphics.vb | 74 ++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index 7a2a01c04c3..8f03a796ed0 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -24,7 +24,7 @@ Public Class dlgGeneralForGraphics 'list of completed layers. Private iLayerIndex As Integer 'current layer - Private clsGlobalAesFunction As New RFunction + Private clsGlobalAesFunction, clsAsNumericFunction, clsScaleContinuousFunction, clsLevelsFunction As New RFunction Private clsBaseOperator As ROperator Private strGlobalDataFrame As String Public bDataFrameSet As Boolean @@ -89,14 +89,17 @@ Public Class dlgGeneralForGraphics ucrReceiverX.bAddParameterIfEmpty = True 'ucrReceiverX.SetLinkedDisplayControl(ucrChkUseasNumeric) - ucrChkUseasNumeric.SetParameter(New RParameter("circular", 4)) + ucrChkUseasNumeric.SetParameter(New RParameter("check", 4)) ucrChkUseasNumeric.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkUseasNumeric.SetText("Use as Numeric") ucrChkUseasNumeric.SetLinkedDisplayControl(ucrChkDisplayasFactor) + ucrChkUseasNumeric.SetRDefault("FALSE") - ucrChkDisplayasFactor.SetParameter(New RParameter("circular", 4)) + ucrChkDisplayasFactor.SetParameter(New RParameter("check", 5)) ucrChkDisplayasFactor.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkDisplayasFactor.SetText("Display as Factor") + ucrChkDisplayasFactor.SetRDefault("FALSE") + 'ucrChkDisplayasFactor.SetLinkedDisplayControl(ucrChkDisplayasFactor) ucrFillOrColourReceiver.Selector = ucrGraphicsSelector @@ -111,13 +114,16 @@ Public Class dlgGeneralForGraphics ucrSave.SetCheckBoxText("Save Graph") ucrSave.SetDataFrameSelector(ucrGraphicsSelector.ucrAvailableDataFrames) ucrSave.SetAssignToIfUncheckedValue("last_graph") - 'VariableXType() End Sub Private Sub SetDefaults() clsGgplotFunction = New RFunction clsGlobalAesFunction = New RFunction + clsAsNumericFunction = New RFunction + clsScaleContinuousFunction = New RFunction + clsLevelsFunction = New RFunction clsBaseOperator = New ROperator + 'clsDollarOperator = New ROperator ucrSave.Reset() @@ -138,6 +144,26 @@ Public Class dlgGeneralForGraphics clsGlobalAesFunction.SetPackageName("ggplot2") clsGlobalAesFunction.SetRCommand("aes") + clsAsNumericFunction.SetRCommand("as.numeric") + + clsLevelsFunction.SetPackageName("base") + clsLevelsFunction.SetRCommand("levels") + clsLevelsFunction.AddParameter("y", ucrReceiverX.GetVariableNames(False), bIncludeArgumentName:=False, iPosition:=0) + + clsScaleContinuousFunction.SetPackageName("ggplot2") + clsScaleContinuousFunction.SetRCommand("scale_x_continuous") + clsScaleContinuousFunction.AddParameter("breaks", "1:12", iPosition:=1) + clsScaleContinuousFunction.AddParameter("labels", clsRFunctionParameter:=clsLevelsFunction, iPosition:=2) + 'clsDollarOperator.SetOperation("$") + 'clsDollarOperator.bSpaceAroundOperation = False + 'clsDollarOperator.AddParameter("left", ucrGraphicsSelector.strCurrentDataFrame, bIncludeArgumentName:=False, iPosition:=0) + 'clsDollarOperator.AddParameter("right", ucrReceiverX.GetVariableNames(False), bIncludeArgumentName:=False, iPosition:=1) + + + + 'clsScaleContinuousFunction.AddParameter("vjust", "-0.25", iPosition:=3) + 'clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) + clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsYlabsFunction = GgplotDefaults.clsYlabTitleFunction.Clone() clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() @@ -166,11 +192,13 @@ Public Class dlgGeneralForGraphics End Sub Private Sub SetRCodeForControls(bReset As Boolean) + ucrReceiverX.AddAdditionalCodeParameterPair(clsAsNumericFunction, New RParameter("x", ucrReceiverX.GetVariableNames(False), bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) + ucrReceiverX.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("y", ucrReceiverX.GetVariableNames(False), bNewIncludeArgumentName:=False), iAdditionalPairNo:=2) ucrGraphicsSelector.SetRCode(clsGgplotFunction, bReset) ucrVariablesAsFactorForGraphics.SetRCode(clsGlobalAesFunction, bReset) ucrReceiverX.SetRCode(clsGlobalAesFunction, bReset) ucrChkUseasNumeric.SetRCode(clsGlobalAesFunction, bReset) - ucrChkDisplayasFactor.SetRCode(clsGlobalAesFunction, bReset) + ucrChkDisplayasFactor.SetRCode(clsScaleContinuousFunction, bReset) ucrFillOrColourReceiver.SetRCode(clsGlobalAesFunction, bReset) ucrSave.SetRCode(clsBaseOperator, bReset) VariableXType() @@ -178,7 +206,6 @@ Public Class dlgGeneralForGraphics Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() - VariableXType() SetRCodeForControls(True) TestOKEnabled() End Sub @@ -248,34 +275,51 @@ Public Class dlgGeneralForGraphics End If End Sub - Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlValueChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrChkUseasNumeric.ControlValueChanged, ucrChkDisplayasFactor.ControlValueChanged + Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlContentsChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrChkUseasNumeric.ControlContentsChanged, ucrChkDisplayasFactor.ControlContentsChanged TestOKEnabled() - VariableXType() End Sub Private Sub VariableXType() - 'ucrChkDisplayasFactor.Visible = False - 'ucrChkUseasNumeric.Visible = False + ucrChkDisplayasFactor.Visible = False + ucrChkUseasNumeric.Visible = False If Not ucrReceiverX.IsEmpty Then - 'clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) + clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) 'If {"factor", "character"}.Contains(ucrReceiverX.strCurrDataType) Then ' ucrChkUseasNumeric.Visible = True 'ElseIf {"numeric", "integer"}.Contains(ucrReceiverX.strCurrDataType) OrElse {"date"}.Contains(ucrReceiverX.strCurrDataType) Then ' ucrChkUseasNumeric.Visible = False 'End If - If ucrReceiverX.strCurrDataType = "numeric" Then - ucrChkUseasNumeric.Checked = True + If ucrReceiverX.strCurrDataType = "factor" Then ucrChkUseasNumeric.Visible = True Else ucrChkUseasNumeric.Visible = False End If + If ucrChkUseasNumeric.Checked Then + clsGlobalAesFunction.AddParameter("x", clsRFunctionParameter:=clsAsNumericFunction, iPosition:=0) + clsGlobalAesFunction.RemoveParameterByName("check") + ucrChkDisplayasFactor.Visible = True + Else + clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) + + ucrChkDisplayasFactor.Visible = False + End If + If ucrChkDisplayasFactor.Checked Then + clsBaseOperator.AddParameter("scale_continuous", clsRFunctionParameter:=clsScaleContinuousFunction, iPosition:=3) + clsScaleContinuousFunction.RemoveParameterByName("check") + Else + clsBaseOperator.RemoveParameterByName("scale_continuous") + End If Else clsGlobalAesFunction.RemoveParameterByName("x") - ucrChkDisplayasFactor.Visible = False - ucrChkUseasNumeric.Visible = False + 'ucrChkDisplayasFactor.Visible = False + ' ucrChkUseasNumeric.Visible = False End If End Sub + + Private Sub ucrReceiverX_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverX.ControlValueChanged, ucrChkUseasNumeric.ControlValueChanged, ucrChkDisplayasFactor.ControlValueChanged + VariableXType() + End Sub End Class \ No newline at end of file From d4c944910139fcd6c1cc2e8fb570387738f9234a Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Tue, 18 Jul 2023 12:12:10 +0100 Subject: [PATCH 03/10] Added Use as Numeric and Display as Factor checkbox --- instat/dlgGeneralForGraphics.Designer.vb | 4 ++-- instat/dlgGeneralForGraphics.vb | 22 ---------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/instat/dlgGeneralForGraphics.Designer.vb b/instat/dlgGeneralForGraphics.Designer.vb index ed117757e07..e0a6a024414 100644 --- a/instat/dlgGeneralForGraphics.Designer.vb +++ b/instat/dlgGeneralForGraphics.Designer.vb @@ -192,7 +192,7 @@ Partial Class dlgGeneralForGraphics Me.ucrChkUseasNumeric.Checked = False Me.ucrChkUseasNumeric.Location = New System.Drawing.Point(262, 233) Me.ucrChkUseasNumeric.Name = "ucrChkUseasNumeric" - Me.ucrChkUseasNumeric.Size = New System.Drawing.Size(100, 23) + Me.ucrChkUseasNumeric.Size = New System.Drawing.Size(125, 23) Me.ucrChkUseasNumeric.TabIndex = 20 ' 'ucrChkDisplayasFactor @@ -201,7 +201,7 @@ Partial Class dlgGeneralForGraphics Me.ucrChkDisplayasFactor.Checked = False Me.ucrChkDisplayasFactor.Location = New System.Drawing.Point(262, 280) Me.ucrChkDisplayasFactor.Name = "ucrChkDisplayasFactor" - Me.ucrChkDisplayasFactor.Size = New System.Drawing.Size(100, 23) + Me.ucrChkDisplayasFactor.Size = New System.Drawing.Size(125, 23) Me.ucrChkDisplayasFactor.TabIndex = 21 ' 'dlgGeneralForGraphics diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index 8f03a796ed0..f61f4645274 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -87,7 +87,6 @@ Public Class dlgGeneralForGraphics ucrReceiverX.SetParameterIsString() ucrReceiverX.SetValuesToIgnore({Chr(34) & Chr(34)}) ucrReceiverX.bAddParameterIfEmpty = True - 'ucrReceiverX.SetLinkedDisplayControl(ucrChkUseasNumeric) ucrChkUseasNumeric.SetParameter(New RParameter("check", 4)) ucrChkUseasNumeric.SetValuesCheckedAndUnchecked("TRUE", "FALSE") @@ -100,8 +99,6 @@ Public Class dlgGeneralForGraphics ucrChkDisplayasFactor.SetText("Display as Factor") ucrChkDisplayasFactor.SetRDefault("FALSE") - 'ucrChkDisplayasFactor.SetLinkedDisplayControl(ucrChkDisplayasFactor) - ucrFillOrColourReceiver.Selector = ucrGraphicsSelector ucrFillOrColourReceiver.SetIncludedDataTypes({"factor"}) ucrFillOrColourReceiver.strSelectorHeading = "Factors" @@ -123,7 +120,6 @@ Public Class dlgGeneralForGraphics clsScaleContinuousFunction = New RFunction clsLevelsFunction = New RFunction clsBaseOperator = New ROperator - 'clsDollarOperator = New ROperator ucrSave.Reset() @@ -154,15 +150,6 @@ Public Class dlgGeneralForGraphics clsScaleContinuousFunction.SetRCommand("scale_x_continuous") clsScaleContinuousFunction.AddParameter("breaks", "1:12", iPosition:=1) clsScaleContinuousFunction.AddParameter("labels", clsRFunctionParameter:=clsLevelsFunction, iPosition:=2) - 'clsDollarOperator.SetOperation("$") - 'clsDollarOperator.bSpaceAroundOperation = False - 'clsDollarOperator.AddParameter("left", ucrGraphicsSelector.strCurrentDataFrame, bIncludeArgumentName:=False, iPosition:=0) - 'clsDollarOperator.AddParameter("right", ucrReceiverX.GetVariableNames(False), bIncludeArgumentName:=False, iPosition:=1) - - - - 'clsScaleContinuousFunction.AddParameter("vjust", "-0.25", iPosition:=3) - 'clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsYlabsFunction = GgplotDefaults.clsYlabTitleFunction.Clone() @@ -284,11 +271,6 @@ Public Class dlgGeneralForGraphics ucrChkUseasNumeric.Visible = False If Not ucrReceiverX.IsEmpty Then clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) - 'If {"factor", "character"}.Contains(ucrReceiverX.strCurrDataType) Then - ' ucrChkUseasNumeric.Visible = True - 'ElseIf {"numeric", "integer"}.Contains(ucrReceiverX.strCurrDataType) OrElse {"date"}.Contains(ucrReceiverX.strCurrDataType) Then - ' ucrChkUseasNumeric.Visible = False - 'End If If ucrReceiverX.strCurrDataType = "factor" Then ucrChkUseasNumeric.Visible = True Else @@ -311,14 +293,10 @@ Public Class dlgGeneralForGraphics End If Else clsGlobalAesFunction.RemoveParameterByName("x") - 'ucrChkDisplayasFactor.Visible = False - ' ucrChkUseasNumeric.Visible = False End If End Sub - - Private Sub ucrReceiverX_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverX.ControlValueChanged, ucrChkUseasNumeric.ControlValueChanged, ucrChkDisplayasFactor.ControlValueChanged VariableXType() End Sub From 8b9870dc1ebb2ce327ae09c4d1654f3e06d59b48 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Wed, 6 Sep 2023 12:59:57 +0100 Subject: [PATCH 04/10] Minor change --- instat/dlgGeneralForGraphics.Designer.vb | 18 ++------ instat/dlgGeneralForGraphics.vb | 56 +++++++++--------------- 2 files changed, 24 insertions(+), 50 deletions(-) diff --git a/instat/dlgGeneralForGraphics.Designer.vb b/instat/dlgGeneralForGraphics.Designer.vb index e0a6a024414..248ecaa41e1 100644 --- a/instat/dlgGeneralForGraphics.Designer.vb +++ b/instat/dlgGeneralForGraphics.Designer.vb @@ -51,7 +51,6 @@ Partial Class dlgGeneralForGraphics Me.ucrAdditionalLayers = New instat.ucrAdditionalLayers() Me.ucrBase = New instat.ucrButtons() Me.ucrChkUseasNumeric = New instat.ucrCheck() - Me.ucrChkDisplayasFactor = New instat.ucrCheck() Me.SuspendLayout() ' 'cmdOptions @@ -80,7 +79,7 @@ Partial Class dlgGeneralForGraphics ' Me.lblFillOrColor.AutoSize = True Me.lblFillOrColor.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblFillOrColor.Location = New System.Drawing.Point(264, 316) + Me.lblFillOrColor.Location = New System.Drawing.Point(264, 280) Me.lblFillOrColor.Name = "lblFillOrColor" Me.lblFillOrColor.Size = New System.Drawing.Size(57, 13) Me.lblFillOrColor.TabIndex = 4 @@ -135,7 +134,7 @@ Partial Class dlgGeneralForGraphics ' Me.ucrFillOrColourReceiver.AutoSize = True Me.ucrFillOrColourReceiver.frmParent = Me - Me.ucrFillOrColourReceiver.Location = New System.Drawing.Point(262, 331) + Me.ucrFillOrColourReceiver.Location = New System.Drawing.Point(262, 295) Me.ucrFillOrColourReceiver.Margin = New System.Windows.Forms.Padding(0) Me.ucrFillOrColourReceiver.Name = "ucrFillOrColourReceiver" Me.ucrFillOrColourReceiver.Selector = Nothing @@ -190,27 +189,17 @@ Partial Class dlgGeneralForGraphics ' Me.ucrChkUseasNumeric.AutoSize = True Me.ucrChkUseasNumeric.Checked = False - Me.ucrChkUseasNumeric.Location = New System.Drawing.Point(262, 233) + Me.ucrChkUseasNumeric.Location = New System.Drawing.Point(262, 241) Me.ucrChkUseasNumeric.Name = "ucrChkUseasNumeric" Me.ucrChkUseasNumeric.Size = New System.Drawing.Size(125, 23) Me.ucrChkUseasNumeric.TabIndex = 20 ' - 'ucrChkDisplayasFactor - ' - Me.ucrChkDisplayasFactor.AutoSize = True - Me.ucrChkDisplayasFactor.Checked = False - Me.ucrChkDisplayasFactor.Location = New System.Drawing.Point(262, 280) - Me.ucrChkDisplayasFactor.Name = "ucrChkDisplayasFactor" - Me.ucrChkDisplayasFactor.Size = New System.Drawing.Size(125, 23) - Me.ucrChkDisplayasFactor.TabIndex = 21 - ' 'dlgGeneralForGraphics ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(416, 519) - Me.Controls.Add(Me.ucrChkDisplayasFactor) Me.Controls.Add(Me.ucrChkUseasNumeric) Me.Controls.Add(Me.cmdTheme) Me.Controls.Add(Me.cmdFacets) @@ -248,6 +237,5 @@ Partial Class dlgGeneralForGraphics Friend WithEvents ucrSave As ucrSave Friend WithEvents cmdTheme As Button Friend WithEvents cmdFacets As Button - Friend WithEvents ucrChkDisplayasFactor As ucrCheck Friend WithEvents ucrChkUseasNumeric As ucrCheck End Class diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index f61f4645274..ad6427461ac 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -24,7 +24,7 @@ Public Class dlgGeneralForGraphics 'list of completed layers. Private iLayerIndex As Integer 'current layer - Private clsGlobalAesFunction, clsAsNumericFunction, clsScaleContinuousFunction, clsLevelsFunction As New RFunction + Private clsGlobalAesFunction, clsScaleContinuousFunction, clsLevelsFunction As New RFunction Private clsBaseOperator As ROperator Private strGlobalDataFrame As String Public bDataFrameSet As Boolean @@ -47,6 +47,7 @@ Public Class dlgGeneralForGraphics Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsAnnotateFunction As New RFunction + Private clsDummyFunction As New RFunction Private Sub dlgGeneralForGraphics_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then @@ -88,16 +89,9 @@ Public Class dlgGeneralForGraphics ucrReceiverX.SetValuesToIgnore({Chr(34) & Chr(34)}) ucrReceiverX.bAddParameterIfEmpty = True - ucrChkUseasNumeric.SetParameter(New RParameter("check", 4)) - ucrChkUseasNumeric.SetValuesCheckedAndUnchecked("TRUE", "FALSE") - ucrChkUseasNumeric.SetText("Use as Numeric") - ucrChkUseasNumeric.SetLinkedDisplayControl(ucrChkDisplayasFactor) - ucrChkUseasNumeric.SetRDefault("FALSE") - - ucrChkDisplayasFactor.SetParameter(New RParameter("check", 5)) - ucrChkDisplayasFactor.SetValuesCheckedAndUnchecked("TRUE", "FALSE") - ucrChkDisplayasFactor.SetText("Display as Factor") - ucrChkDisplayasFactor.SetRDefault("FALSE") + ucrChkUseasNumeric.SetText("Group X") + ucrChkUseasNumeric.AddParameterValuesCondition(True, "group", "True") + ucrChkUseasNumeric.AddParameterValuesCondition(False, "group", "False") ucrFillOrColourReceiver.Selector = ucrGraphicsSelector ucrFillOrColourReceiver.SetIncludedDataTypes({"factor"}) @@ -111,15 +105,16 @@ Public Class dlgGeneralForGraphics ucrSave.SetCheckBoxText("Save Graph") ucrSave.SetDataFrameSelector(ucrGraphicsSelector.ucrAvailableDataFrames) ucrSave.SetAssignToIfUncheckedValue("last_graph") + VariableXType() End Sub Private Sub SetDefaults() clsGgplotFunction = New RFunction clsGlobalAesFunction = New RFunction - clsAsNumericFunction = New RFunction clsScaleContinuousFunction = New RFunction clsLevelsFunction = New RFunction clsBaseOperator = New ROperator + clsDummyFunction = New RFunction ucrSave.Reset() @@ -129,6 +124,8 @@ Public Class dlgGeneralForGraphics bDataFrameSet = False bResetOptionsSubdialog = True + clsDummyFunction.AddParameter("group", "false", iPosition:=0) + clsBaseOperator.SetOperation("+") clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsGgplotFunction, iPosition:=0) clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) @@ -140,8 +137,6 @@ Public Class dlgGeneralForGraphics clsGlobalAesFunction.SetPackageName("ggplot2") clsGlobalAesFunction.SetRCommand("aes") - clsAsNumericFunction.SetRCommand("as.numeric") - clsLevelsFunction.SetPackageName("base") clsLevelsFunction.SetRCommand("levels") clsLevelsFunction.AddParameter("y", ucrReceiverX.GetVariableNames(False), bIncludeArgumentName:=False, iPosition:=0) @@ -179,16 +174,15 @@ Public Class dlgGeneralForGraphics End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrReceiverX.AddAdditionalCodeParameterPair(clsAsNumericFunction, New RParameter("x", ucrReceiverX.GetVariableNames(False), bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) - ucrReceiverX.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("y", ucrReceiverX.GetVariableNames(False), bNewIncludeArgumentName:=False), iAdditionalPairNo:=2) + ucrReceiverX.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("y", ucrReceiverX.GetVariableNames(False), bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) ucrGraphicsSelector.SetRCode(clsGgplotFunction, bReset) ucrVariablesAsFactorForGraphics.SetRCode(clsGlobalAesFunction, bReset) + If bReset Then + ucrChkUseasNumeric.SetRCode(clsDummyFunction, bReset) + End If ucrReceiverX.SetRCode(clsGlobalAesFunction, bReset) - ucrChkUseasNumeric.SetRCode(clsGlobalAesFunction, bReset) - ucrChkDisplayasFactor.SetRCode(clsScaleContinuousFunction, bReset) ucrFillOrColourReceiver.SetRCode(clsGlobalAesFunction, bReset) ucrSave.SetRCode(clsBaseOperator, bReset) - VariableXType() End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -262,12 +256,15 @@ Public Class dlgGeneralForGraphics End If End Sub - Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlContentsChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrChkUseasNumeric.ControlContentsChanged, ucrChkDisplayasFactor.ControlContentsChanged + Private Sub AllControl_ControlContentsChanged() Handles ucrReceiverX.ControlContentsChanged, ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrChkUseasNumeric.ControlContentsChanged TestOKEnabled() End Sub + Private Sub AllControl_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrReceiverX.ControlContentsChanged, ucrChkUseasNumeric.ControlContentsChanged + + End Sub + Private Sub VariableXType() - ucrChkDisplayasFactor.Visible = False ucrChkUseasNumeric.Visible = False If Not ucrReceiverX.IsEmpty Then clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) @@ -277,27 +274,16 @@ Public Class dlgGeneralForGraphics ucrChkUseasNumeric.Visible = False End If If ucrChkUseasNumeric.Checked Then - clsGlobalAesFunction.AddParameter("x", clsRFunctionParameter:=clsAsNumericFunction, iPosition:=0) - clsGlobalAesFunction.RemoveParameterByName("check") - ucrChkDisplayasFactor.Visible = True + clsGlobalAesFunction.AddParameter("group", "1", iPosition:=2) Else - clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) - - ucrChkDisplayasFactor.Visible = False - End If - If ucrChkDisplayasFactor.Checked Then - clsBaseOperator.AddParameter("scale_continuous", clsRFunctionParameter:=clsScaleContinuousFunction, iPosition:=3) - clsScaleContinuousFunction.RemoveParameterByName("check") - Else - clsBaseOperator.RemoveParameterByName("scale_continuous") + clsGlobalAesFunction.RemoveParameterByName("group") End If Else clsGlobalAesFunction.RemoveParameterByName("x") End If - End Sub - Private Sub ucrReceiverX_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverX.ControlValueChanged, ucrChkUseasNumeric.ControlValueChanged, ucrChkDisplayasFactor.ControlValueChanged + Private Sub ucrReceiverX_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverX.ControlValueChanged, ucrChkUseasNumeric.ControlValueChanged VariableXType() End Sub End Class \ No newline at end of file From 33153c0247514f60d2ad4acf8e2e77c78d59dad5 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Wed, 6 Sep 2023 14:13:50 +0100 Subject: [PATCH 05/10] minor change --- instat/dlgGeneralForGraphics.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index ad6427461ac..3f874f59df9 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -214,6 +214,7 @@ Public Class dlgGeneralForGraphics Private Sub ucrAdditionalLayers_NumberOfLayersChanged() Handles ucrAdditionalLayers.NumberOfLayersChanged 'When the number of Layers in the lstLayers on ucrAdditionalLayers need to check if OK is enabled on dlgGeneralForGraphics. 'TestOKEnabled() + VariableXType() End Sub Private Sub cmdFacets_Click(sender As Object, e As EventArgs) Handles cmdFacets.Click From 8599df4a17a6cf11413b09715ed0d1505d142166 Mon Sep 17 00:00:00 2001 From: MeSophie <106779233+MeSophie@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:52:38 +0100 Subject: [PATCH 06/10] Update instat/dlgGeneralForGraphics.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/dlgGeneralForGraphics.vb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index 3f874f59df9..bf46fa028b8 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -269,11 +269,7 @@ Public Class dlgGeneralForGraphics ucrChkUseasNumeric.Visible = False If Not ucrReceiverX.IsEmpty Then clsGlobalAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) - If ucrReceiverX.strCurrDataType = "factor" Then - ucrChkUseasNumeric.Visible = True - Else - ucrChkUseasNumeric.Visible = False - End If + ucrChkUseasNumeric.Visible = ucrReceiverX.strCurrDataType = "factor" If ucrChkUseasNumeric.Checked Then clsGlobalAesFunction.AddParameter("group", "1", iPosition:=2) Else From 5368c1e8b34d7948a52348b0eb8dab34654140a6 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Fri, 8 Sep 2023 10:54:57 +0100 Subject: [PATCH 07/10] minor change --- instat/dlgGeneralForGraphics.vb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/instat/dlgGeneralForGraphics.vb b/instat/dlgGeneralForGraphics.vb index bf46fa028b8..3cd569aceb2 100644 --- a/instat/dlgGeneralForGraphics.vb +++ b/instat/dlgGeneralForGraphics.vb @@ -261,10 +261,6 @@ Public Class dlgGeneralForGraphics TestOKEnabled() End Sub - Private Sub AllControl_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorForGraphics.ControlContentsChanged, ucrSave.ControlContentsChanged, ucrReceiverX.ControlContentsChanged, ucrChkUseasNumeric.ControlContentsChanged - - End Sub - Private Sub VariableXType() ucrChkUseasNumeric.Visible = False If Not ucrReceiverX.IsEmpty Then From db6d24a59b1c9a2e31de54eb176c41107cb3b5ba Mon Sep 17 00:00:00 2001 From: Barbra2020 Date: Thu, 21 Sep 2023 13:21:22 +0300 Subject: [PATCH 08/10] Adding functions --- instat/dlgHistogram.designer.vb | 33 ++++++++- instat/dlgHistogram.vb | 124 +++++++++++++++++++++++++++++--- 2 files changed, 144 insertions(+), 13 deletions(-) diff --git a/instat/dlgHistogram.designer.vb b/instat/dlgHistogram.designer.vb index 2b13fdbd1c5..46b7178c5f8 100644 --- a/instat/dlgHistogram.designer.vb +++ b/instat/dlgHistogram.designer.vb @@ -62,6 +62,8 @@ Partial Class dlgHistogram Me.ucrHistogramSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrPnlOptions = New instat.UcrPanel() + Me.lblReorder = New System.Windows.Forms.Label() + Me.ucrInputAddReorder = New instat.ucrInputComboBox() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -234,7 +236,7 @@ Partial Class dlgHistogram 'ucrSaveHist ' Me.ucrSaveHist.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveHist.Location = New System.Drawing.Point(10, 311) + Me.ucrSaveHist.Location = New System.Drawing.Point(10, 342) Me.ucrSaveHist.Margin = New System.Windows.Forms.Padding(5) Me.ucrSaveHist.Name = "ucrSaveHist" Me.ucrSaveHist.Size = New System.Drawing.Size(322, 24) @@ -283,7 +285,7 @@ Partial Class dlgHistogram ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(10, 334) + Me.ucrBase.Location = New System.Drawing.Point(10, 365) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) @@ -298,12 +300,35 @@ Partial Class dlgHistogram Me.ucrPnlOptions.Size = New System.Drawing.Size(433, 30) Me.ucrPnlOptions.TabIndex = 0 ' + 'lblReorder + ' + Me.lblReorder.AutoSize = True + Me.lblReorder.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblReorder.Location = New System.Drawing.Point(286, 298) + Me.lblReorder.Name = "lblReorder" + Me.lblReorder.Size = New System.Drawing.Size(48, 13) + Me.lblReorder.TabIndex = 38 + Me.lblReorder.Text = "Reorder:" + ' + 'ucrInputAddReorder + ' + Me.ucrInputAddReorder.AddQuotesIfUnrecognised = True + Me.ucrInputAddReorder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputAddReorder.GetSetSelectedIndex = -1 + Me.ucrInputAddReorder.IsReadOnly = False + Me.ucrInputAddReorder.Location = New System.Drawing.Point(287, 314) + Me.ucrInputAddReorder.Name = "ucrInputAddReorder" + Me.ucrInputAddReorder.Size = New System.Drawing.Size(120, 21) + Me.ucrInputAddReorder.TabIndex = 39 + ' 'dlgHistogram ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(448, 394) + Me.ClientSize = New System.Drawing.Size(448, 422) + Me.Controls.Add(Me.lblReorder) + Me.Controls.Add(Me.ucrInputAddReorder) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.ucrChkDisplayAsDotPlot) Me.Controls.Add(Me.ucrChkRidges) @@ -355,4 +380,6 @@ Partial Class dlgHistogram Friend WithEvents toolStripMenuItemDensityRidgesOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemFrequencyPolygonOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemDotOptions As ToolStripMenuItem + Friend WithEvents lblReorder As Label + Friend WithEvents ucrInputAddReorder As ucrInputComboBox End Class \ No newline at end of file diff --git a/instat/dlgHistogram.vb b/instat/dlgHistogram.vb index 4d8fce75cc8..0cebbb3384c 100644 --- a/instat/dlgHistogram.vb +++ b/instat/dlgHistogram.vb @@ -43,6 +43,14 @@ Public Class dlgHistogram Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsAnnotateFunction As New RFunction + Private clsForecatsReverse As New RFunction + Private clsForecatsInfreqValue As New RFunction + Private clsForecatsReverseValue As New RFunction + + Private ReadOnly strAscending As String = "Ascending" + Private ReadOnly strDescending As String = "Descending" + Private ReadOnly strReverse As String = "Reverse" + Private ReadOnly strNone As String = "None" 'Parameter names for geoms Private strFirstParameterName As String = "geomfunc" @@ -119,6 +127,10 @@ Public Class dlgHistogram ucrVariablesAsFactorforHist.bWithQuotes = False ucrVariablesAsFactorforHist.SetParameterIsString() + ucrInputAddReorder.SetItems({strAscending, strDescending, strReverse, strNone}) + ucrInputAddReorder.SetDropDownStyleAsNonEditable() + ucrInputAddReorder.SetLinkedDisplayControl(lblReorder) + ucrPnlOptions.AddToLinkedControls({ucrChkDisplayAsDotPlot}, {rdoHistogram}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrChkRidges}, {rdoDensity_ridges}, bNewLinkedHideIfParameterMissing:=True) ucrChkRidges.AddToLinkedControls(ucrInputStats, {"FALSE"}, bNewLinkedHideIfParameterMissing:=True) @@ -139,6 +151,9 @@ Public Class dlgHistogram clsRaesFunction = New RFunction clsHistAesFunction = New RFunction clsPercentage = New RFunction + clsForecatsReverse = New RFunction + clsForecatsInfreqValue = New RFunction + clsForecatsReverseValue = New RFunction ucrHistogramSelector.Reset() ucrHistogramSelector.SetGgplotFunction(clsBaseOperator) ucrSaveHist.Reset() @@ -146,6 +161,9 @@ Public Class dlgHistogram bResetSubdialog = True bResetHistLayerSubdialog = True + ucrInputAddReorder.SetText(strNone) + ucrInputAddReorder.bUpdateRCodeFromControl = True + clsBaseOperator.SetOperation("+") clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRggplotFunction, iPosition:=0) clsBaseOperator.AddParameter(strFirstParameterName, clsRFunctionParameter:=clsRgeomPlotFunction, iPosition:=2) @@ -168,6 +186,15 @@ Public Class dlgHistogram clsPercentage.SetPackageName("scales") clsPercentage.SetRCommand("percent_format") + clsForecatsReverse.SetPackageName("forcats") + clsForecatsReverse.SetRCommand("fct_rev") + + clsForecatsReverseValue.SetPackageName("forcats") + clsForecatsReverseValue.SetRCommand("fct_rev") + + clsForecatsInfreqValue.SetPackageName("forcats") + clsForecatsInfreqValue.SetRCommand("fct_infreq") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsYlabFunction = GgplotDefaults.clsYlabTitleFunction.Clone() @@ -198,10 +225,10 @@ Public Class dlgHistogram ucrChkPercentages.SetRCode(clsYScalecontinuousFunction, bReset) ucrChkDisplayAsDotPlot.SetRCode(clsRgeomPlotFunction, bReset) ucrChkRidges.SetRCode(clsRgeomPlotFunction, bReset) - ucrFactorReceiver.SetRCode(clsRaesFunction, bReset) ucrVariablesAsFactorforHist.SetRCode(clsRaesFunction, bReset) If bReset Then ucrInputStats.SetRCode(clsHistAesFunction, bReset) + ucrFactorReceiver.SetRCode(clsRaesFunction, bReset) End If End Sub @@ -225,6 +252,8 @@ Public Class dlgHistogram clsHistAesFunction.RemoveParameterByName("y") clsHistAesFunction.AddParameter("y", "stat(count)", iPosition:=0) clsRgeomPlotFunction.SetPackageName("ggplot2") + ucrInputAddReorder.Visible = Not ucrFactorReceiver.IsEmpty() + If rdoHistogram.Checked Then If ucrChkDisplayAsDotPlot.Checked Then clsRgeomPlotFunction.SetRCommand("geom_dotplot") @@ -242,12 +271,14 @@ Public Class dlgHistogram clsHistAesFunction.AddParameter("y", clsRFunctionParameter:=ucrFactorReceiver.GetVariables(), iPosition:=2) clsRgeomPlotFunction.SetPackageName("ggridges") clsRgeomPlotFunction.SetRCommand("geom_density_ridges") + clsRgeomPlotFunction.RemoveParameterByName("mapping") If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("density_ridges") End If Else ucrFactorReceiver.ChangeParameterName("colour") clsRgeomPlotFunction.SetRCommand("geom_density") + clsRgeomPlotFunction.AddParameter("mapping", clsRFunctionParameter:=clsHistAesFunction) If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("density") End If @@ -260,9 +291,75 @@ Public Class dlgHistogram End If End If autoTranslate(Me) + UpdateParameter() + End Sub + + Private Sub UpdateParameter() + Dim strChangedTextFreq As String = ucrInputAddReorder.GetText() + clsRaesFunction.RemoveParameterByName("colour") + clsRaesFunction.RemoveParameterByName("y") + clsRaesFunction.RemoveParameterByName("fill") + + clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrFactorReceiver.GetVariableNames(False) & ")", iPosition:=0) + + If rdoHistogram.Checked Then + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + ElseIf rdoDensity_ridges.Checked Then + If ucrChkRidges.Checked Then + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("y", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + Else + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + End If + Else + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + End If End Sub - Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged + Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged, ucrInputAddReorder.ControlValueChanged toolStripMenuItemHistogramOptions.Enabled = rdoHistogram.Checked AndAlso Not ucrChkDisplayAsDotPlot.Checked toolStripMenuItemDotOptions.Enabled = rdoHistogram.Checked AndAlso ucrChkDisplayAsDotPlot.Checked toolStripMenuItemDensityOptions.Enabled = rdoDensity_ridges.Checked AndAlso Not ucrChkRidges.Checked @@ -270,6 +367,7 @@ Public Class dlgHistogram toolStripMenuItemFrequencyPolygonOptions.Enabled = rdoFrequencyPolygon.Checked SetDialogOptions() DialogueSize() + UpdateParameter() End Sub Private Sub Adding_Percentages(ucrChangedControl As ucrCore) Handles ucrInputStats.ControlValueChanged, ucrChkPercentages.ControlValueChanged @@ -366,20 +464,26 @@ Public Class dlgHistogram Private Sub DialogueSize() If rdoHistogram.Checked Then Me.Size = New Size(464, 409) - Me.ucrSaveHist.Location = New Point(10, 284) - Me.ucrBase.Location = New Point(10, 314) + Me.lblReorder.Location = New Point(283, 275) + Me.ucrInputAddReorder.Location = New Point(283, 289) + Me.ucrSaveHist.Location = New Point(10, 314) + Me.ucrBase.Location = New Point(10, 342) ElseIf rdoDensity_ridges.Checked Then - Me.Size = New Size(464, 433) - Me.ucrSaveHist.Location = New Point(10, 311) - Me.ucrBase.Location = New Point(10, 334) + Me.Size = New Size(464, 461) + Me.lblReorder.Location = New Point(286, 298) + Me.ucrInputAddReorder.Location = New Point(287, 314) + Me.ucrSaveHist.Location = New Point(10, 342) + Me.ucrBase.Location = New Point(10, 365) Else Me.Size = New Size(464, 401) - Me.ucrSaveHist.Location = New Point(10, 275) - Me.ucrBase.Location = New Point(10, 305) + Me.lblReorder.Location = New Point(283, 250) + Me.ucrInputAddReorder.Location = New Point(283, 264) + Me.ucrSaveHist.Location = New Point(10, 288) + Me.ucrBase.Location = New Point(10, 314) End If End Sub - Private Sub CoreControls_ControlContentsChanged() Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged + Private Sub CoreControls_ControlContentsChanged() Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged, ucrInputAddReorder.ControlContentsChanged TestOkEnabled() End Sub End Class \ No newline at end of file From 7281548d0a9f9fb930a6eca5571d644392089ae3 Mon Sep 17 00:00:00 2001 From: Barbra2020 Date: Thu, 21 Sep 2023 18:34:44 +0300 Subject: [PATCH 09/10] a change to the code --- instat/dlgHistogram.vb | 70 +++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/instat/dlgHistogram.vb b/instat/dlgHistogram.vb index 0cebbb3384c..ab3e283affc 100644 --- a/instat/dlgHistogram.vb +++ b/instat/dlgHistogram.vb @@ -303,33 +303,52 @@ Public Class dlgHistogram clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrFactorReceiver.GetVariableNames(False) & ")", iPosition:=0) If rdoHistogram.Checked Then - Select Case strChangedTextFreq - Case strAscending - clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strDescending - clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - Case strReverse - clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strNone - clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - End Select - ElseIf rdoDensity_ridges.Checked Then - If ucrChkRidges.Checked Then + If Not ucrFactorReceiver.IsEmpty Then Select Case strChangedTextFreq Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strDescending - clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) Case strReverse clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strNone - clsRaesFunction.AddParameter("y", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) End Select - Else + End If + ElseIf rdoDensity_ridges.Checked Then + If Not ucrFactorReceiver.IsEmpty Then + If ucrChkRidges.Checked Then + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("y", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("y", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + Else + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + End Select + End If + End If + Else + If Not ucrFactorReceiver.IsEmpty Then Select Case strChangedTextFreq Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) @@ -343,19 +362,6 @@ Public Class dlgHistogram clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) End Select End If - Else - Select Case strChangedTextFreq - Case strAscending - clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strDescending - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - Case strReverse - clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strNone - clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - End Select End If End Sub From 80009b889a3205fb23d10016f06e1310f4258f76 Mon Sep 17 00:00:00 2001 From: Barbra2020 Date: Fri, 22 Sep 2023 13:06:39 +0300 Subject: [PATCH 10/10] changes to the code --- instat/dlgHistogram.vb | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/instat/dlgHistogram.vb b/instat/dlgHistogram.vb index ab3e283affc..26c424d6094 100644 --- a/instat/dlgHistogram.vb +++ b/instat/dlgHistogram.vb @@ -317,9 +317,9 @@ Public Class dlgHistogram clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) End Select End If - ElseIf rdoDensity_ridges.Checked Then + Else If Not ucrFactorReceiver.IsEmpty Then - If ucrChkRidges.Checked Then + If rdoDensity_ridges.Checked AndAlso ucrChkRidges.Checked Then Select Case strChangedTextFreq Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) @@ -347,21 +347,6 @@ Public Class dlgHistogram End Select End If End If - Else - If Not ucrFactorReceiver.IsEmpty Then - Select Case strChangedTextFreq - Case strAscending - clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strDescending - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - Case strReverse - clsForecatsReverse.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - clsRaesFunction.AddParameter("colour", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strNone - clsRaesFunction.AddParameter("colour", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - End Select - End If End If End Sub