From a5208bd0d2797f8e30ab820ca9cc6e54d5bc6c79 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Fri, 5 May 2023 18:00:21 +0300 Subject: [PATCH 01/57] importing wide datasets --- instat/static/InstatObject/R/data_object_R6.R | 8 +++++--- instat/ucrColumnMetadata.vb | 12 +++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 8314a15d5a9..3e926c53e29 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1102,9 +1102,11 @@ DataSheet$set("public", "append_to_changes", function(value) { if(missing(value)) { stop("value arguements must be specified.") - } - else { - private$changes[[length(private$changes)+1]] <- value + }else { + #see comments in issue #7161 as to using list() was used + #primary reason was because of performance when it comes to wide data sets + #private$changes[[length(private$changes)+1]] <- value + private$changes<-list(private$changes, value) } } ) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index c56717bbd3b..d956df4b374 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -31,6 +31,7 @@ Public Class ucrColumnMetadata Private strDataTypeLabel As String = "DataType" Private strLabelsLabel As String = "labels" Private strLabelsScientific As String = "Scientific" + Private _Refreshed As Boolean = False Public WriteOnly Property DataBook() As clsDataBook Set(ByVal value As clsDataBook) @@ -45,6 +46,12 @@ Public Class ucrColumnMetadata mnuInsertColsBefore.Visible = False End Sub + Private Sub ucrColumnMetadata_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged + 'the grid may not have the latest contents because of being hidden + 'so refresh the grid data + RefreshGridData() + End Sub + Private Function GetCurrentDataFrameFocus() As clsDataFrame Return _clsDataBook.GetDataFrame(_grid.CurrentWorksheet.Name) End Function @@ -87,7 +94,9 @@ Public Class ucrColumnMetadata End Sub Public Sub RefreshGridData() - If _clsDataBook IsNot Nothing Then + 'only refresh the grid when the data book is initialised and the grid is visible + 'very useful for wide data sets. + If _clsDataBook IsNot Nothing And Visible Then _grid.RemoveOldWorksheets() AddAndUpdateWorksheets() _grid.bVisible = _clsDataBook.DataFrames.Count > 0 @@ -468,4 +477,5 @@ Public Class ucrColumnMetadata Private Sub mnuHelp1_Click(sender As Object, e As EventArgs) Handles mnuHelp1.Click, mnuHelp2.Click Help.ShowHelp(Me, frmMain.strStaticPath & "\" & frmMain.strHelpFilePath, HelpNavigator.TopicId, "543") End Sub + End Class \ No newline at end of file From 37866300ceb3bb095781574addf3a258dd04b83e Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:03:54 +0300 Subject: [PATCH 02/57] Improving and fixing bugs in the bar chart dialogue. --- instat/dlgBarAndPieChart.Designer.vb | 12 +-- instat/dlgBarAndPieChart.vb | 123 ++++++++++++++++++--------- 2 files changed, 89 insertions(+), 46 deletions(-) diff --git a/instat/dlgBarAndPieChart.Designer.vb b/instat/dlgBarAndPieChart.Designer.vb index 5048b0ad6ff..ab39b15bdd5 100644 --- a/instat/dlgBarAndPieChart.Designer.vb +++ b/instat/dlgBarAndPieChart.Designer.vb @@ -766,9 +766,9 @@ Partial Class dlgBarAndPieChart ' Me.ucrChkStart.AutoSize = True Me.ucrChkStart.Checked = False - Me.ucrChkStart.Location = New System.Drawing.Point(10, 317) + Me.ucrChkStart.Location = New System.Drawing.Point(10, 316) Me.ucrChkStart.Name = "ucrChkStart" - Me.ucrChkStart.Size = New System.Drawing.Size(108, 23) + Me.ucrChkStart.Size = New System.Drawing.Size(83, 23) Me.ucrChkStart.TabIndex = 28 ' 'ucrInputStart @@ -777,7 +777,7 @@ Partial Class dlgBarAndPieChart Me.ucrInputStart.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputStart.GetSetSelectedIndex = -1 Me.ucrInputStart.IsReadOnly = False - Me.ucrInputStart.Location = New System.Drawing.Point(79, 315) + Me.ucrInputStart.Location = New System.Drawing.Point(104, 315) Me.ucrInputStart.Name = "ucrInputStart" Me.ucrInputStart.Size = New System.Drawing.Size(93, 21) Me.ucrInputStart.TabIndex = 30 @@ -806,7 +806,7 @@ Partial Class dlgBarAndPieChart Me.ucrChkBacktoback.Checked = False Me.ucrChkBacktoback.Location = New System.Drawing.Point(10, 293) Me.ucrChkBacktoback.Name = "ucrChkBacktoback" - Me.ucrChkBacktoback.Size = New System.Drawing.Size(166, 23) + Me.ucrChkBacktoback.Size = New System.Drawing.Size(93, 23) Me.ucrChkBacktoback.TabIndex = 27 ' 'ucrChkPolarCoordinates @@ -913,7 +913,6 @@ Partial Class dlgBarAndPieChart Me.Controls.Add(Me.ucrReceiverX) Me.Controls.Add(Me.lblWordcloudAngle) Me.Controls.Add(Me.ucrInputReorderX) - Me.Controls.Add(Me.ucrChkIncreaseSize) Me.Controls.Add(Me.ucrInputAddReorder) Me.Controls.Add(Me.lblLabelPosition) Me.Controls.Add(Me.ucrPnlPolar) @@ -922,7 +921,6 @@ Partial Class dlgBarAndPieChart Me.Controls.Add(Me.ucrInputStart) Me.Controls.Add(Me.ucrChkLayout) Me.Controls.Add(Me.ucrChkFlipCoordinates) - Me.Controls.Add(Me.ucrChkBacktoback) Me.Controls.Add(Me.ucrChkPolarCoordinates) Me.Controls.Add(Me.lblWordcloudLabel) Me.Controls.Add(Me.lblArea) @@ -931,6 +929,8 @@ Partial Class dlgBarAndPieChart Me.Controls.Add(Me.ucrReceiverWordcloudAngle) Me.Controls.Add(Me.ucrChkAddLabelsText) Me.Controls.Add(Me.ucrChkAddLabelsTreemap) + Me.Controls.Add(Me.ucrChkBacktoback) + Me.Controls.Add(Me.ucrChkIncreaseSize) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 3884518ab16..023527deb9e 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -77,6 +77,9 @@ Public Class dlgBarAndPieChart Private clsScaleSizeAreaFunction As New RFunction Private clsDummyFunction As New RFunction Private clsPointsFunction As New RFunction + Private clsPointsAesFunction As New RFunction + Private clsGeomLollipopAesFunction As New RFunction + Private clsPieFunction As New RFunction Private ReadOnly strAscending As String = "Ascending" Private ReadOnly strDescending As String = "Descending" @@ -89,7 +92,6 @@ Public Class dlgBarAndPieChart Private strAdditionalPointsParameterName As String = "add_jitter" Private strGeomParameterNames() As String = {strFirstParameterName, strStatSummaryParameterName, strAdditionalPointsParameterName} - Private Sub dlgBarAndPieChart_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then InitialiseDialog() @@ -408,6 +410,9 @@ Public Class dlgBarAndPieChart clsScaleSizeAreaFunction = New RFunction clsDummyFunction = New RFunction clsPointsFunction = New RFunction + clsPointsAesFunction = New RFunction + clsGeomLollipopAesFunction = New RFunction + clsPieFunction = New RFunction ucrBarChartSelector.Reset() ucrBarChartSelector.SetGgplotFunction(clsBaseOperator) @@ -455,13 +460,19 @@ Public Class dlgBarAndPieChart clsGeomLollipopFunction.AddParameter("point.colour", "steelblue", iPosition:=0) clsGeomLollipopFunction.AddParameter("point.size", "1", iPosition:=1) + clsGeomLollipopAesFunction.SetPackageName("ggplot2") + clsGeomLollipopAesFunction.SetRCommand("aes") + clsBarAesFunction.SetPackageName("ggplot2") clsBarAesFunction.SetRCommand("aes") + clsPieFunction.SetPackageName("ggplot2") + clsPieFunction.SetRCommand("aes") + clsPieFunction.AddParameter("x", Chr(34) & Chr(34)) + clsPieFunction.AddParameter("y", Chr(34) & Chr(34)) + clsPieAesFunction.SetPackageName("ggplot2") clsPieAesFunction.SetRCommand("aes") - clsPieAesFunction.AddParameter("x", Chr(34) & Chr(34)) - clsPieAesFunction.AddParameter("y", Chr(34) & Chr(34)) clsForecatsReverse.SetPackageName("forcats") clsForecatsReverse.SetRCommand("fct_rev") @@ -487,8 +498,11 @@ Public Class dlgBarAndPieChart clsPointsFunction.SetPackageName("ggplot2") clsPointsFunction.SetRCommand("geom_point") - clsPointsFunction.AddParameter("size", "3") - clsPointsFunction.AddParameter("colour", Chr(34) & "red" & Chr(34)) + clsPointsFunction.AddParameter("size", "3", iPosition:=0) + clsPointsFunction.AddParameter("colour", Chr(34) & "red" & Chr(34), iPosition:=1) + + clsPointsAesFunction.SetPackageName("ggplot2") + clsPointsAesFunction.SetRCommand("aes") clsIsEqualToOperator1.SetOperation("==") clsIsEqualToOperator1.AddParameter("right", clsROperatorParameter:=clsOpeningSubsetOperator1, iPosition:=1) @@ -547,6 +561,7 @@ Public Class dlgBarAndPieChart clsGeomTreemapAesFunction.SetPackageName("ggplot2") clsGeomTreemapAesFunction.SetRCommand("aes") + clsGeomTreemapAesFunction.AddParameter("area", clsRFunctionParameter:=clsAsNumericFunction, iPosition:=0) clsAsNumericFunction.SetRCommand("as.numeric") @@ -554,7 +569,8 @@ Public Class dlgBarAndPieChart clsGeomTreemapTextAesFunction.SetPackageName("ggplot2") clsGeomTreemapTextAesFunction.SetRCommand("aes") - clsGeomTreemapTextAesFunction.AddParameter("label", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=0) + clsGeomTreemapTextAesFunction.AddParameter("label", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) + clsGeomTextWordcloudAesFunction.SetPackageName("ggplot2") clsGeomTextWordcloudAesFunction.SetRCommand("aes") @@ -593,14 +609,17 @@ Public Class dlgBarAndPieChart ucrBarChartSelector.AddAdditionalCodeParameterPair(clsSubsetFunction1, ucrBarChartSelector.GetParameter(), iAdditionalPairNo:=1) ucrBarChartSelector.AddAdditionalCodeParameterPair(clsSubsetFunction2, ucrBarChartSelector.GetParameter(), iAdditionalPairNo:=2) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsPieAesFunction, ucrReceiverByFactor.GetParameter(), iAdditionalPairNo:=1) - ucrVariablesAsFactorForBarChart.AddAdditionalCodeParameterPair(clsPieAesFunction, ucrVariablesAsFactorForBarChart.GetParameter(), iAdditionalPairNo:=1) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator1, New RParameter("left", 0), iAdditionalPairNo:=2) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator2, New RParameter("left", 0), iAdditionalPairNo:=3) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("x", 0), iAdditionalPairNo:=4) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsReorderFunctionValue, New RParameter("x", 0), iAdditionalPairNo:=5) + ucrVariablesAsFactorForBarChart.AddAdditionalCodeParameterPair(clsPieAesFunction, ucrVariablesAsFactorForBarChart.GetParameter(), iAdditionalPairNo:=1) ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) - ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 0), iAdditionalPairNo:=1) + ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) + ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) + ucrInputLollipopColour.AddAdditionalCodeParameterPair(clsPointsFunction, New RParameter("colour", 1), iAdditionalPairNo:=1) + ucrNudLollipopSize.AddAdditionalCodeParameterPair(clsPointsFunction, New RParameter("size", 0), iAdditionalPairNo:=1) ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) ucrReceiverX.SetRCode(clsBarAesFunction, bReset) @@ -623,9 +642,7 @@ Public Class dlgBarAndPieChart ucrReceiverFill.SetRCode(clsGeomTreemapAesFunction, bReset) ucrReceiverLabel.SetRCode(clsGeomTreemapTextAesFunction, bReset) ucrInputLayout.SetRCode(clsGeomTreemapFunction, bReset) - ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) ucrInputStart.SetRCode(clsGeomTreemapFunction, bReset) - ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) ucrInputPlace.SetRCode(clsGeomTreemapTextFunction, bReset) ucrReceiverWordcloudLabel.SetRCode(clsGeomTextWordcloudAesFunction, bReset) ucrReceiverWordcloudSize.SetRCode(clsGeomTextWordcloudAesFunction, bReset) @@ -635,6 +652,11 @@ Public Class dlgBarAndPieChart ucrNudMaxSize.SetRCode(clsScaleSizeAreaFunction, bReset) ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset) ucrChkReorderFrequency.SetRCode(clsDummyFunction, bReset) + + If bReset Then + ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) + ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) + End If End Sub Private Sub TestOkEnabled() @@ -671,9 +693,9 @@ Public Class dlgBarAndPieChart TestOkEnabled() End Sub - Private Sub openSdgLayerOptions(clsNewGeomFunc As RFunction) + Private Sub openSdgLayerOptions(clsNewGeomFunc As RFunction, clsNewAesFunction As RFunction) sdgLayerOptions.SetupLayer(clsNewGgPlot:=clsRggplotFunction, clsNewGeomFunc:=clsNewGeomFunc, - clsNewGlobalAesFunc:=clsLabelAesFunction, clsNewLocalAes:=clsLocalRaesFunction, + clsNewGlobalAesFunc:=clsNewAesFunction, clsNewLocalAes:=clsLocalRaesFunction, bFixGeom:=True, ucrNewBaseSelector:=ucrBarChartSelector, bApplyAesGlobally:=True, bReset:=bResetLineLayerSubdialog) sdgLayerOptions.ShowDialog() @@ -723,23 +745,23 @@ Public Class dlgBarAndPieChart End Sub Private Sub toolStripMenuItemBarchartOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemBarchartOptions.Click - openSdgLayerOptions(clsRgeomBarFunction1) + openSdgLayerOptions(clsRgeomBarFunction, clsBarAesFunction) End Sub Private Sub toolStripMenuItemLollipopOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemLollipopOptions.Click - openSdgLayerOptions(clsGeomLollipopFunction) + openSdgLayerOptions(clsGeomLollipopFunction, clsGeomLollipopAesFunction) End Sub Private Sub toolStripMenuItemTreemapOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTreemapOptions.Click - openSdgLayerOptions(clsGeomTreemapFunction) + openSdgLayerOptions(clsGeomTreemapFunction, clsGeomTreemapAesFunction) End Sub Private Sub toolStripMenuItemWordcloudOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemWordcloudOptions.Click - openSdgLayerOptions(clsGeomTextWordcloudFunction) + openSdgLayerOptions(clsGeomTextWordcloudFunction, clsGeomTextWordcloudAesFunction) End Sub Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemPointOptions.Click - openSdgLayerOptions(clsPointsFunction) + openSdgLayerOptions(clsPointsFunction, clsPointsAesFunction) End Sub Private Sub SetDialogOptions() @@ -760,7 +782,6 @@ Public Class dlgBarAndPieChart Else clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextWordcloudAesFunction, iPosition:=1) End If - ucrChkLollipop.Enabled = If(rdoValue.Checked, True, False) If rdoFrequency.Checked Then If ucrVariablesAsFactorForBarChart.bSingleVariable Then @@ -839,18 +860,22 @@ Public Class dlgBarAndPieChart End Sub Private Sub ChangeParameterName() + clsBaseOperator.RemoveParameterByName("geom_lollipop") clsBarAesFunction.RemoveParameterByName("x") clsBarAesFunction.RemoveParameterByName("y") clsPieAesFunction.RemoveParameterByName("x") clsPieAesFunction.RemoveParameterByName("y") - clsBaseOperator.RemoveParameterByName("geom_lollipop") + clsPieAesFunction.RemoveParameterByName("fill") If rdoValue.Checked Then clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + clsGeomLollipopAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) + clsGeomLollipopAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsGeomLollipopAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=2) clsRgeomBarFunction2.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=1) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=1) @@ -870,6 +895,7 @@ Public Class dlgBarAndPieChart clsPieAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=2) End If If ucrChkLollipop.Checked Then + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") End If @@ -879,21 +905,43 @@ Public Class dlgBarAndPieChart clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) End If ElseIf rdoFrequency.Checked Then - If ucrVariablesAsFactorForBarChart.IsEmpty Then - clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - clsPieAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - End If - If ucrReceiverByFactor.IsEmpty Then - clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) - clsPieAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + If ucrChkPolarCoordinates.Checked Then + If rdoPie.Checked Then + If ucrReceiverByFactor.IsEmpty Then + clsPieAesFunction.AddParameter("x", "1", iPosition:=0) + clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + Else + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + End If + Else + If ucrReceiverByFactor.IsEmpty Then + clsPieAesFunction.AddParameter("x", "1", iPosition:=0) + clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + Else + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + End If + End If + clsRggplotFunction.RemoveParameterByName("mapping") + clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) + Else + If ucrVariablesAsFactorForBarChart.IsEmpty Then + clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + Else + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + + End If + If ucrReceiverByFactor.IsEmpty Then + clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + Else + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + End If + clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) + clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) + clsRgeomBarFunction2.RemoveParameterByName("stat") + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) End If - clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) - clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) - clsRgeomBarFunction2.RemoveParameterByName("stat") clsBaseOperator.RemoveParameterByName("geom_treemap") clsBaseOperator.RemoveParameterByName("geom_text_wordcloud") ElseIf rdoTreeMap.Checked Then @@ -979,18 +1027,14 @@ Public Class dlgBarAndPieChart End Sub Private Sub ucrChkPolarCoordinates_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkPolarCoordinates.ControlValueChanged, ucrPnlPolar.ControlValueChanged + ' adding coordpolar geom clsBaseOperator.RemoveParameterByName("coordpolar") ChangeParameterName() If Not rdoDonut.Checked OrElse Not ucrChkPolarCoordinates.Checked Then clsBaseOperator.RemoveParameterByName("scale") End If - If Not rdoDonut.Checked OrElse Not rdoPie.Checked Then - ChangeParameterName() - End If If ucrChkPolarCoordinates.Checked Then ucrChkBacktoback.Checked = Not ucrChkPolarCoordinates.Checked - clsRggplotFunction.RemoveParameterByName("mapping") - clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) If rdoDonut.Checked Then clsBaseOperator.AddParameter("scale", clsRFunctionParameter:=clsScaleXdiscretFunction, iPosition:=4, bIncludeArgumentName:=False) End If @@ -1052,5 +1096,4 @@ Public Class dlgBarAndPieChart clsBaseOperator.RemoveParameterByName("geom_treemap_text") End If End Sub - End Class \ No newline at end of file From f6c3ad98e1e00b41338638e63020c20d583d1dbf Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Thu, 13 Jul 2023 14:41:08 +0300 Subject: [PATCH 03/57] Added reorder to pie and donut, fixed bugs --- instat/dlgBarAndPieChart.Designer.vb | 66 ++++++++++++++-------------- instat/dlgBarAndPieChart.vb | 59 ++++++++++++++++++------- 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/instat/dlgBarAndPieChart.Designer.vb b/instat/dlgBarAndPieChart.Designer.vb index ab39b15bdd5..cb6f182f0a4 100644 --- a/instat/dlgBarAndPieChart.Designer.vb +++ b/instat/dlgBarAndPieChart.Designer.vb @@ -68,7 +68,7 @@ Partial Class dlgBarAndPieChart Me.toolStripMenuItemPlotOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemBarchartOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemLollipopOptions = New System.Windows.Forms.ToolStripMenuItem() - Me.toolStripMenuItemPointOptions = New System.Windows.Forms.ToolStripMenuItem() + Me.toolStripMenuItemTextOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemTreemapOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemWordcloudOptions = New System.Windows.Forms.ToolStripMenuItem() Me.cmdOptions = New instat.ucrSplitButton() @@ -97,7 +97,6 @@ Partial Class dlgBarAndPieChart Me.ucrReceiverWordcloudColor = New instat.ucrReceiverSingle() Me.ucrReceiverX = New instat.ucrReceiverSingle() Me.ucrInputReorderX = New instat.ucrInputComboBox() - Me.ucrChkIncreaseSize = New instat.ucrCheck() Me.ucrInputAddReorder = New instat.ucrInputComboBox() Me.ucrPnlPolar = New instat.UcrPanel() Me.ucrInputLabelColour = New instat.ucrInputComboBox() @@ -105,12 +104,13 @@ Partial Class dlgBarAndPieChart Me.ucrInputStart = New instat.ucrInputComboBox() Me.ucrChkLayout = New instat.ucrCheck() Me.ucrChkFlipCoordinates = New instat.ucrCheck() - Me.ucrChkBacktoback = New instat.ucrCheck() Me.ucrChkPolarCoordinates = New instat.ucrCheck() Me.ucrVariablesAsFactorForBarChart = New instat.ucrVariablesAsFactor() Me.ucrReceiverWordcloudAngle = New instat.ucrReceiverSingle() Me.ucrChkAddLabelsText = New instat.ucrCheck() Me.ucrChkAddLabelsTreemap = New instat.ucrCheck() + Me.ucrChkBacktoback = New instat.ucrCheck() + Me.ucrChkIncreaseSize = New instat.ucrCheck() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -387,44 +387,44 @@ Partial Class dlgBarAndPieChart ' 'contextMenuStripOptions ' - Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemBarchartOptions, Me.toolStripMenuItemLollipopOptions, Me.toolStripMenuItemPointOptions, Me.toolStripMenuItemTreemapOptions, Me.toolStripMenuItemWordcloudOptions}) + Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemBarchartOptions, Me.toolStripMenuItemLollipopOptions, Me.toolStripMenuItemTextOptions, Me.toolStripMenuItemTreemapOptions, Me.toolStripMenuItemWordcloudOptions}) Me.contextMenuStripOptions.Name = "contextMenuStripOk" - Me.contextMenuStripOptions.Size = New System.Drawing.Size(179, 136) + Me.contextMenuStripOptions.Size = New System.Drawing.Size(181, 158) ' 'toolStripMenuItemPlotOptions ' Me.toolStripMenuItemPlotOptions.Name = "toolStripMenuItemPlotOptions" - Me.toolStripMenuItemPlotOptions.Size = New System.Drawing.Size(178, 22) + Me.toolStripMenuItemPlotOptions.Size = New System.Drawing.Size(180, 22) Me.toolStripMenuItemPlotOptions.Text = "Plot Options" ' 'toolStripMenuItemBarchartOptions ' Me.toolStripMenuItemBarchartOptions.Name = "toolStripMenuItemBarchartOptions" - Me.toolStripMenuItemBarchartOptions.Size = New System.Drawing.Size(178, 22) + Me.toolStripMenuItemBarchartOptions.Size = New System.Drawing.Size(180, 22) Me.toolStripMenuItemBarchartOptions.Text = "BarChart Options" ' 'toolStripMenuItemLollipopOptions ' Me.toolStripMenuItemLollipopOptions.Name = "toolStripMenuItemLollipopOptions" - Me.toolStripMenuItemLollipopOptions.Size = New System.Drawing.Size(178, 22) + Me.toolStripMenuItemLollipopOptions.Size = New System.Drawing.Size(180, 22) Me.toolStripMenuItemLollipopOptions.Text = "Lollipop Options" ' - 'toolStripMenuItemPointOptions + 'toolStripMenuItemTextOptions ' - Me.toolStripMenuItemPointOptions.Name = "toolStripMenuItemPointOptions" - Me.toolStripMenuItemPointOptions.Size = New System.Drawing.Size(178, 22) - Me.toolStripMenuItemPointOptions.Text = "Point Options" + Me.toolStripMenuItemTextOptions.Name = "toolStripMenuItemTextOptions" + Me.toolStripMenuItemTextOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemTextOptions.Text = "Text Options" ' 'toolStripMenuItemTreemapOptions ' Me.toolStripMenuItemTreemapOptions.Name = "toolStripMenuItemTreemapOptions" - Me.toolStripMenuItemTreemapOptions.Size = New System.Drawing.Size(178, 22) + Me.toolStripMenuItemTreemapOptions.Size = New System.Drawing.Size(180, 22) Me.toolStripMenuItemTreemapOptions.Text = "Treemap Options" ' 'toolStripMenuItemWordcloudOptions ' Me.toolStripMenuItemWordcloudOptions.Name = "toolStripMenuItemWordcloudOptions" - Me.toolStripMenuItemWordcloudOptions.Size = New System.Drawing.Size(178, 22) + Me.toolStripMenuItemWordcloudOptions.Size = New System.Drawing.Size(180, 22) Me.toolStripMenuItemWordcloudOptions.Text = "Wordcloud Options" ' 'cmdOptions @@ -723,15 +723,6 @@ Partial Class dlgBarAndPieChart Me.ucrInputReorderX.Size = New System.Drawing.Size(93, 21) Me.ucrInputReorderX.TabIndex = 12 ' - 'ucrChkIncreaseSize - ' - Me.ucrChkIncreaseSize.AutoSize = True - Me.ucrChkIncreaseSize.Checked = False - Me.ucrChkIncreaseSize.Location = New System.Drawing.Point(10, 317) - Me.ucrChkIncreaseSize.Name = "ucrChkIncreaseSize" - Me.ucrChkIncreaseSize.Size = New System.Drawing.Size(88, 23) - Me.ucrChkIncreaseSize.TabIndex = 63 - ' 'ucrInputAddReorder ' Me.ucrInputAddReorder.AddQuotesIfUnrecognised = True @@ -800,15 +791,6 @@ Partial Class dlgBarAndPieChart Me.ucrChkFlipCoordinates.Size = New System.Drawing.Size(166, 23) Me.ucrChkFlipCoordinates.TabIndex = 29 ' - 'ucrChkBacktoback - ' - Me.ucrChkBacktoback.AutoSize = True - Me.ucrChkBacktoback.Checked = False - Me.ucrChkBacktoback.Location = New System.Drawing.Point(10, 293) - Me.ucrChkBacktoback.Name = "ucrChkBacktoback" - Me.ucrChkBacktoback.Size = New System.Drawing.Size(93, 23) - Me.ucrChkBacktoback.TabIndex = 27 - ' 'ucrChkPolarCoordinates ' Me.ucrChkPolarCoordinates.AutoSize = True @@ -862,6 +844,24 @@ Partial Class dlgBarAndPieChart Me.ucrChkAddLabelsTreemap.Size = New System.Drawing.Size(129, 24) Me.ucrChkAddLabelsTreemap.TabIndex = 61 ' + 'ucrChkBacktoback + ' + Me.ucrChkBacktoback.AutoSize = True + Me.ucrChkBacktoback.Checked = False + Me.ucrChkBacktoback.Location = New System.Drawing.Point(10, 293) + Me.ucrChkBacktoback.Name = "ucrChkBacktoback" + Me.ucrChkBacktoback.Size = New System.Drawing.Size(93, 23) + Me.ucrChkBacktoback.TabIndex = 27 + ' + 'ucrChkIncreaseSize + ' + Me.ucrChkIncreaseSize.AutoSize = True + Me.ucrChkIncreaseSize.Checked = False + Me.ucrChkIncreaseSize.Location = New System.Drawing.Point(10, 317) + Me.ucrChkIncreaseSize.Name = "ucrChkIncreaseSize" + Me.ucrChkIncreaseSize.Size = New System.Drawing.Size(88, 23) + Me.ucrChkIncreaseSize.TabIndex = 63 + ' 'dlgBarAndPieChart ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -1011,7 +1011,7 @@ Partial Class dlgBarAndPieChart Friend WithEvents contextMenuStripOptions As ContextMenuStrip Friend WithEvents toolStripMenuItemPlotOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemBarchartOptions As ToolStripMenuItem - Friend WithEvents toolStripMenuItemPointOptions As ToolStripMenuItem + Friend WithEvents toolStripMenuItemTextOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemTreemapOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemWordcloudOptions As ToolStripMenuItem Friend WithEvents cmdOptions As ucrSplitButton diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 023527deb9e..3ea7fae80ba 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -59,6 +59,7 @@ Public Class dlgBarAndPieChart Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsGeomTextFunction As New RFunction + Private clsGeomTextAesFunction As New RFunction Private clsLabelAesFunction As New RFunction Private clsAnnotateFunction As New RFunction Private clsForecatsInfreq As New RFunction @@ -77,7 +78,6 @@ Public Class dlgBarAndPieChart Private clsScaleSizeAreaFunction As New RFunction Private clsDummyFunction As New RFunction Private clsPointsFunction As New RFunction - Private clsPointsAesFunction As New RFunction Private clsGeomLollipopAesFunction As New RFunction Private clsPieFunction As New RFunction @@ -393,6 +393,7 @@ Public Class dlgBarAndPieChart clsScaleXdiscretFunction = New RFunction clsExpansionFunction = New RFunction clsGeomTextFunction = New RFunction + clsGeomTextAesFunction = New RFunction clsLabelAesFunction = New RFunction clsForecatsInfreq = New RFunction clsForecatsReverse = New RFunction @@ -410,7 +411,6 @@ Public Class dlgBarAndPieChart clsScaleSizeAreaFunction = New RFunction clsDummyFunction = New RFunction clsPointsFunction = New RFunction - clsPointsAesFunction = New RFunction clsGeomLollipopAesFunction = New RFunction clsPieFunction = New RFunction @@ -422,11 +422,14 @@ Public Class dlgBarAndPieChart bResetBarLayerSubdialog = True ucrInputAddReorder.SetText(strNone) + ucrInputAddReorder.bUpdateRCodeFromControl = True ucrInputReorderX.SetText(strNone) ucrInputReorderX.bUpdateRCodeFromControl = True ucrInputReorderValue.SetText(strNone) + ucrInputReorderValue.bUpdateRCodeFromControl = True + 'Temp fix: Set panel conditions properly! rdoPie.Checked = True rdoFrequency.Checked = True @@ -501,9 +504,6 @@ Public Class dlgBarAndPieChart clsPointsFunction.AddParameter("size", "3", iPosition:=0) clsPointsFunction.AddParameter("colour", Chr(34) & "red" & Chr(34), iPosition:=1) - clsPointsAesFunction.SetPackageName("ggplot2") - clsPointsAesFunction.SetRCommand("aes") - clsIsEqualToOperator1.SetOperation("==") clsIsEqualToOperator1.AddParameter("right", clsROperatorParameter:=clsOpeningSubsetOperator1, iPosition:=1) @@ -545,6 +545,9 @@ Public Class dlgBarAndPieChart clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) + clsGeomTextAesFunction.SetPackageName("ggplot2") + clsGeomTextAesFunction.SetRCommand("aes") + clsLabelAesFunction.SetPackageName("ggplot2") clsLabelAesFunction.SetRCommand("aes") @@ -618,12 +621,9 @@ Public Class dlgBarAndPieChart ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) - ucrInputLollipopColour.AddAdditionalCodeParameterPair(clsPointsFunction, New RParameter("colour", 1), iAdditionalPairNo:=1) - ucrNudLollipopSize.AddAdditionalCodeParameterPair(clsPointsFunction, New RParameter("size", 0), iAdditionalPairNo:=1) ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) ucrReceiverX.SetRCode(clsBarAesFunction, bReset) - ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) ucrSaveBar.SetRCode(clsBaseOperator, bReset) ucrBarChartSelector.SetRCode(clsRggplotFunction, bReset) ucrChkPolarCoordinates.SetRCode(clsPolarCoordFunction, bReset) @@ -656,6 +656,7 @@ Public Class dlgBarAndPieChart If bReset Then ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) + ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) End If End Sub @@ -760,8 +761,8 @@ Public Class dlgBarAndPieChart openSdgLayerOptions(clsGeomTextWordcloudFunction, clsGeomTextWordcloudAesFunction) End Sub - Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemPointOptions.Click - openSdgLayerOptions(clsPointsFunction, clsPointsAesFunction) + Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTextOptions.Click + openSdgLayerOptions(clsGeomTextFunction, clsGeomTextAesFunction) End Sub Private Sub SetDialogOptions() @@ -785,9 +786,11 @@ Public Class dlgBarAndPieChart ucrChkLollipop.Enabled = If(rdoValue.Checked, True, False) If rdoFrequency.Checked Then If ucrVariablesAsFactorForBarChart.bSingleVariable Then - ucrInputAddReorder.Visible = Not ucrReceiverByFactor.IsEmpty() - If Not ucrInputAddReorder.Visible Then + If ucrReceiverByFactor.IsEmpty Then + ucrInputAddReorder.Visible = False ucrInputAddReorder.SetText(strNone) + Else + ucrInputAddReorder.Visible = True End If Else ucrInputReorderX.SetText(strNone) @@ -796,9 +799,9 @@ Public Class dlgBarAndPieChart If ucrVariablesAsFactorForBarChart.bSingleVariable Then ucrChkReorderValue.Visible = True ucrInputAddReorder.Visible = Not ucrReceiverByFactor.IsEmpty() - If Not ucrInputAddReorder.Visible Then - ucrInputAddReorder.SetText(strNone) - End If + 'If Not ucrInputAddReorder.Visible Then + ' ucrInputAddReorder.SetText(strNone) + 'End If Else ucrChkReorderValue.Visible = False End If @@ -816,45 +819,69 @@ Public Class dlgBarAndPieChart Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strDescending clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) Case strReverse clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case Else + clsBarAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) End Select Select Case strChangedTextValue Case strAscending clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) Case strDescending clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=2) Case strReverse clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - End Select + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + Case Else + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + End Select Else Select Case strChangeTextReorder Case strAscending clsReorderFunction.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) Case strDescending clsReorderFunction.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) Case strReverse clsForecatsReverse.AddParameter("f", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + Case Else + clsBarAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) End Select Select Case strChangedTextValue Case strAscending clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strDescending clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strReverse clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case Else + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) End Select End If End Sub From 4c9ce3009701cf71904a2b0e86cd85b7c65d33bf Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 27 Jul 2023 16:36:42 +0300 Subject: [PATCH 04/57] added comments --- instat/ucrColumnMetadata.vb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index d956df4b374..039232d8c8b 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -47,8 +47,9 @@ Public Class ucrColumnMetadata End Sub Private Sub ucrColumnMetadata_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged + 'todo. a temporary useful fix because of wide data sets 'the grid may not have the latest contents because of being hidden - 'so refresh the grid data + 'once 'paging' feature is implemented, this block can be removed. RefreshGridData() End Sub @@ -94,8 +95,9 @@ Public Class ucrColumnMetadata End Sub Public Sub RefreshGridData() + 'todo. a temporary useful fix because of wide data sets 'only refresh the grid when the data book is initialised and the grid is visible - 'very useful for wide data sets. + 'in the long term, this window should have paging feature similar to the data viewer If _clsDataBook IsNot Nothing And Visible Then _grid.RemoveOldWorksheets() AddAndUpdateWorksheets() From 384409efaef6d6b0976f9df8b66e91d567ee13e6 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 27 Jul 2023 16:57:41 +0300 Subject: [PATCH 05/57] improved comment --- instat/static/InstatObject/R/data_object_R6.R | 2 +- instat/ucrColumnMetadata.vb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 3e926c53e29..23fa295bf3a 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1103,7 +1103,7 @@ DataSheet$set("public", "append_to_changes", function(value) { if(missing(value)) { stop("value arguements must be specified.") }else { - #see comments in issue #7161 as to using list() was used + #see comments in issue #7161 that explain more about why list() was used #primary reason was because of performance when it comes to wide data sets #private$changes[[length(private$changes)+1]] <- value private$changes<-list(private$changes, value) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 039232d8c8b..21d86078bd0 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -97,7 +97,8 @@ Public Class ucrColumnMetadata Public Sub RefreshGridData() 'todo. a temporary useful fix because of wide data sets 'only refresh the grid when the data book is initialised and the grid is visible - 'in the long term, this window should have paging feature similar to the data viewer + 'displaying more than a 1000 rows takes a lot of time + 'in the long term, this window should have 'paging' feature similar to the data viewer to display 11000 rows only. If _clsDataBook IsNot Nothing And Visible Then _grid.RemoveOldWorksheets() AddAndUpdateWorksheets() From 9cc602f0bed1582462639f6ed2fb30a4dfe6f19d Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 8 Aug 2023 17:31:03 +0300 Subject: [PATCH 06/57] changes that matter --- instat/dlgTransposeColumns.vb | 21 ++- instat/sdgCalculationsSummmary.vb | 25 ++- instat/ucrReceiver.vb | 44 +++-- instat/ucrReceiverExpression.vb | 208 +++++++++++----------- instat/ucrReceiverMultiple.vb | 276 ++++++++++++++---------------- instat/ucrReceiverSingle.vb | 35 +--- instat/ucrSelector.vb | 61 +++---- instat/ucrVariablesAsFactor.vb | 2 +- 8 files changed, 308 insertions(+), 364 deletions(-) diff --git a/instat/dlgTransposeColumns.vb b/instat/dlgTransposeColumns.vb index a5b04a50f6a..42b9265afe9 100644 --- a/instat/dlgTransposeColumns.vb +++ b/instat/dlgTransposeColumns.vb @@ -137,19 +137,24 @@ Public Class dlgTransposeColumns ucrSelectorTransposeColumns.lstAvailableVariable.Columns.Add("Variables") End Sub Private Sub ucrReceiverVariableNames_Enter(sender As Object, e As EventArgs) Handles ucrReceiverVariableNames.Enter - Dim grps As New ListViewGroup ClearSelector() If Not ucrReceiverColumnsToTranspose.IsEmpty Then - If ucrReceiverColumnsToTranspose.GetVariableNamesList(False).Count > 1 Then - grps = New ListViewGroup(key:=ucrSelectorTransposeColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text, - headerText:=ucrSelectorTransposeColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text) - ucrSelectorTransposeColumns.lstAvailableVariable.Groups.Add(grps) + '------------------------- + 'todo. this cod block below requires more refactoring. + 'it should use the selector functions for adding items instead of accessing the selector controls + Dim arrItems As String() = ucrReceiverColumnsToTranspose.GetVariableNamesList(False) + If arrItems.Count > 1 Then + ucrSelectorTransposeColumns.lstAvailableVariable.Groups.Add(New ListViewGroup( + key:=ucrSelectorTransposeColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text, + headerText:=ucrSelectorTransposeColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text)) End If - For j = 0 To ucrReceiverColumnsToTranspose.GetVariableNamesList(False).Count - 1 - ucrSelectorTransposeColumns.lstAvailableVariable.Items.Add(ucrReceiverColumnsToTranspose.GetVariableNamesList(False)(j)) + + For j = 0 To arrItems.Count - 1 + ucrSelectorTransposeColumns.lstAvailableVariable.Items.Add(arrItems(j)) ucrSelectorTransposeColumns.lstAvailableVariable.Items(j).Tag = ucrSelectorTransposeColumns.ucrAvailableDataFrames.cboAvailableDataFrames.Text - ucrSelectorTransposeColumns.lstAvailableVariable.Items(j).ToolTipText = ucrReceiverColumnsToTranspose.GetVariableNamesList(False)(0) + ucrSelectorTransposeColumns.lstAvailableVariable.Items(j).ToolTipText = arrItems(j) Next + '------------------------- End If End Sub Private Sub ucrSelectorTransposeColumns_DataFrameChanged() Handles ucrSelectorTransposeColumns.DataFrameChanged diff --git a/instat/sdgCalculationsSummmary.vb b/instat/sdgCalculationsSummmary.vb index 8d4d9683fe7..499067c9172 100644 --- a/instat/sdgCalculationsSummmary.vb +++ b/instat/sdgCalculationsSummmary.vb @@ -351,8 +351,10 @@ Public Class sdgCalculationsSummmary clsCalculationFunction.RemoveParameterByName("function_exp") End If - If ucrCalcSummary.ucrSelectorForCalculations.lstVariablesInReceivers.Count > 0 Then - clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList(ucrCalcSummary.ucrSelectorForCalculations.lstVariablesInReceivers, ucrCalcSummary.ucrSelectorForCalculations)) + If Not ucrCalcSummary.ucrSelectorForCalculations.CurrentReceiver.IsEmpty Then + clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList( + ucrCalcSummary.ucrSelectorForCalculations.CurrentReceiver.GetVariableNamesList(bWithQuotes:=False), + ucrCalcSummary.ucrSelectorForCalculations)) Else clsCalculationFunction.RemoveParameterByName("calculated_from") End If @@ -364,29 +366,22 @@ Public Class sdgCalculationsSummmary If ucrReceiverByOrSort.IsEmpty Then clsCalculationFunction.RemoveParameterByName("calculated_from") Else - clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList(ucrSelectorBy.lstVariablesInReceivers, ucrSelectorBy)) + clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList( + ucrSelectorBy.CurrentReceiver.GetVariableNamesList(bWithQuotes:=False), ucrSelectorBy)) End If End If End Sub 'Need to do this instead of with RFunctions because the calculated_from list can have multiple items with the same label - Private Function CreateCalcFromList(lstVariables As List(Of Tuple(Of String, String)), ucrCurrentSelector As ucrSelectorByDataFrame) As String + Private Function CreateCalcFromList(lstVariables As String(), ucrCurrentSelector As ucrSelectorByDataFrame) As String Dim strCalcFromList As String - Dim strColumn As String - Dim strDataFrame As String strCalcFromList = "list(" For i = 0 To lstVariables.Count - 1 - strColumn = lstVariables(i).Item1 - If lstVariables(i).Item1 = "" Then - strDataFrame = ucrCurrentSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text - Else - strDataFrame = lstVariables(i).Item2 - End If If i > 0 Then strCalcFromList = strCalcFromList & "," End If - strCalcFromList = strCalcFromList & strDataFrame & " = " & Chr(34) & strColumn & Chr(34) + strCalcFromList = strCalcFromList & ucrCurrentSelector.strCurrentDataFrame & " = " & Chr(34) & lstVariables(i) & Chr(34) Next strCalcFromList = strCalcFromList & ")" Return strCalcFromList @@ -399,7 +394,9 @@ Public Class sdgCalculationsSummmary clsCalculationFunction.RemoveParameterByName("calculated_from") Else clsCalculationFunction.AddParameter("function_exp", Chr(34) & ucrDefineFilter.ucrFilterPreview.GetText() & Chr(34)) - clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList(ucrDefineFilter.ucrSelectorForFitler.lstVariablesInReceivers, ucrDefineFilter.ucrSelectorForFitler)) + clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList( + ucrDefineFilter.ucrSelectorForFitler.CurrentReceiver.GetVariableNamesList(bWithQuotes:=False), + ucrDefineFilter.ucrSelectorForFitler)) End If End If End Sub diff --git a/instat/ucrReceiver.vb b/instat/ucrReceiver.vb index 1e6affcfddd..d34273d7ca4 100644 --- a/instat/ucrReceiver.vb +++ b/instat/ucrReceiver.vb @@ -14,6 +14,7 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . +Imports System.Windows.Documents Imports instat Imports instat.Translations Imports RDotNet @@ -98,7 +99,7 @@ Public Class ucrReceiver bUpdateRCodeFromControl = True End Sub - Public Overridable Sub AddSelected() + Public Overridable Sub AddSelectedSelectorVariables() End Sub @@ -133,7 +134,7 @@ Public Class ucrReceiver End Sub 'This refers to the selector list of columns - Public Overridable Sub RemoveAnyVariablesNotInList() + Public Overridable Sub RemoveAnyVariablesNotInSelector() End Sub @@ -150,18 +151,15 @@ Public Class ucrReceiver End Property Public Overridable Function GetVariables(Optional bForceAsDataFrame As Boolean = False) As RFunction - Dim clsGetVariablesFunc As New RFunction - Return clsGetVariablesFunc + Return New RFunction End Function - Public Overridable Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String - Dim strVarNames As String = "" - Return strVarNames + Public Overridable Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Return "" End Function Public Overridable Function GetVariableNamesList(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String() - Dim strVarNames As String() = Nothing - Return strVarNames + Return Nothing End Function Public Overridable Sub SetMeAsReceiver() @@ -475,16 +473,30 @@ Public Class ucrReceiver End If Clear() If lstCurrentVariables IsNot Nothing Then - For Each strTemp As String In lstCurrentVariables + If Selector IsNot Nothing Then + strTempDataName = Selector.strCurrentDataFrame + End If + If TypeOf Me Is ucrReceiverMultiple Then + 'TODO This only works if the selector is updated before receivers and dialog only uses one data frame! ' Needs to change eventually. - If Selector IsNot Nothing AndAlso strTemp <> "" Then - If strTempDataName = "" Then - strTempDataName = Selector.strCurrentDataFrame - End If + Dim lstItems As New List(Of KeyValuePair(Of String, String)) + For Each strTemp As String In lstCurrentVariables + lstItems.Add(New KeyValuePair(Of String, String)(strTempDataName, strTemp)) + Next + + DirectCast(Me, ucrReceiverMultiple).AddMultiple(lstItems) + RemoveAnyVariablesNotInSelector() 'needed due to the Autofill option + Else + For Each strTemp As String In lstCurrentVariables + 'TODO This only works if the selector is updated before receivers and dialog only uses one data frame! + ' Needs to change eventually. Add(strTemp, strTempDataName) - End If - Next + Next + + End If + + End If End If End If diff --git a/instat/ucrReceiverExpression.vb b/instat/ucrReceiverExpression.vb index a881dd26c51..f4f297c1a45 100644 --- a/instat/ucrReceiverExpression.vb +++ b/instat/ucrReceiverExpression.vb @@ -14,79 +14,78 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports RDotNet - -Public Class ucrReceiverExpression - Private lstItemsInExpression As List(Of KeyValuePair(Of String, String)) - Private lstDataFrames As List(Of String) +Imports RDotNet + +Public Class ucrReceiverExpression + Private lstItemsInExpression As List(Of KeyValuePair(Of String, String)) + Private lstDataFrames As List(Of String) Private iCurrentPosition As Integer = 0 - Public Sub New() - ' This call is required by the designer. - InitializeComponent() - - ' Add any initialization after the InitializeComponent() call. - lstItemsInExpression = New List(Of KeyValuePair(Of String, String)) - lstDataFrames = New List(Of String) - End Sub - - Public Overrides Sub AddSelected() - If Selector.lstAvailableVariable.SelectedItems.Count = 1 Then - Add(Selector.lstAvailableVariable.SelectedItems.Item(0).Text, Selector.lstAvailableVariable.SelectedItems.Item(0).Tag) - Else - 'Error? - End If - End Sub - - Public Overrides Sub Add(strItem As String, Optional strDataFrame As String = "", Optional bFixReceiver As Boolean = False) - Dim strCurrentItemType As String - Dim kvpItem As KeyValuePair(Of String, String) - - MyBase.Add(strItem, strDataFrame) - - If bTypeSet Then - strCurrentItemType = strType - Else - strCurrentItemType = Selector.GetItemType() - End If - - If cboExpression.Enabled Then - If strCurrentItemType = "column" Then - If strDataFrame = "" Then - SetMeAsReceiver() - For i = 0 To Selector.lstAvailableVariable.Items.Count - 1 - If Selector.lstAvailableVariable.Items(i).Text = strItem Then - strDataFrame = Selector.lstAvailableVariable.Items(i).Tag - End If - Next - End If - End If - If Not lstDataFrames.Contains(strDataFrame) Then - lstDataFrames.Add(strDataFrame) - End If - kvpItem = New KeyValuePair(Of String, String)(strDataFrame, strItem) - AddToItemsInExpressionList(kvpItem) - AddToReceiverAtCursorPosition(strItem) - Selector.AddToVariablesList(strItem, strDataFrame) + Public Sub New() + ' This call is required by the designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + lstItemsInExpression = New List(Of KeyValuePair(Of String, String)) + lstDataFrames = New List(Of String) + End Sub + + Public Overrides Sub AddSelectedSelectorVariables() + If Selector.lstAvailableVariable.SelectedItems.Count = 1 Then + Add(Selector.lstAvailableVariable.SelectedItems.Item(0).Text, Selector.lstAvailableVariable.SelectedItems.Item(0).Tag) + Else + 'Error? + End If + End Sub + + Public Overrides Sub Add(strItem As String, Optional strDataFrame As String = "", Optional bFixReceiver As Boolean = False) + Dim strCurrentItemType As String + Dim kvpItem As KeyValuePair(Of String, String) + + MyBase.Add(strItem, strDataFrame) + + If bTypeSet Then + strCurrentItemType = strType + Else + strCurrentItemType = Selector.GetItemType() + End If + + If cboExpression.Enabled Then + If strCurrentItemType = "column" Then + If strDataFrame = "" Then + SetMeAsReceiver() + For i = 0 To Selector.lstAvailableVariable.Items.Count - 1 + If Selector.lstAvailableVariable.Items(i).Text = strItem Then + strDataFrame = Selector.lstAvailableVariable.Items(i).Tag + End If + Next + End If + End If + If Not lstDataFrames.Contains(strDataFrame) Then + lstDataFrames.Add(strDataFrame) + End If + kvpItem = New KeyValuePair(Of String, String)(strDataFrame, strItem) + AddToItemsInExpressionList(kvpItem) + AddToReceiverAtCursorPosition(strItem) OnSelectionChanged() 'we need this to run when everything else has run cboExpression.Enabled = Not bFixReceiver - End If + End If + End Sub + + Private Sub AddToItemsInExpressionList(kvpItem As KeyValuePair(Of String, String)) + If Not lstItemsInExpression.Contains(kvpItem) Then + lstItemsInExpression.Add(kvpItem) + End If End Sub - Private Sub AddToItemsInExpressionList(kvpItem As KeyValuePair(Of String, String)) - If Not lstItemsInExpression.Contains(kvpItem) Then - lstItemsInExpression.Add(kvpItem) - End If - End Sub - - Public Sub AddToReceiverAtPosition(strText As String, iPosition As Integer, Optional iSetCursorBackCharacters As Integer = 0) - cboExpression.Text = cboExpression.Text.Insert(iPosition, strText) + Public Sub AddToReceiverAtPosition(strText As String, iPosition As Integer, Optional iSetCursorBackCharacters As Integer = 0) + cboExpression.Text = cboExpression.Text.Insert(iPosition, strText) iCurrentPosition = iPosition + strText.Length - iSetCursorBackCharacters - cboExpression.SelectionStart = iCurrentPosition - cboExpression.SelectedText = "" - 'Adding focus to the function in the Receiver Expreession - cboExpression.Focus() + cboExpression.SelectionStart = iCurrentPosition + cboExpression.SelectedText = "" + 'Adding focus to the function in the Receiver Expreession + cboExpression.Focus() End Sub Public Sub Backspace() @@ -94,25 +93,18 @@ Public Class ucrReceiverExpression cboExpression.Text = Mid(cboExpression.Text, 1, iCurrentPosition - 1) & Mid(cboExpression.Text, iCurrentPosition + 1, Len(cboExpression.Text) - iCurrentPosition + 1) iCurrentPosition = iCurrentPosition - 1 End If - End Sub - - Public Sub AddToReceiverAtCursorPosition(strText As String, Optional iSetCursorBackCharacters As Integer = 0) - AddToReceiverAtPosition(strText, iCurrentPosition, iSetCursorBackCharacters) - End Sub - - Public Overrides Sub RemoveSelected() - Dim kvpItem As KeyValuePair(Of String, String) - - If cboExpression.Enabled Then - If Selector IsNot Nothing Then - For Each kvpItem In lstItemsInExpression - Selector.RemoveFromVariablesList(kvpItem.Value, kvpItem.Key) - Next - End If - cboExpression.Text = "" - cboExpression.Focus() - End If - MyBase.RemoveSelected() + End Sub + + Public Sub AddToReceiverAtCursorPosition(strText As String, Optional iSetCursorBackCharacters As Integer = 0) + AddToReceiverAtPosition(strText, iCurrentPosition, iSetCursorBackCharacters) + End Sub + + Public Overrides Sub RemoveSelected() + If cboExpression.Enabled Then + cboExpression.Text = "" + cboExpression.Focus() + End If + MyBase.RemoveSelected() End Sub Public Function GetText() As String @@ -120,12 +112,12 @@ Public Class ucrReceiverExpression End Function Public Overrides Sub Clear() - RemoveSelected() - iCurrentPosition = 0 - End Sub - - Public Overrides Function IsEmpty() As Boolean - Return cboExpression.Text = "" + RemoveSelected() + iCurrentPosition = 0 + End Sub + + Public Overrides Function IsEmpty() As Boolean + Return cboExpression.Text = "" End Function Public Sub AddtoCombobox(strNew As String) @@ -134,24 +126,24 @@ Public Class ucrReceiverExpression End If End Sub - Private Sub cboExpression_KeyUp(sender As Object, e As KeyEventArgs) Handles cboExpression.KeyUp - iCurrentPosition = cboExpression.SelectionStart - End Sub - - Private Sub cboExpression_MouseDown(sender As Object, e As MouseEventArgs) Handles cboExpression.MouseDown - iCurrentPosition = cboExpression.SelectionStart - End Sub - - Private Sub cboExpression_TextChanged(sender As Object, e As EventArgs) Handles cboExpression.TextChanged - OnSelectionChanged() - End Sub - - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String - If bWithQuotes Then - Return Chr(34) & cboExpression.Text & Chr(34) - Else - Return cboExpression.Text - End If + Private Sub cboExpression_KeyUp(sender As Object, e As KeyEventArgs) Handles cboExpression.KeyUp + iCurrentPosition = cboExpression.SelectionStart + End Sub + + Private Sub cboExpression_MouseDown(sender As Object, e As MouseEventArgs) Handles cboExpression.MouseDown + iCurrentPosition = cboExpression.SelectionStart + End Sub + + Private Sub cboExpression_TextChanged(sender As Object, e As EventArgs) Handles cboExpression.TextChanged + OnSelectionChanged() + End Sub + + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + If bWithQuotes Then + Return Chr(34) & cboExpression.Text & Chr(34) + Else + Return cboExpression.Text + End If End Function Private Sub cboExpression_GotFocus(sender As Object, e As EventArgs) Handles cboExpression.GotFocus diff --git a/instat/ucrReceiverMultiple.vb b/instat/ucrReceiverMultiple.vb index 34baa703fb5..2c44abcdb72 100644 --- a/instat/ucrReceiverMultiple.vb +++ b/instat/ucrReceiverMultiple.vb @@ -34,85 +34,130 @@ Public Class ucrReceiverMultiple End If End Sub - Public Overrides Sub AddSelected() - Dim lstItems(Selector.lstAvailableVariable.SelectedItems.Count - 1) As KeyValuePair(Of String, String) - Dim lviTemp As ListViewItem - Dim i As Integer = 0 - - For Each lviTemp In Selector.lstAvailableVariable.SelectedItems - lstItems(i) = New KeyValuePair(Of String, String)(lviTemp.Tag, lviTemp.Text) - i = i + 1 + Public Overrides Sub AddSelectedSelectorVariables() + Dim lstItems As New List(Of KeyValuePair(Of String, String)) + For Each lviTemp As ListViewItem In Selector.lstAvailableVariable.SelectedItems + lstItems.Add(New KeyValuePair(Of String, String)(lviTemp.Tag, lviTemp.Text)) Next AddMultiple(lstItems) End Sub - Private Function GetCurrItemNames() As List(Of String) - Dim strItemNames As New List(Of String) - Dim currItem As ListViewItem + Public Sub AddMultiple(lstItems As IEnumerable(Of KeyValuePair(Of String, String))) + Dim lstActualItemsToAdd As New List(Of KeyValuePair(Of String, String)) + 'first eliminate all items that already exist + 'this improves perfomance significantly for wide data sets + For Each kvpTempItem As KeyValuePair(Of String, String) In lstItems + If lstSelectedVariables.FindItemWithText(kvpTempItem.Value) Is Nothing Then + lstActualItemsToAdd.Add(kvpTempItem) + End If + Next - For Each currItem In lstSelectedVariables.Items - strItemNames.Add(currItem.Text) + 'then add the new items + For Each kvpTempItem As KeyValuePair(Of String, String) In lstActualItemsToAdd + lstSelectedVariables.Items.Add(New ListViewItem With { + .Name = kvpTempItem.Value, + .Text = kvpTempItem.Value, + .ToolTipText = kvpTempItem.Value, + .Tag = kvpTempItem.Key, + .Group = AddGroupName(kvpTempItem.Key) + }) Next - Return strItemNames - End Function - Private Function GetCurrGroupNames() As List(Of String) - Dim strHeaders As New List(Of String) - Dim grpTemp As ListViewGroup + SetGroupHeaderVariablesCount() - For Each grpTemp In lstSelectedVariables.Groups - strHeaders.Add(grpTemp.Name) + OnSelectionChanged() + End Sub + + 'add new group if it exist and return it + 'support of multiple groups assumes that the receiver may have variables from more than one data frame + 'this feature is not yet supported fully + Private Function AddGroupName(strNewGroupName As String) As ListViewGroup + For Each grp In lstSelectedVariables.Groups + If grp.Name = strNewGroupName Then + Return grp + End If Next - Return strHeaders + Dim newGrp As New ListViewGroup(key:=strNewGroupName, headerText:=strNewGroupName) + lstSelectedVariables.Groups.Add(newGrp) + Return newGrp End Function - Public Overrides Sub RemoveSelected() - Dim objItem As ListViewItem - Dim tempObjects(lstSelectedVariables.SelectedItems.Count - 1) As Object - - If lstSelectedVariables.SelectedItems.Count > 0 Then - lstSelectedVariables.SelectedItems.CopyTo(tempObjects, 0) - For Each objItem In tempObjects - lstSelectedVariables.Items.Remove(objItem) - Selector.RemoveFromVariablesList(objItem.Text, objItem.Tag) - Next + Public Overrides Sub Add(strItem As String, Optional strDataFrame As String = "", Optional bFixreceiver As Boolean = False) + Dim kvpItems(0) As KeyValuePair(Of String, String) + If strDataFrame = "" Then + Dim lvi As ListViewItem = Selector.lstAvailableVariable.FindItemWithText(strItem) + If lvi IsNot Nothing Then + strDataFrame = lvi.Tag + End If End If + kvpItems(0) = New KeyValuePair(Of String, String)(strDataFrame, strItem) + AddMultiple(kvpItems) + + RemoveAnyVariablesNotInSelector() 'needed due to the Autofill option + + lstSelectedVariables.Enabled = Not bFixreceiver + End Sub + + Public Overrides Sub RemoveSelected() + For Each lvi As ListViewItem In lstSelectedVariables.SelectedItems + lstSelectedVariables.Items.Remove(lvi) + Next + SetGroupHeaderVariablesCount() OnSelectionChanged() MyBase.RemoveSelected() End Sub Public Overrides Sub Remove(strItems() As String) - MyBase.Remove(strItems) - - If strItems.Count > 0 Then - For Each strTempItem In strItems - lstSelectedVariables.Items.RemoveByKey(strTempItem) - 'TODO pass data frame for variables - Selector.RemoveFromVariablesList(strTempItem) - Next - OnSelectionChanged() - MyBase.RemoveSelected() - End If + For Each strTempItem In strItems + lstSelectedVariables.Items.RemoveByKey(strTempItem) + Next + SetGroupHeaderVariablesCount() + OnSelectionChanged() + MyBase.RemoveSelected() End Sub Public Overrides Sub Clear() - Dim lviVar As ListViewItem - Dim strItems As New List(Of String) + lstSelectedVariables.Items.Clear() + lstSelectedVariables.Groups.Clear() + OnSelectionChanged() + MyBase.RemoveSelected() + End Sub + + + ''' + ''' Removes any variable in the multiple receiver + ''' that is not in the list of variables of the selector + ''' + Public Overrides Sub RemoveAnyVariablesNotInSelector() + Dim lstItemsToRemove As New List(Of ListViewItem) + For Each lvi As ListViewItem In lstSelectedVariables.Items + If Selector.lstAvailableVariable.FindItemWithText(lvi.Text) Is Nothing Then + lstItemsToRemove.Add(lvi) + End If + Next - For Each lviVar In lstSelectedVariables.Items - strItems.Add(lviVar.Text) + For Each lvi As ListViewItem In lstItemsToRemove + lstSelectedVariables.Items.Remove(lvi) Next - Remove(strItems.ToArray()) + + OnSelectionChanged() + MyBase.RemoveSelected() End Sub - Public Overrides Function IsEmpty() As Boolean + Private Sub SetGroupHeaderVariablesCount() + 'show count selection at the header of the receiver + 'todo. support this feature for receivers that have 1 data frame only. + 'it's not clear when the receiver will ever have more than one data frame - If lstSelectedVariables.Items.Count > 0 Then - Return False - Else - Return True + 'reset the header text with the name + lstSelectedVariables.Groups(0).Header = lstSelectedVariables.Groups(0).Name + If lstSelectedVariables.Groups.Count = 1 AndAlso lstSelectedVariables.Items.Count > 0 Then + lstSelectedVariables.Groups(0).Header = lstSelectedVariables.Groups(0).Header & " (" & lstSelectedVariables.Items.Count & ")" End If + End Sub + Public Overrides Function IsEmpty() As Boolean + Return lstSelectedVariables.Items.Count = 0 End Function Public Function Count() As Integer @@ -196,6 +241,8 @@ Public Class ucrReceiverMultiple Return clsGetVariablesFunc End Function + 'todo. this function is used by dlgCombineText dialog only. + 'after refactoring the dialog, remove it from here. Public Function GetVariablesAsList() As List(Of RFunction) Dim lstColumnFunctions As New List(Of RFunction) Dim strColumn As String @@ -224,71 +271,46 @@ Public Class ucrReceiverMultiple Return lstColumnFunctions End Function - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String - Dim strTemp As String = "" - Dim i As Integer + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Dim strTempBuilder As New Text.StringBuilder + Dim strQuoteHolder As String = If(bWithQuotes, Chr(34), "") + If lstSelectedVariables.Items.Count = 1 AndAlso Not bForceVariablesAsList Then - If bWithQuotes Then - strTemp = Chr(34) & lstSelectedVariables.Items(0).Text & Chr(34) - Else - strTemp = lstSelectedVariables.Items(0).Text - End If + strTempBuilder.Append(strQuoteHolder).Append(lstSelectedVariables.Items(0).Text).Append(strQuoteHolder) ElseIf lstSelectedVariables.Items.Count > 1 OrElse bForceVariablesAsList Then - If strVariablesListPackageName <> "" Then - strTemp = strVariablesListPackageName & "::" - End If - strTemp = strTemp & strVariablesListFunctionName & "(" - For i = 0 To lstSelectedVariables.Items.Count - 1 - If i > 0 Then - strTemp = strTemp & "," - End If - If lstSelectedVariables.Items(i).Text <> "" Then - If bWithQuotes Then - strTemp = strTemp & Chr(34) & lstSelectedVariables.Items(i).Text & Chr(34) - Else - strTemp = strTemp & lstSelectedVariables.Items(i).Text - End If - End If + strTempBuilder.Append(If(strVariablesListPackageName <> "", strVariablesListPackageName & "::", "")) + strTempBuilder.Append(strVariablesListFunctionName).Append("(") + For Each lvi As ListViewItem In lstSelectedVariables.Items + strTempBuilder.Append(strQuoteHolder).Append(lvi.Text).Append(strQuoteHolder).Append(",") Next - strTemp = strTemp & ")" + strTempBuilder.Length -= 1 'remove last comma + strTempBuilder.Append(")") End If - - Return strTemp + Return strTempBuilder.ToString() End Function Public Overrides Function GetVariableNamesList(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String() - Dim lstItems As String() - - ReDim lstItems(0 To lstSelectedVariables.Items.Count - 1) + Dim arrItems(lstSelectedVariables.Items.Count) As String + Dim strQuoteHolder As String = If(bWithQuotes, strQuotes, "") For i = 0 To lstSelectedVariables.Items.Count - 1 - If bWithQuotes Then - lstItems(i) = strQuotes & lstSelectedVariables.Items(i).Text & strQuotes - Else - lstItems(i) = lstSelectedVariables.Items(i).Text - End If + arrItems(i) = strQuoteHolder & lstSelectedVariables.Items(i).Text & strQuoteHolder Next - Return lstItems + Return arrItems End Function Public Function GetVariableNamesAsList() As List(Of String) - Dim lstItems As New List(Of String) - - For i = 0 To lstSelectedVariables.Items.Count - 1 - lstItems.Add(lstSelectedVariables.Items(i).Text) + Dim lstItems As New List(Of String)(lstSelectedVariables.Items.Count) + For Each lvi As ListViewItem In lstSelectedVariables.Items + lstItems.Add(lvi.Text) Next Return lstItems End Function Public Function GetDataFrameNames() As List(Of String) Dim strDataFrames As New List(Of String) - Dim CurrObj As ListViewItem - - For Each CurrObj In lstSelectedVariables.Items - If Not strDataFrames.Contains(CurrObj.Group.Header) Then - strDataFrames.Add(CurrObj.Group.Header) - End If + For Each CurrObj As ListViewGroup In lstSelectedVariables.Groups + strDataFrames.Add(CurrObj.Name) Next - Return strDataFrames End Function @@ -300,17 +322,6 @@ Public Class ucrReceiverMultiple lstSelectedVariables.BackColor = Color.White End Sub - ''' - ''' Removes any variable in the multiple receiver - ''' that is not in the list of variables of the selector - ''' - Public Overrides Sub RemoveAnyVariablesNotInList() - For Each strVar In GetVariableNamesAsList() - If Selector.lstAvailableVariable.FindItemWithText(strVar) Is Nothing Then - Remove({strVar}) - End If - Next - End Sub Private Sub lstSelectedVariables_KeyDown(sender As Object, e As KeyEventArgs) Handles lstSelectedVariables.KeyDown If e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Back Then @@ -338,45 +349,6 @@ Public Class ucrReceiverMultiple End If End Function - Public Sub AddMultiple(lstItems As KeyValuePair(Of String, String)()) - Dim kvpTempItem As KeyValuePair(Of String, String) - Dim grpCurr As New ListViewGroup - - For Each kvpTempItem In lstItems - If Not GetCurrItemNames().Contains(kvpTempItem.Value) Then - If Not GetCurrGroupNames().Contains(kvpTempItem.Key) Then - grpCurr = New ListViewGroup(key:=kvpTempItem.Key, headerText:=kvpTempItem.Key) - lstSelectedVariables.Groups.Add(grpCurr) - Else - grpCurr = lstSelectedVariables.Groups(GetCurrGroupNames().IndexOf(kvpTempItem.Key)) - End If - lstSelectedVariables.Items.Add(kvpTempItem.Value).Group = grpCurr - lstSelectedVariables.Items(lstSelectedVariables.Items.Count - 1).Tag = kvpTempItem.Key - lstSelectedVariables.Items(lstSelectedVariables.Items.Count - 1).Name = kvpTempItem.Value - lstSelectedVariables.Items(lstSelectedVariables.Items.Count - 1).ToolTipText = kvpTempItem.Value - Selector.AddToVariablesList(kvpTempItem.Value, kvpTempItem.Key) - End If - Next - OnSelectionChanged() - End Sub - - Public Overrides Sub Add(strItem As String, Optional strDataFrame As String = "", Optional bFixreceiver As Boolean = False) - Dim kvpItems(0) As KeyValuePair(Of String, String) - If strDataFrame = "" Then - For i = 0 To Selector.lstAvailableVariable.Items.Count - 1 - If Selector.lstAvailableVariable.Items(i).Text = strItem Then - strDataFrame = Selector.lstAvailableVariable.Items(i).Tag - End If - Next - End If - kvpItems(0) = New KeyValuePair(Of String, String)(strDataFrame, strItem) - AddMultiple(kvpItems) - - RemoveAnyVariablesNotInList() 'needed due to the Autofill option - - lstSelectedVariables.Enabled = Not bFixreceiver - End Sub - Public Function GetCurrentItemTypes(Optional bUnique As Boolean = False, Optional bIsCategoricalNumeric As Boolean = False) As List(Of String) Dim clsGetDataType As New RFunction Dim strDataTypes As New List(Of String) @@ -518,6 +490,12 @@ Public Class ucrReceiverMultiple End Sub Public Overrides Function GetItemsDataFrames() As List(Of String) - Return GetCurrGroupNames() + Dim strHeaders As New List(Of String) + Dim grpTemp As ListViewGroup + + For Each grpTemp In lstSelectedVariables.Groups + strHeaders.Add(grpTemp.Name) + Next + Return strHeaders End Function End Class \ No newline at end of file diff --git a/instat/ucrReceiverSingle.vb b/instat/ucrReceiverSingle.vb index e600bd5732e..49e4fd96c3c 100644 --- a/instat/ucrReceiverSingle.vb +++ b/instat/ucrReceiverSingle.vb @@ -35,7 +35,7 @@ Public Class ucrReceiverSingle strCurrDataType = "" End Sub - Public Overrides Sub AddSelected() + Public Overrides Sub AddSelectedSelectorVariables() 'Dim tempObjects(Selector.lstAvailableVariable.SelectedItems.Count - 1) As ListViewItem If Selector.lstAvailableVariable.SelectedItems.Count = 1 Then @@ -53,16 +53,6 @@ Public Class ucrReceiverSingle Dim expColumnType As SymbolicExpression Dim bRemove As Boolean = False - 'Would prefer to have remove selected but that will first clear the receiver - 'This has issues when reading RSyntax and filling receivers e.g. in Specific plot dialogs - 'Because it modifies the list of parameters it is looping through when clearing first, crashing - 'Below is the part from RemoveSelected() that is needed - 'This is only an issue with single receiver - 'If RemoveSelected() later contains other things, this may need to be updated. - 'RemoveSelected() - If Selector IsNot Nothing Then - Selector.RemoveFromVariablesList(txtReceiverSingle.Text, strDataFrame) - End If MyBase.Add(strItem, strDataFrame) strCurrentItemType = If(bTypeSet, strType, Selector?.GetItemType()) @@ -118,9 +108,6 @@ Public Class ucrReceiverSingle End If strDataFrameName = strDataFrame txtReceiverSingle.Text = strItem - If Selector IsNot Nothing Then - Selector.AddToVariablesList(strItem, strDataFrameName) - End If If bRemove Then RemoveSelected() End If @@ -130,9 +117,6 @@ Public Class ucrReceiverSingle Public Overrides Sub RemoveSelected() If txtReceiverSingle.Enabled Then - If Selector IsNot Nothing Then - Selector.RemoveFromVariablesList(txtReceiverSingle.Text, strDataFrameName) - End If txtReceiverSingle.Text = "" strDataFrameName = "" End If @@ -234,22 +218,12 @@ Public Class ucrReceiverSingle End If End Function - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String - Dim strTemp As String = "" - If txtReceiverSingle.Text <> "" Then - If bWithQuotes Then - strTemp = Chr(34) & txtReceiverSingle.Text & Chr(34) - Else - strTemp = txtReceiverSingle.Text - End If - End If - Return strTemp + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Return If(bWithQuotes, strQuotes & txtReceiverSingle.Text & strQuotes, txtReceiverSingle.Text) End Function Public Overrides Function GetVariableNameslist(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String() - Dim arrTemp As String() = Nothing - arrTemp = {GetVariableNames()} - Return arrTemp + Return {GetVariableNames(bWithQuotes:=bWithQuotes, strQuotes:=strQuotes)} End Function Public Function GetDataName() As String @@ -281,7 +255,6 @@ Public Class ucrReceiverSingle If bDisableReceiver Then Add("variable", "") Me.Enabled = False - Selector.RemoveFromVariablesList("variable") Else Me.Enabled = True If txtReceiverSingle.Text = "variable" Then diff --git a/instat/ucrSelector.vb b/instat/ucrSelector.vb index 22e8c9f50fd..fd628cd26ea 100644 --- a/instat/ucrSelector.vb +++ b/instat/ucrSelector.vb @@ -17,9 +17,8 @@ Public Class ucrSelector Public CurrentReceiver As ucrReceiver Public Event ResetAll() Public Event ResetReceivers() - Public Event VariablesInReceiversChanged() Public Event DataFrameChanged() - Public lstVariablesInReceivers As List(Of Tuple(Of String, String)) + Public bFirstLoad As Boolean Public strCurrentDataFrame As String = "" ' If a dialog has receivers which can have columns from multiple data frames @@ -50,7 +49,6 @@ Public Class ucrSelector InitializeComponent() ' Add any initialization after the InitializeComponent() call. - lstVariablesInReceivers = New List(Of Tuple(Of String, String)) bFirstLoad = True 'bIncludeOverall = False lstIncludedMetadataProperties = New List(Of KeyValuePair(Of String, String())) @@ -115,7 +113,7 @@ Public Class ucrSelector lstCombinedMetadataLists = CombineMetadataLists(CurrentReceiver.lstIncludedMetadataProperties, CurrentReceiver.lstExcludedMetadataProperties) If CurrentReceiver.bExcludeFromSelector Then - arrStrExclud = GetVariablesInReceiver().ToArray + arrStrExclud = CurrentReceiver.GetVariableNamesList(bWithQuotes:=False) End If 'set the type of 'elements' to show. If current receiver is set to a particular 'element' type then use it @@ -151,7 +149,7 @@ Public Class ucrSelector strHeading:=CurrentReceiver.strSelectorHeading, strDataFrameName:=strCurrentDataFrame, strExcludedItems:=arrStrExclud, strDatabaseQuery:=CurrentReceiver.strDatabaseQuery, strNcFilePath:=CurrentReceiver.strNcFilePath) If Not CurrentReceiver.bExcludeFromSelector Then - CurrentReceiver.RemoveAnyVariablesNotInList() 'this needed for the multiple receiver(s) where the autofill is not applied + CurrentReceiver.RemoveAnyVariablesNotInSelector() 'this needed for the multiple receiver(s) where the autofill is not applied End If EnableDataOptions(strCurrentType) @@ -202,20 +200,10 @@ Public Class ucrSelector Return strSelectorFillCondition End Function - Private Function GetVariablesInReceiver() As List(Of String) - Dim lstVars As New List(Of String) - - For Each tplTemp As Tuple(Of String, String) In lstVariablesInReceivers - lstVars.Add(tplTemp.Item1) - Next - Return lstVars - End Function - Public Overridable Sub Reset() RaiseEvent ResetReceivers() - lstVariablesInReceivers.Clear() + 'lstVariablesInReceivers.Clear() LoadList() - 'lstItemsInReceivers.Clear() End Sub Public Sub SetCurrentReceiver(conReceiver As ucrReceiver) @@ -261,7 +249,7 @@ Public Class ucrSelector Public Sub Add() If CurrentReceiver IsNot Nothing AndAlso (lstAvailableVariable.SelectedItems.Count > 0) Then - CurrentReceiver.AddSelected() + CurrentReceiver.AddSelectedSelectorVariables() 'sets current focus enabling correct tab navigation CurrentReceiver.Focus() 'check if autoswitching from the receiver is allowed before doing an autoswitch. @@ -329,27 +317,26 @@ Public Class ucrSelector ucrLinkedSelector = ucrNewLinkedSelector End Sub - Public Sub AddToVariablesList(strVariable As String, Optional strDataFrame As String = "") - If strDataFrame = "" OrElse strDataFrame = strCurrentDataFrame Then - lstVariablesInReceivers.Add(New Tuple(Of String, String)(strVariable, strDataFrame)) - If ucrLinkedSelector IsNot Nothing Then - ucrLinkedSelector.AddToVariablesList(strVariable, strCurrentDataFrame) - End If - RaiseEvent VariablesInReceiversChanged() - End If - End Sub + 'Public lstVariablesInReceivers As List(Of Tuple(Of String, String)) + 'Public Sub AddToVariablesList(strVariable As String, Optional strDataFrame As String = "") + ' If strDataFrame = "" OrElse strDataFrame = strCurrentDataFrame Then + ' lstVariablesInReceivers.Add(New Tuple(Of String, String)(strVariable, strDataFrame)) + ' If ucrLinkedSelector IsNot Nothing Then + ' ucrLinkedSelector.AddToVariablesList(strVariable, strCurrentDataFrame) + ' End If + ' End If + 'End Sub - Public Sub RemoveFromVariablesList(strVariable As String, Optional strDataFrame As String = "") - For i As Integer = lstVariablesInReceivers.Count - 1 To 0 Step -1 - If lstVariablesInReceivers(i).Item1 = strVariable AndAlso (strDataFrame = "" OrElse lstVariablesInReceivers(i).Item2 = strDataFrame) Then - lstVariablesInReceivers.RemoveAt(i) - End If - Next - If ucrLinkedSelector IsNot Nothing Then - ucrLinkedSelector.RemoveFromVariablesList(strVariable, strCurrentDataFrame) - End If - RaiseEvent VariablesInReceiversChanged() - End Sub + 'Public Sub RemoveFromVariablesList(strVariable As String, Optional strDataFrame As String = "") + ' For i As Integer = lstVariablesInReceivers.Count - 1 To 0 Step -1 + ' If lstVariablesInReceivers(i).Item1 = strVariable AndAlso (strDataFrame = "" OrElse lstVariablesInReceivers(i).Item2 = strDataFrame) Then + ' lstVariablesInReceivers.RemoveAt(i) + ' End If + ' Next + ' If ucrLinkedSelector IsNot Nothing Then + ' ucrLinkedSelector.RemoveFromVariablesList(strVariable, strCurrentDataFrame) + ' End If + 'End Sub Public Sub AddIncludedMetadataProperty(strProperty As String, strInclude As String()) Dim iIncludeIndex As Integer diff --git a/instat/ucrVariablesAsFactor.vb b/instat/ucrVariablesAsFactor.vb index 1909cf33d05..6ed854247d1 100644 --- a/instat/ucrVariablesAsFactor.vb +++ b/instat/ucrVariablesAsFactor.vb @@ -62,7 +62,7 @@ Public Class ucrVariablesAsFactor OnSelectionChanged() End Sub - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String 'This sub provides the name of the variable that should be used by external components that want to access the "content" of this receiver. If it is in single mode, this is simply providing the name of the variable in use. 'However in multiple mode, a New variable will be created using the "stack" And "measure.vars" explained in SetReceiverStatus. Dim strVariables As String = "" From dcbd9744e2a7c68742fdce378581f2f13534b477 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:21:44 +0300 Subject: [PATCH 07/57] Changes on the bar chart's and pie chart's reorder and receiver controls. Small issue still present in the reorder for pie chart --- instat/dlgBarAndPieChart.vb | 168 ++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 85 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 3ea7fae80ba..62aec23d316 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -611,12 +611,10 @@ Public Class dlgBarAndPieChart Private Sub SetRCodeForControls(bReset As Boolean) ucrBarChartSelector.AddAdditionalCodeParameterPair(clsSubsetFunction1, ucrBarChartSelector.GetParameter(), iAdditionalPairNo:=1) ucrBarChartSelector.AddAdditionalCodeParameterPair(clsSubsetFunction2, ucrBarChartSelector.GetParameter(), iAdditionalPairNo:=2) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsPieAesFunction, ucrReceiverByFactor.GetParameter(), iAdditionalPairNo:=1) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator1, New RParameter("left", 0), iAdditionalPairNo:=2) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator2, New RParameter("left", 0), iAdditionalPairNo:=3) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("x", 0), iAdditionalPairNo:=4) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsReorderFunctionValue, New RParameter("x", 0), iAdditionalPairNo:=5) - ucrVariablesAsFactorForBarChart.AddAdditionalCodeParameterPair(clsPieAesFunction, ucrVariablesAsFactorForBarChart.GetParameter(), iAdditionalPairNo:=1) + ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator1, New RParameter("left", 0), iAdditionalPairNo:=1) + ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsIsEqualToOperator2, New RParameter("left", 0), iAdditionalPairNo:=2) + ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("x", 0), iAdditionalPairNo:=3) + ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsReorderFunctionValue, New RParameter("x", 0), iAdditionalPairNo:=4) ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) @@ -815,74 +813,81 @@ Public Class dlgBarAndPieChart If rdoFrequency.Checked Then clsForecatsInfreq.AddParameter("f", "as.factor(" & ucrVariablesAsFactorForBarChart.GetVariableNames(False) & ")", iPosition:=0) clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrReceiverByFactor.GetVariableNames(False) & ")", iPosition:=0) - Select Case strChangedTextFreq - Case strAscending - clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strDescending - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - Case strReverse - clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case Else - clsBarAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) - End Select - Select Case strChangedTextValue - Case strAscending - clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) - Case strDescending - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=1) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=2) - Case strReverse - clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) - Case Else - clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) - - End Select - Else - Select Case strChangeTextReorder - Case strAscending - clsReorderFunction.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) - Case strDescending - clsReorderFunction.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) - Case strReverse - clsForecatsReverse.AddParameter("f", ucrReceiverX.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) - Case Else - clsBarAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("x", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) - End Select - Select Case strChangedTextValue - Case strAscending - clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - Case strDescending - clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - Case strReverse - clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - Case Else - clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) - End Select + If ucrChkReorderFrequency.Checked AndAlso strChangedTextFreq <> strNone Then + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strNone + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + End Select + End If + If Not ucrReceiverByFactor.IsEmpty AndAlso strChangedTextValue <> strNone Then + Select Case strChangedTextValue + Case strAscending + clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + Case strDescending + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=2) + Case strReverse + clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + Case strNone + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + End Select + End If + ElseIf rdoValue.Checked Then + If ucrChkReorderValue.Checked AndAlso strChangeTextReorder <> strNone Then + Select Case strChangeTextReorder + Case strAscending + clsReorderFunction.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + Case strDescending + clsReorderFunction.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrReceiverX.GetVariableNames(False), iPosition:=0) + clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + Case strNone + clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=2) + End Select + End If + If Not ucrReceiverByFactor.IsEmpty AndAlso strChangedTextValue <> strNone Then + Select Case strChangedTextValue + Case strAscending + clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case strDescending + clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case strReverse + clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case strNone + clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + End Select + End If End If End Sub @@ -933,15 +938,7 @@ Public Class dlgBarAndPieChart End If ElseIf rdoFrequency.Checked Then If ucrChkPolarCoordinates.Checked Then - If rdoPie.Checked Then - If ucrReceiverByFactor.IsEmpty Then - clsPieAesFunction.AddParameter("x", "1", iPosition:=0) - clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) - Else - clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - End If - Else + If rdoPie.Checked OrElse rdoDonut.Checked Then If ucrReceiverByFactor.IsEmpty Then clsPieAesFunction.AddParameter("x", "1", iPosition:=0) clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) @@ -957,7 +954,6 @@ Public Class dlgBarAndPieChart clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - End If If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) @@ -969,6 +965,7 @@ Public Class dlgBarAndPieChart clsRgeomBarFunction2.RemoveParameterByName("stat") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) End If + clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_treemap") clsBaseOperator.RemoveParameterByName("geom_text_wordcloud") ElseIf rdoTreeMap.Checked Then @@ -1053,7 +1050,8 @@ Public Class dlgBarAndPieChart SetGeomTextOptions() End Sub - Private Sub ucrChkPolarCoordinates_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkPolarCoordinates.ControlValueChanged, ucrPnlPolar.ControlValueChanged + Private Sub ucrChkPolarCoordinates_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkPolarCoordinates.ControlValueChanged, ucrPnlPolar.ControlValueChanged, + ucrChkReorderValue.ControlValueChanged, ucrChkReorderFrequency.ControlValueChanged ' adding coordpolar geom clsBaseOperator.RemoveParameterByName("coordpolar") ChangeParameterName() From 655941384c6453c4c87923252bb22d3e45d85b98 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Mon, 14 Aug 2023 12:23:29 +0300 Subject: [PATCH 08/57] Fixing geoms --- instat/dlgBarAndPieChart.Designer.vb | 24 ++++++++++++++++-------- instat/dlgBarAndPieChart.vb | 6 +++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/instat/dlgBarAndPieChart.Designer.vb b/instat/dlgBarAndPieChart.Designer.vb index cb6f182f0a4..7e857d855c2 100644 --- a/instat/dlgBarAndPieChart.Designer.vb +++ b/instat/dlgBarAndPieChart.Designer.vb @@ -111,6 +111,7 @@ Partial Class dlgBarAndPieChart Me.ucrChkAddLabelsTreemap = New instat.ucrCheck() Me.ucrChkBacktoback = New instat.ucrCheck() Me.ucrChkIncreaseSize = New instat.ucrCheck() + Me.toolStripMenuItemTreemapTextOptionsOptions = New System.Windows.Forms.ToolStripMenuItem() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -387,44 +388,44 @@ Partial Class dlgBarAndPieChart ' 'contextMenuStripOptions ' - Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemBarchartOptions, Me.toolStripMenuItemLollipopOptions, Me.toolStripMenuItemTextOptions, Me.toolStripMenuItemTreemapOptions, Me.toolStripMenuItemWordcloudOptions}) + Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemBarchartOptions, Me.toolStripMenuItemTextOptions, Me.toolStripMenuItemLollipopOptions, Me.toolStripMenuItemTreemapOptions, Me.toolStripMenuItemTreemapTextOptionsOptions, Me.toolStripMenuItemWordcloudOptions}) Me.contextMenuStripOptions.Name = "contextMenuStripOk" - Me.contextMenuStripOptions.Size = New System.Drawing.Size(181, 158) + Me.contextMenuStripOptions.Size = New System.Drawing.Size(189, 180) ' 'toolStripMenuItemPlotOptions ' Me.toolStripMenuItemPlotOptions.Name = "toolStripMenuItemPlotOptions" - Me.toolStripMenuItemPlotOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemPlotOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemPlotOptions.Text = "Plot Options" ' 'toolStripMenuItemBarchartOptions ' Me.toolStripMenuItemBarchartOptions.Name = "toolStripMenuItemBarchartOptions" - Me.toolStripMenuItemBarchartOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemBarchartOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemBarchartOptions.Text = "BarChart Options" ' 'toolStripMenuItemLollipopOptions ' Me.toolStripMenuItemLollipopOptions.Name = "toolStripMenuItemLollipopOptions" - Me.toolStripMenuItemLollipopOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemLollipopOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemLollipopOptions.Text = "Lollipop Options" ' 'toolStripMenuItemTextOptions ' Me.toolStripMenuItemTextOptions.Name = "toolStripMenuItemTextOptions" - Me.toolStripMenuItemTextOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemTextOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemTextOptions.Text = "Text Options" ' 'toolStripMenuItemTreemapOptions ' Me.toolStripMenuItemTreemapOptions.Name = "toolStripMenuItemTreemapOptions" - Me.toolStripMenuItemTreemapOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemTreemapOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemTreemapOptions.Text = "Treemap Options" ' 'toolStripMenuItemWordcloudOptions ' Me.toolStripMenuItemWordcloudOptions.Name = "toolStripMenuItemWordcloudOptions" - Me.toolStripMenuItemWordcloudOptions.Size = New System.Drawing.Size(180, 22) + Me.toolStripMenuItemWordcloudOptions.Size = New System.Drawing.Size(188, 22) Me.toolStripMenuItemWordcloudOptions.Text = "Wordcloud Options" ' 'cmdOptions @@ -862,6 +863,12 @@ Partial Class dlgBarAndPieChart Me.ucrChkIncreaseSize.Size = New System.Drawing.Size(88, 23) Me.ucrChkIncreaseSize.TabIndex = 63 ' + 'toolStripMenuItemTreemapTextOptionsOptions + ' + Me.toolStripMenuItemTreemapTextOptionsOptions.Name = "toolStripMenuItemTreemapTextOptionsOptions" + Me.toolStripMenuItemTreemapTextOptionsOptions.Size = New System.Drawing.Size(188, 22) + Me.toolStripMenuItemTreemapTextOptionsOptions.Text = "Treemap Text Options" + ' 'dlgBarAndPieChart ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -1016,4 +1023,5 @@ Partial Class dlgBarAndPieChart Friend WithEvents toolStripMenuItemWordcloudOptions As ToolStripMenuItem Friend WithEvents cmdOptions As ucrSplitButton Friend WithEvents toolStripMenuItemLollipopOptions As ToolStripMenuItem + Friend WithEvents toolStripMenuItemTreemapTextOptionsOptions As ToolStripMenuItem End Class \ No newline at end of file diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 62aec23d316..25d727b7ea9 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -744,7 +744,7 @@ Public Class dlgBarAndPieChart End Sub Private Sub toolStripMenuItemBarchartOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemBarchartOptions.Click - openSdgLayerOptions(clsRgeomBarFunction, clsBarAesFunction) + openSdgLayerOptions(clsRgeomBarFunction1, clsBarAesFunction) End Sub Private Sub toolStripMenuItemLollipopOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemLollipopOptions.Click @@ -759,6 +759,10 @@ Public Class dlgBarAndPieChart openSdgLayerOptions(clsGeomTextWordcloudFunction, clsGeomTextWordcloudAesFunction) End Sub + Private Sub toolStripMenuItemTreemapTextOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTreemapTextOptionsOptions.Click + openSdgLayerOptions(clsGeomTreemapTextFunction, clsGeomTreemapTextAesFunction) + End Sub + Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTextOptions.Click openSdgLayerOptions(clsGeomTextFunction, clsGeomTextAesFunction) End Sub From a1c050d0d16fd81803ce98cb56a93bb4f30885c7 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Tue, 15 Aug 2023 09:29:51 +0300 Subject: [PATCH 09/57] Changes in the code --- instat/dlgBarAndPieChart.vb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 25d727b7ea9..0a830430b5f 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -59,7 +59,6 @@ Public Class dlgBarAndPieChart Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsGeomTextFunction As New RFunction - Private clsGeomTextAesFunction As New RFunction Private clsLabelAesFunction As New RFunction Private clsAnnotateFunction As New RFunction Private clsForecatsInfreq As New RFunction @@ -393,7 +392,6 @@ Public Class dlgBarAndPieChart clsScaleXdiscretFunction = New RFunction clsExpansionFunction = New RFunction clsGeomTextFunction = New RFunction - clsGeomTextAesFunction = New RFunction clsLabelAesFunction = New RFunction clsForecatsInfreq = New RFunction clsForecatsReverse = New RFunction @@ -545,9 +543,6 @@ Public Class dlgBarAndPieChart clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) - clsGeomTextAesFunction.SetPackageName("ggplot2") - clsGeomTextAesFunction.SetRCommand("aes") - clsLabelAesFunction.SetPackageName("ggplot2") clsLabelAesFunction.SetRCommand("aes") @@ -764,7 +759,7 @@ Public Class dlgBarAndPieChart End Sub Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTextOptions.Click - openSdgLayerOptions(clsGeomTextFunction, clsGeomTextAesFunction) + openSdgLayerOptions(clsGeomTextFunction, clsLabelAesFunction) End Sub Private Sub SetDialogOptions() From 10272c0f653e3b26ef59745e8d8a1a945f13ad82 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:39:20 +0300 Subject: [PATCH 10/57] Fixing developer error but there is still an issue with the geom text --- instat/dlgBarAndPieChart.vb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 0a830430b5f..624483d1e28 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -536,6 +536,9 @@ Public Class dlgBarAndPieChart clsScaleYSymmetricFunction.SetPackageName("lemon") clsScaleYSymmetricFunction.SetRCommand("scale_y_symmetric") + clsLabelAesFunction.SetPackageName("ggplot2") + clsLabelAesFunction.SetRCommand("aes") + clsGeomTextFunction.SetPackageName("ggplot2") clsGeomTextFunction.SetRCommand("geom_text") clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) @@ -543,9 +546,6 @@ Public Class dlgBarAndPieChart clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) - clsLabelAesFunction.SetPackageName("ggplot2") - clsLabelAesFunction.SetRCommand("aes") - clsGeomTreemapFunction.SetPackageName("treemapify") clsGeomTreemapFunction.SetRCommand("geom_treemap") clsGeomTreemapFunction.AddParameter("layout", Chr(34) & "squarified" & Chr(34), iPosition:=0) @@ -643,12 +643,12 @@ Public Class dlgBarAndPieChart ucrReceiverWordcloudAngle.SetRCode(clsGeomTextWordcloudAesFunction, bReset) ucrChkAddLabelsTreemap.SetRCode(clsBaseOperator, bReset) ucrNudMaxSize.SetRCode(clsScaleSizeAreaFunction, bReset) - ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset) ucrChkReorderFrequency.SetRCode(clsDummyFunction, bReset) If bReset Then ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) + ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset) ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) End If End Sub From 1f8fb28b5ed9132aea80dcf79d6766a46ef1951b Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:52:48 +0300 Subject: [PATCH 11/57] Changes in the code (WIP) --- instat/dlgBarAndPieChart.vb | 76 +++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 624483d1e28..df3753985a9 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -696,34 +696,38 @@ Public Class dlgBarAndPieChart bResetLineLayerSubdialog = False 'Coming from the sdgLayerOptions, clsRaesFunction and others have been modified. ' One then needs to display these modifications on the dlgScatteredPlot. - - 'The aesthetics parameters on the main dialog are repopulated as required. - For Each clsParam In clsLabelAesFunction.clsParameters - If clsParam.strArgumentName = "x" Then - If clsParam.strArgumentValue = Chr(34) & Chr(34) Then - ucrReceiverX.Clear() - Else - ucrReceiverX.Add(clsParam.strArgumentValue) - End If - 'In the y case, the value stored in the clsReasFunction in the multiple variables - ' case is "value", however that one shouldn't be written in the multiple - ' variables receiver (otherwise it would stack all variables and the stack - ' ("value") itself!). - 'Warning: what if someone used the name value for one of it's variables - ' independently from the multiple variables method? Here if the receiver is - ' actually in single mode, the variable "value" will still be given back, which - ' throws the problem back to the creation of "value" in the multiple receiver case. - ElseIf clsParam.strArgumentName = "y" AndAlso (clsParam.strArgumentValue <> "value" OrElse ucrVariablesAsFactorForBarChart.bSingleVariable) Then - 'Still might be in the case of bSingleVariable with mapping y="". - If clsParam.strArgumentValue = Chr(34) & Chr(34) Then - ucrVariablesAsFactorForBarChart.Clear() - Else - ucrReceiverWordcloudSize.Add(clsParam.strArgumentValue) + Try + 'The aesthetics parameters on the main dialog are repopulated as required. + For Each clsParam In clsNewAesFunction.clsParameters + If clsParam.strArgumentName = "x" Then + If clsParam.strArgumentValue = Chr(34) & Chr(34) Then + ucrReceiverX.Clear() + Else + ucrReceiverX.Add(clsParam.strArgumentValue) + End If + 'In the y case, the value stored in the clsReasFunction in the multiple variables + ' case is "value", however that one shouldn't be written in the multiple + ' variables receiver (otherwise it would stack all variables and the stack + ' ("value") itself!). + 'Warning: what if someone used the name value for one of it's variables + ' independently from the multiple variables method? Here if the receiver is + ' actually in single mode, the variable "value" will still be given back, which + ' throws the problem back to the creation of "value" in the multiple receiver case. + ElseIf clsParam.strArgumentName = "y" AndAlso (clsParam.strArgumentValue <> "value" OrElse ucrVariablesAsFactorForBarChart.bSingleVariable) Then + 'Still might be in the case of bSingleVariable with mapping y="". + If clsParam.strArgumentValue = Chr(34) & Chr(34) Then + ucrVariablesAsFactorForBarChart.Clear() + Else + ucrReceiverWordcloudSize.Add(clsParam.strArgumentValue) + End If + ElseIf clsParam.strArgumentName = "colour" Then + ucrReceiverByFactor.Add(clsParam.strArgumentValue) End If - ElseIf clsParam.strArgumentName = "colour" Then - ucrReceiverByFactor.Add(clsParam.strArgumentValue) - End If - Next + Next + Catch ex As Exception + MsgBox(ex.Message) + End Try + TestOkEnabled() End Sub @@ -897,6 +901,8 @@ Public Class dlgBarAndPieChart clsPieAesFunction.RemoveParameterByName("x") clsPieAesFunction.RemoveParameterByName("y") clsPieAesFunction.RemoveParameterByName("fill") + clsRggplotFunction.RemoveParameterByName("mapping") + clsRggplotFunction.RemoveParameterByName("aes") If rdoValue.Checked Then clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) @@ -927,6 +933,9 @@ Public Class dlgBarAndPieChart End If If ucrChkLollipop.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) + If ucrChkAddLabelsText.Checked Then + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + End If clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") End If @@ -948,21 +957,31 @@ Public Class dlgBarAndPieChart End If clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) + If ucrChkAddLabelsText.Checked Then + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + End If Else If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + clsLabelAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsLabelAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + clsLabelAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) Else clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsLabelAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) End If clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsRgeomBarFunction2.RemoveParameterByName("stat") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) + If ucrChkAddLabelsText.Checked Then + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + End If End If clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_treemap") @@ -1050,7 +1069,7 @@ Public Class dlgBarAndPieChart End Sub Private Sub ucrChkPolarCoordinates_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkPolarCoordinates.ControlValueChanged, ucrPnlPolar.ControlValueChanged, - ucrChkReorderValue.ControlValueChanged, ucrChkReorderFrequency.ControlValueChanged + ucrChkReorderValue.ControlValueChanged, ucrChkReorderFrequency.ControlValueChanged, ucrChkAddLabelsText.ControlValueChanged ' adding coordpolar geom clsBaseOperator.RemoveParameterByName("coordpolar") ChangeParameterName() @@ -1071,6 +1090,7 @@ Public Class dlgBarAndPieChart clsBaseOperator.AddParameter("geom_text", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=5) Else clsBaseOperator.RemoveParameterByName("geom_text") + clsRggplotFunction.RemoveParameterByName("mapping") End If End Sub From 31293dce44bfd19e608ebd1f33b7f96db87e531b Mon Sep 17 00:00:00 2001 From: n-thony Date: Thu, 17 Aug 2023 12:00:01 +0300 Subject: [PATCH 12/57] bug fixes --- instat/dlgBarAndPieChart.vb | 84 ++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index df3753985a9..30f87392755 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -59,7 +59,7 @@ Public Class dlgBarAndPieChart Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsGeomTextFunction As New RFunction - Private clsLabelAesFunction As New RFunction + Private clsTextAesFunction As New RFunction Private clsAnnotateFunction As New RFunction Private clsForecatsInfreq As New RFunction Private clsForecatsReverse As New RFunction @@ -392,7 +392,7 @@ Public Class dlgBarAndPieChart clsScaleXdiscretFunction = New RFunction clsExpansionFunction = New RFunction clsGeomTextFunction = New RFunction - clsLabelAesFunction = New RFunction + clsTextAesFunction = New RFunction clsForecatsInfreq = New RFunction clsForecatsReverse = New RFunction clsForecatsInfreqValue = New RFunction @@ -536,12 +536,14 @@ Public Class dlgBarAndPieChart clsScaleYSymmetricFunction.SetPackageName("lemon") clsScaleYSymmetricFunction.SetRCommand("scale_y_symmetric") - clsLabelAesFunction.SetPackageName("ggplot2") - clsLabelAesFunction.SetRCommand("aes") + clsTextAesFunction.SetPackageName("ggplot2") + clsTextAesFunction.SetRCommand("aes") + clsTextAesFunction.AddParameter("label", "..count..", iPosition:=0) + clsGeomTextFunction.SetPackageName("ggplot2") clsGeomTextFunction.SetRCommand("geom_text") - clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) clsGeomTextFunction.AddParameter("colour", "black", iPosition:=4) clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) @@ -567,7 +569,7 @@ Public Class dlgBarAndPieChart clsGeomTreemapTextAesFunction.SetPackageName("ggplot2") clsGeomTreemapTextAesFunction.SetRCommand("aes") - clsGeomTreemapTextAesFunction.AddParameter("label", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) + 'clsGeomTreemapTextAesFunction.AddParameter("label", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) clsGeomTextWordcloudAesFunction.SetPackageName("ggplot2") @@ -611,8 +613,8 @@ Public Class dlgBarAndPieChart ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("x", 0), iAdditionalPairNo:=3) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsReorderFunctionValue, New RParameter("x", 0), iAdditionalPairNo:=4) ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) - ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) - ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) + 'ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) + 'ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) @@ -727,14 +729,14 @@ Public Class dlgBarAndPieChart Catch ex As Exception MsgBox(ex.Message) End Try - + SetGeomTextOptions() TestOkEnabled() End Sub Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click, toolStripMenuItemPlotOptions.Click sdgPlots.SetRCode(clsNewOperator:=ucrBase.clsRsyntax.clsBaseOperator, clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewXLabsTitleFunction:=clsXlabFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, - clsNewThemeFunction:=clsThemeFuction, dctNewThemeFunctions:=dctThemeFunctions, clsNewGlobalAesFunction:=clsLabelAesFunction, ucrNewBaseSelector:=ucrBarChartSelector, + clsNewThemeFunction:=clsThemeFuction, dctNewThemeFunctions:=dctThemeFunctions, clsNewGlobalAesFunction:=clsTextAesFunction, ucrNewBaseSelector:=ucrBarChartSelector, clsNewCoordPolarFunction:=clsCoordPolarFunction, clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewAnnotateFunction:=clsAnnotateFunction, clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, strMainDialogGeomParameterNames:=strGeomParameterNames, bReset:=bResetSubdialog) @@ -763,7 +765,7 @@ Public Class dlgBarAndPieChart End Sub Private Sub toolStripMenuItemPointOptions_Click(sender As Object, e As EventArgs) Handles toolStripMenuItemTextOptions.Click - openSdgLayerOptions(clsGeomTextFunction, clsLabelAesFunction) + openSdgLayerOptions(clsGeomTextFunction, clsTextAesFunction) End Sub Private Sub SetDialogOptions() @@ -876,16 +878,16 @@ Public Class dlgBarAndPieChart Select Case strChangedTextValue Case strAscending clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) Case strDescending clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strReverse clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) Case strNone clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) @@ -910,12 +912,14 @@ Public Class dlgBarAndPieChart clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) clsGeomLollipopAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsGeomLollipopAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsGeomLollipopAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=2) clsRgeomBarFunction2.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=1) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "identity" & Chr(34), iPosition:=1) + clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_treemap") clsBaseOperator.RemoveParameterByName("geom_treemap_text") clsBaseOperator.RemoveParameterByName("geom_text_wordcloud") @@ -934,17 +938,18 @@ Public Class dlgBarAndPieChart If ucrChkLollipop.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) End If clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") End If - If ucrChkBacktoback.Checked Then - clsBaseOperator.RemoveParameterByName("geom_bar") - Else - clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) - End If + 'If ucrChkBacktoback.Checked Then + ' clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) + 'Else + ' clsBaseOperator.RemoveParameterByName("geom_bar") + 'End If ElseIf rdoFrequency.Checked Then + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) If ucrChkPolarCoordinates.Checked Then If rdoPie.Checked OrElse rdoDonut.Checked Then If ucrReceiverByFactor.IsEmpty Then @@ -958,29 +963,28 @@ Public Class dlgBarAndPieChart clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) End If Else If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - clsLabelAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + clsTextAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsLabelAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsTextAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) - clsLabelAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + clsTextAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) Else clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsLabelAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsTextAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) End If clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsRgeomBarFunction2.RemoveParameterByName("stat") - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) End If End If clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) @@ -990,11 +994,13 @@ Public Class dlgBarAndPieChart clsBaseOperator.RemoveParameterByName("geom_bar") clsBaseOperator.RemoveParameterByName("geom_text") clsBaseOperator.RemoveParameterByName("geom_text_wordcloud") + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) clsBaseOperator.AddParameter("geom_treemap", clsRFunctionParameter:=clsGeomTreemapFunction, iPosition:=2) ElseIf rdoWordCloud.Checked Then clsBaseOperator.RemoveParameterByName("geom_treemap") clsBaseOperator.RemoveParameterByName("geom_treemap_text") clsBaseOperator.RemoveParameterByName("geom_bar") + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextWordcloudAesFunction, iPosition:=1) clsBaseOperator.AddParameter("geom_text_wordcloud", clsRFunctionParameter:=clsGeomTextWordcloudFunction, iPosition:=2) If ucrChkIncreaseSize.Checked Then clsBaseOperator.AddParameter("scale_size_area", clsRFunctionParameter:=clsScaleSizeAreaFunction, iPosition:=3) @@ -1014,8 +1020,7 @@ Public Class dlgBarAndPieChart ChangeParameterName() If rdoTreeMap.Checked Then ucrReceiverArea.SetMeAsReceiver() - End If - If rdoWordCloud.Checked Then + ElseIf rdoWordCloud.Checked Then ucrReceiverWordcloudLabel.SetMeAsReceiver() End If End Sub @@ -1031,7 +1036,7 @@ Public Class dlgBarAndPieChart End Sub Private Sub ucrChkBacktoback_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkBacktoback.ControlValueChanged, - ucrVariablesAsFactorForBarChart.ControlValueChanged, ucrReceiverX.ControlValueChanged + ucrVariablesAsFactorForBarChart.ControlValueChanged, ucrReceiverX.ControlValueChanged, ucrPnlOptions.ControlValueChanged If rdoFrequency.Checked OrElse rdoValue.Checked Then clsBaseOperator.RemoveParameterByName("geom_bar1") clsBaseOperator.RemoveParameterByName("geom_bar2") @@ -1056,11 +1061,11 @@ Public Class dlgBarAndPieChart If rdoValue.Checked Then clsAesFunction1.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsAesFunction2.AddParameter("y", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsRgeomBarFunction2.AddParameter("aes", clsRFunctionParameter:=clsAesFunction1, iPosition:=1, bIncludeArgumentName:=False) - clsRgeomBarFunction1.AddParameter("aes", clsRFunctionParameter:=clsAesFunction2, iPosition:=1, bIncludeArgumentName:=False) + clsRgeomBarFunction2.AddParameter("aes", clsRFunctionParameter:=clsAesFunction1, iPosition:=1) + clsRgeomBarFunction1.AddParameter("aes", clsRFunctionParameter:=clsAesFunction2, iPosition:=1) Else clsAesFunction1.AddParameter("y", "..count..*(-1)", iPosition:=0) - clsRgeomBarFunction1.AddParameter("aes", clsRFunctionParameter:=clsAesFunction1, iPosition:=1, bIncludeArgumentName:=False) + clsRgeomBarFunction1.AddParameter("aes", clsRFunctionParameter:=clsAesFunction1, iPosition:=1) End If End If End If @@ -1112,10 +1117,13 @@ Public Class dlgBarAndPieChart End If If rdoFrequency.Checked Then clsGeomTextFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=0) - clsLabelAesFunction.AddParameter("label", "..count..", iPosition:=0) + If ucrChkAddLabelsText.Checked AndAlso + clsTextAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "label") < 0 Then + clsTextAesFunction.AddParameter("label", "..count..", iPosition:=0) + End If Else - clsGeomTextFunction.RemoveParameterByName("stat") - clsLabelAesFunction.AddParameter("label", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsGeomTextFunction.RemoveParameterByName("stat") + clsTextAesFunction.AddParameter("label", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If End Sub From 7aa2fc1a89361500793d045ec961dd936daebabc Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:08:50 +0300 Subject: [PATCH 13/57] Changes to code --- instat/dlgBarAndPieChart.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 30f87392755..b3acbf2001d 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -1122,7 +1122,7 @@ Public Class dlgBarAndPieChart clsTextAesFunction.AddParameter("label", "..count..", iPosition:=0) End If Else - clsGeomTextFunction.RemoveParameterByName("stat") + clsGeomTextFunction.RemoveParameterByName("stat") clsTextAesFunction.AddParameter("label", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If End Sub From f4cd1b07d6bcebc2a1c890afc895dc3c6a84143b Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:27:24 +0300 Subject: [PATCH 14/57] Minor code changes. --- instat/dlgBarAndPieChart.vb | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index b3acbf2001d..4b3fadd5fab 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -78,7 +78,6 @@ Public Class dlgBarAndPieChart Private clsDummyFunction As New RFunction Private clsPointsFunction As New RFunction Private clsGeomLollipopAesFunction As New RFunction - Private clsPieFunction As New RFunction Private ReadOnly strAscending As String = "Ascending" Private ReadOnly strDescending As String = "Descending" @@ -410,7 +409,6 @@ Public Class dlgBarAndPieChart clsDummyFunction = New RFunction clsPointsFunction = New RFunction clsGeomLollipopAesFunction = New RFunction - clsPieFunction = New RFunction ucrBarChartSelector.Reset() ucrBarChartSelector.SetGgplotFunction(clsBaseOperator) @@ -467,11 +465,6 @@ Public Class dlgBarAndPieChart clsBarAesFunction.SetPackageName("ggplot2") clsBarAesFunction.SetRCommand("aes") - clsPieFunction.SetPackageName("ggplot2") - clsPieFunction.SetRCommand("aes") - clsPieFunction.AddParameter("x", Chr(34) & Chr(34)) - clsPieFunction.AddParameter("y", Chr(34) & Chr(34)) - clsPieAesFunction.SetPackageName("ggplot2") clsPieAesFunction.SetRCommand("aes") @@ -540,7 +533,6 @@ Public Class dlgBarAndPieChart clsTextAesFunction.SetRCommand("aes") clsTextAesFunction.AddParameter("label", "..count..", iPosition:=0) - clsGeomTextFunction.SetPackageName("ggplot2") clsGeomTextFunction.SetRCommand("geom_text") clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) @@ -561,7 +553,6 @@ Public Class dlgBarAndPieChart clsGeomTreemapAesFunction.SetPackageName("ggplot2") clsGeomTreemapAesFunction.SetRCommand("aes") - clsGeomTreemapAesFunction.AddParameter("area", clsRFunctionParameter:=clsAsNumericFunction, iPosition:=0) clsAsNumericFunction.SetRCommand("as.numeric") @@ -569,8 +560,6 @@ Public Class dlgBarAndPieChart clsGeomTreemapTextAesFunction.SetPackageName("ggplot2") clsGeomTreemapTextAesFunction.SetRCommand("aes") - 'clsGeomTreemapTextAesFunction.AddParameter("label", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) - clsGeomTextWordcloudAesFunction.SetPackageName("ggplot2") clsGeomTextWordcloudAesFunction.SetRCommand("aes") @@ -613,8 +602,6 @@ Public Class dlgBarAndPieChart ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsLevelsFunction, New RParameter("x", 0), iAdditionalPairNo:=3) ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsReorderFunctionValue, New RParameter("x", 0), iAdditionalPairNo:=4) ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) - 'ucrReceiverFill.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("label", 1), iAdditionalPairNo:=1) - 'ucrReceiverArea.AddAdditionalCodeParameterPair(clsGeomTreemapTextAesFunction, New RParameter("area", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) @@ -802,9 +789,6 @@ Public Class dlgBarAndPieChart If ucrVariablesAsFactorForBarChart.bSingleVariable Then ucrChkReorderValue.Visible = True ucrInputAddReorder.Visible = Not ucrReceiverByFactor.IsEmpty() - 'If Not ucrInputAddReorder.Visible Then - ' ucrInputAddReorder.SetText(strNone) - 'End If Else ucrChkReorderValue.Visible = False End If @@ -943,11 +927,6 @@ Public Class dlgBarAndPieChart clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") End If - 'If ucrChkBacktoback.Checked Then - ' clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) - 'Else - ' clsBaseOperator.RemoveParameterByName("geom_bar") - 'End If ElseIf rdoFrequency.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) If ucrChkPolarCoordinates.Checked Then From 1e85c0e7f4efcbd7afe865ccdec5729ce29afdc0 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 22 Aug 2023 12:26:07 +0300 Subject: [PATCH 15/57] Adds message to the column metadata --- instat/ucrColumnMetadata.vb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 21d86078bd0..bb12e532470 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -62,6 +62,13 @@ Public Class ucrColumnMetadata Exit Sub End If + 'todo. this check is necessary for wide data sets + 'once the "paging" feature is implemented, then the check can be removed. + If dataFrame.clsColumnMetaData.iRowCount > 1000 AndAlso + DialogResult.No = MessageBox.Show(Me, "Are you sure you need " & dataFrame.strName & " column metadata? If so, be patient. It, will be slow to load the first time", dataFrame.strName & " Column Metadata", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) Then + Exit Sub + End If + _grid.CurrentWorksheet = fillWorksheet _grid.UpdateWorksheetStyle(fillWorksheet) _grid.AddColumns(dataFrame.clsColumnMetaData) From b16194aab6f750d304fd8724dbc0e908e64a5226 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 22 Aug 2023 13:57:36 +0300 Subject: [PATCH 16/57] small cahnges to frmMain windows contents --- instat/frmMain.vb | 59 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/instat/frmMain.vb b/instat/frmMain.vb index 08b5707786c..5b71fa4fed9 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -551,6 +551,18 @@ Public Class frmMain End Sub Public Sub UpdateLayout() + 'splOverall has 2 panels + 'splDataOutput.Panel1 contains splExtraWindows + 'splDataOutput.Panel2 contains splDataOutput + + 'splExtraWindows has 2 panels + 'splExtraWindows.Panel1 contains splMetadata which contains data frame and column metadata windows + 'splExtraWindows.Panel2 contains script window + + 'splDataOutput has 2 panels + 'splDataOutput.Panel1 contains data viewer window + 'splDataOutput.Panel2 contains output window + If Not mnuViewDataView.Checked _ AndAlso Not mnuViewOutput.Checked _ AndAlso Not mnuViewColumnMetadata.Checked _ @@ -560,32 +572,43 @@ Public Class frmMain splOverall.Hide() Else splOverall.Show() - If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then - splOverall.Panel2Collapsed = False - splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked - splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked - Else - splOverall.Panel2Collapsed = True - End If - If mnuViewColumnMetadata.Checked _ - OrElse mnuViewDataFrameMetadata.Checked _ - OrElse mnuViewLogScript.Checked Then - splOverall.Panel1Collapsed = False + + 'determine splOverall contents visibility + + '------------------------------- + 'determine splOverall.Panel1 and it's contents visibility + + If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked OrElse mnuViewLogScript.Checked Then + 'change splOverall.Panel1Collapsed contents visibilty If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked Then - splExtraWindows.Panel1Collapsed = False splMetadata.Panel1Collapsed = Not mnuViewColumnMetadata.Checked splMetadata.Panel2Collapsed = Not mnuViewDataFrameMetadata.Checked + splExtraWindows.Panel1Collapsed = False Else splExtraWindows.Panel1Collapsed = True End If - If mnuViewLogScript.Checked Then - splExtraWindows.Panel2Collapsed = False - Else - splExtraWindows.Panel2Collapsed = True - End If + 'expand panel 1 + splOverall.Panel1Collapsed = False + 'expand panel 2 based on log script menu item checked status + splExtraWindows.Panel2Collapsed = Not mnuViewLogScript.Checked Else splOverall.Panel1Collapsed = True End If + '------------------------------- + + '------------------------------- + 'determine splOverall.Panel2 and it's contents visibility + + If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then + splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked + splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked + splOverall.Panel2Collapsed = False + Else + splOverall.Panel2Collapsed = True + End If + '------------------------------- + + End If mnuTbDataView.Checked = mnuViewDataView.Checked mnuOutputWindow.Checked = mnuViewOutput.Checked @@ -640,7 +663,7 @@ Public Class frmMain End Sub Private Sub mnuPrepareSheetColumnMetadata_Click(sender As Object, e As EventArgs) Handles mnuViewColumnMetadata.Click - mnuViewColumnMetadata.Checked = True + mnuViewColumnMetadata.Checked = Not mnuViewColumnMetadata.Checked UpdateLayout() End Sub From 4f6ecd6db8acbe37cdbddc3733c1eaef51466df9 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 22 Aug 2023 15:32:41 +0300 Subject: [PATCH 17/57] Removes oddity on startup and toggling visibility of windows in main form --- instat/frmMain.vb | 227 ++++++++++++++++++--------------- instat/ucrColumnMetadata.vb | 74 ++++++----- instat/ucrDataFrameMetadata.vb | 23 ++-- instat/ucrScript.vb | 88 +++++++------ 4 files changed, 231 insertions(+), 181 deletions(-) diff --git a/instat/frmMain.vb b/instat/frmMain.vb index 5b71fa4fed9..c65e42af663 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -80,6 +80,10 @@ Public Class frmMain InitializeComponent() ' Add any initialization after the InitializeComponent() call. + + 'set controls layout + SetupInitialLayout() + clsOutputLogger = New clsOutputLogger clsRLink = New RLink(clsOutputLogger) If RuntimeInformation.IsOSPlatform(OSPlatform.Windows) Then @@ -128,8 +132,6 @@ Public Class frmMain ucrOutput.SetLogger(clsOutputLogger) - SetToDefaultLayout() - '--------------------------------------- 'set up R-Instat options (settings) 'load any saved options if available @@ -218,6 +220,114 @@ Public Class frmMain isMaximised = True 'Need to get the windowstate when the application is loaded End Sub + Private Sub SetupInitialLayout() + 'splOverall has 2 panels + 'splOverall.Panel1 contains splExtraWindows + 'splOverall.Panel2 contains splDataOutput + + 'splExtraWindows has 2 panels + 'splExtraWindows.Panel1 contains splMetadata + 'splExtraWindows.Panel2 contains script window + + 'splMetadata has 2 panels + 'splMetadata.Panel1 contains data frame + 'splMetadata.Panel2 contains column metadata + + 'splDataOutput has 2 panels + 'splDataOutput.Panel1 contains data viewer window + 'splDataOutput.Panel2 contains output window + + 'collaspe all the panels initially (on application startup) + splOverall.Panel1Collapsed = True + splOverall.Panel2Collapsed = True + + splExtraWindows.Panel1Collapsed = True + splExtraWindows.Panel2Collapsed = True + + splMetadata.Panel1Collapsed = True + splMetadata.Panel2Collapsed = True + + splDataOutput.Panel1Collapsed = True + splDataOutput.Panel2Collapsed = True + + SetToDefaultLayout() + End Sub + + Private Sub SetToDefaultLayout() + splOverall.SplitterDistance = splOverall.Height / 4 + splDataOutput.SplitterDistance = splDataOutput.Width / 2 + splExtraWindows.SplitterDistance = splExtraWindows.Width / 2 + splMetadata.SplitterDistance = splMetadata.Width / 2 + + mnuViewDataView.Checked = True + mnuViewOutput.Checked = True + mnuViewDataFrameMetadata.Checked = False + mnuViewColumnMetadata.Checked = False + mnuViewLogScript.Checked = False + mnuViewSwapDataAndMetadata.Checked = False + mnuColumnMetadat.Checked = False + mnuDataFrameMetadat.Checked = False + + mnuTbDataView.Checked = True + mnuOutputWindow.Checked = True + mnuLogScript.Checked = False + UpdateLayout() + End Sub + + Public Sub UpdateLayout() + + If Not mnuViewDataView.Checked _ + AndAlso Not mnuViewOutput.Checked _ + AndAlso Not mnuViewColumnMetadata.Checked _ + AndAlso Not mnuViewDataFrameMetadata.Checked _ + AndAlso Not mnuViewLogScript.Checked _ + AndAlso Not mnuViewSwapDataAndMetadata.Checked Then + splOverall.Hide() + Else + splOverall.Show() + + 'determine splOverall contents visibility + + '------------------------------- + 'determine splOverall.Panel1 and it's contents visibility + + If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked OrElse mnuViewLogScript.Checked Then + 'expand panel 1 + splOverall.Panel1Collapsed = False + 'change splOverall.Panel1Collapsed contents visibilty + If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked Then + splMetadata.Panel1Collapsed = Not mnuViewColumnMetadata.Checked + splMetadata.Panel2Collapsed = Not mnuViewDataFrameMetadata.Checked + splExtraWindows.Panel1Collapsed = False + Else + splExtraWindows.Panel1Collapsed = True + End If + 'expand panel 2 based on log script menu item checked status + splExtraWindows.Panel2Collapsed = Not mnuViewLogScript.Checked + Else + splOverall.Panel1Collapsed = True + End If + '------------------------------- + + '------------------------------- + 'determine splOverall.Panel2 and it's contents visibility + + If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then + splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked + splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked + splOverall.Panel2Collapsed = False + Else + splOverall.Panel2Collapsed = True + End If + '------------------------------- + + + End If + mnuTbDataView.Checked = mnuViewDataView.Checked + mnuOutputWindow.Checked = mnuViewOutput.Checked + mnuLogScript.Checked = mnuViewLogScript.Checked + End Sub + Private Function GetSavedRInstatOptions() As InstatOptions Dim clsInstatOptions As InstatOptions = Nothing Dim strFilePath As String = Path.Combine(strAppDataPath, strInstatOptionsFile) @@ -426,29 +536,21 @@ Public Class frmMain End If End Sub - - - Private Sub SetToDefaultLayout() - splOverall.SplitterDistance = splOverall.Height / 4 - splDataOutput.SplitterDistance = splDataOutput.Width / 2 - splExtraWindows.SplitterDistance = splExtraWindows.Width / 2 - splMetadata.SplitterDistance = splMetadata.Width / 2 - - mnuViewDataView.Checked = True - mnuViewOutput.Checked = True - mnuViewDataFrameMetadata.Checked = False - mnuViewColumnMetadata.Checked = False - mnuViewLogScript.Checked = False - mnuViewSwapDataAndMetadata.Checked = False - mnuColumnMetadat.Checked = False - mnuDataFrameMetadat.Checked = False - - mnuTbDataView.Checked = True - mnuOutputWindow.Checked = True - mnuLogScript.Checked = False - UpdateLayout() + Private Sub UpdateSwapDataAndMetadata() + If mnuViewSwapDataAndMetadata.Checked Then + splDataOutput.Panel1.Controls.Add(ucrColumnMeta) + splMetadata.Panel1.Controls.Add(ucrDataViewer) + mnuViewColumnMetadata.Text = "Data View" + mnuViewDataView.Text = "Column Metadata" + Else + splDataOutput.Panel1.Controls.Add(ucrDataViewer) + splMetadata.Panel1.Controls.Add(ucrColumnMeta) + mnuViewColumnMetadata.Text = "Column Metadata" + mnuViewDataView.Text = "Data View" + End If End Sub + Public Sub SaveInstatOptions(strFilePath As String) Dim serializer As New BinaryFormatter() @@ -550,85 +652,6 @@ Public Class frmMain dlgName.ShowDialog() End Sub - Public Sub UpdateLayout() - 'splOverall has 2 panels - 'splDataOutput.Panel1 contains splExtraWindows - 'splDataOutput.Panel2 contains splDataOutput - - 'splExtraWindows has 2 panels - 'splExtraWindows.Panel1 contains splMetadata which contains data frame and column metadata windows - 'splExtraWindows.Panel2 contains script window - - 'splDataOutput has 2 panels - 'splDataOutput.Panel1 contains data viewer window - 'splDataOutput.Panel2 contains output window - - If Not mnuViewDataView.Checked _ - AndAlso Not mnuViewOutput.Checked _ - AndAlso Not mnuViewColumnMetadata.Checked _ - AndAlso Not mnuViewDataFrameMetadata.Checked _ - AndAlso Not mnuViewLogScript.Checked _ - AndAlso Not mnuViewSwapDataAndMetadata.Checked Then - splOverall.Hide() - Else - splOverall.Show() - - 'determine splOverall contents visibility - - '------------------------------- - 'determine splOverall.Panel1 and it's contents visibility - - If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked OrElse mnuViewLogScript.Checked Then - 'change splOverall.Panel1Collapsed contents visibilty - If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked Then - splMetadata.Panel1Collapsed = Not mnuViewColumnMetadata.Checked - splMetadata.Panel2Collapsed = Not mnuViewDataFrameMetadata.Checked - splExtraWindows.Panel1Collapsed = False - Else - splExtraWindows.Panel1Collapsed = True - End If - 'expand panel 1 - splOverall.Panel1Collapsed = False - 'expand panel 2 based on log script menu item checked status - splExtraWindows.Panel2Collapsed = Not mnuViewLogScript.Checked - Else - splOverall.Panel1Collapsed = True - End If - '------------------------------- - - '------------------------------- - 'determine splOverall.Panel2 and it's contents visibility - - If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then - splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked - splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked - splOverall.Panel2Collapsed = False - Else - splOverall.Panel2Collapsed = True - End If - '------------------------------- - - - End If - mnuTbDataView.Checked = mnuViewDataView.Checked - mnuOutputWindow.Checked = mnuViewOutput.Checked - mnuLogScript.Checked = mnuViewLogScript.Checked - End Sub - - Private Sub UpdateSwapDataAndMetadata() - If mnuViewSwapDataAndMetadata.Checked Then - splDataOutput.Panel1.Controls.Add(ucrColumnMeta) - splMetadata.Panel1.Controls.Add(ucrDataViewer) - mnuViewColumnMetadata.Text = "Data View" - mnuViewDataView.Text = "Column Metadata" - Else - splDataOutput.Panel1.Controls.Add(ucrDataViewer) - splMetadata.Panel1.Controls.Add(ucrColumnMeta) - mnuViewColumnMetadata.Text = "Column Metadata" - mnuViewDataView.Text = "Data View" - End If - End Sub - Private Sub mnuWindowDataFrame_Click(sender As Object, e As EventArgs) Handles mnuViewDataFrameMetadata.Click mnuViewDataFrameMetadata.Checked = Not mnuViewDataFrameMetadata.Checked mnuDataFrameMetadat.Checked = mnuViewDataFrameMetadata.Checked diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index bb12e532470..2e7f9e1697d 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -33,17 +33,19 @@ Public Class ucrColumnMetadata Private strLabelsScientific As String = "Scientific" Private _Refreshed As Boolean = False - Public WriteOnly Property DataBook() As clsDataBook - Set(ByVal value As clsDataBook) - _clsDataBook = value - _grid.DataBook = value - End Set - End Property + Public Sub New() + + ' This call is required by the designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + SetupInitialLayoutAndGrid() + End Sub - Private Sub frmVariables_Load(sender As Object, e As EventArgs) Handles Me.Load - loadForm() + Private Sub ucrColumnMetadata_Load(sender As Object, e As EventArgs) Handles Me.Load mnuInsertColsAfter.Visible = False mnuInsertColsBefore.Visible = False + autoTranslate(Me) End Sub Private Sub ucrColumnMetadata_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged @@ -53,6 +55,37 @@ Public Class ucrColumnMetadata RefreshGridData() End Sub + Private Sub SetupInitialLayoutAndGrid() + lstNonEditableColumns.AddRange({"class", "labels", "Is_Hidden", "Is_Key", "Is_Calculated", "Has_Dependants", "Dependent_Columns", "Calculated_By", "Dependencies", "Colour"}) + + 'DEBUG + ' If True Then + If RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Then + _grid = ucrLinuxGrid + tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Percent + tlpTableContainer.ColumnStyles(0).Width = 100 + tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Absolute + tlpTableContainer.ColumnStyles(1).Width = 0 + Else + _grid = ucrReoGrid + tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Absolute + tlpTableContainer.ColumnStyles(0).Width = 0 + tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Percent + tlpTableContainer.ColumnStyles(1).Width = 100 + End If + _grid.SetNonEditableColumns(lstNonEditableColumns) + _grid.SetContextmenuStrips(Nothing, cellContextMenuStrip, columnContextMenuStrip, statusColumnMenu) + AddHandler _grid.EditValue, AddressOf EditValue + AddHandler _grid.DeleteLabels, AddressOf DeleteLables + End Sub + + Public WriteOnly Property DataBook() As clsDataBook + Set(ByVal value As clsDataBook) + _clsDataBook = value + _grid.DataBook = value + End Set + End Property + Private Function GetCurrentDataFrameFocus() As clsDataFrame Return _clsDataBook.GetDataFrame(_grid.CurrentWorksheet.Name) End Function @@ -113,31 +146,6 @@ Public Class ucrColumnMetadata End If End Sub - Private Sub loadForm() - lstNonEditableColumns.AddRange({"class", "labels", "Is_Hidden", "Is_Key", "Is_Calculated", "Has_Dependants", "Dependent_Columns", "Calculated_By", "Dependencies", "Colour"}) - - 'DEBUG - ' If True Then - If RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Then - _grid = ucrLinuxGrid - tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Percent - tlpTableContainer.ColumnStyles(0).Width = 100 - tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Absolute - tlpTableContainer.ColumnStyles(1).Width = 0 - Else - _grid = ucrReoGrid - tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Absolute - tlpTableContainer.ColumnStyles(0).Width = 0 - tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Percent - tlpTableContainer.ColumnStyles(1).Width = 100 - End If - _grid.SetNonEditableColumns(lstNonEditableColumns) - _grid.SetContextmenuStrips(Nothing, cellContextMenuStrip, columnContextMenuStrip, statusColumnMenu) - AddHandler _grid.EditValue, AddressOf EditValue - AddHandler _grid.DeleteLabels, AddressOf DeleteLables - autoTranslate(Me) - End Sub - Public Sub SetCurrentDataFrame(strDataName As String) _grid.SetCurrentDataFrame(strDataName) End Sub diff --git a/instat/ucrDataFrameMetadata.vb b/instat/ucrDataFrameMetadata.vb index c8be6e85a97..821ff413084 100644 --- a/instat/ucrDataFrameMetadata.vb +++ b/instat/ucrDataFrameMetadata.vb @@ -30,6 +30,20 @@ Public Class ucrDataFrameMetadata Private clsViewDataFrame As New RFunction Private clsGetDataFrame As New RFunction + Public Sub New() + ' This call is required by the designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + SetupInitialLayoutAndGrid() + End Sub + Private Sub ucrDataFrameMetadata_Load(sender As Object, e As EventArgs) Handles Me.Load + clsViewDataFrame.SetRCommand("View") + clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame") + clsHideDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_dataframe_metadata") + End Sub + + Public WriteOnly Property DataBook() As clsDataBook Set(ByVal value As clsDataBook) _clsDataBook = value @@ -37,14 +51,7 @@ Public Class ucrDataFrameMetadata End Set End Property - Private Sub frmMetaData_Load(sender As Object, e As EventArgs) Handles Me.Load - LoadForm() - clsViewDataFrame.SetRCommand("View") - clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame") - clsHideDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_dataframe_metadata") - End Sub - - Private Sub LoadForm() + Private Sub SetupInitialLayoutAndGrid() lstNonEditableColumns.AddRange({"class", "Is_Hidden", "Row_Count", "Column_Count", "Is_Linkable", "Is_Calculated"}) 'Debug diff --git a/instat/ucrScript.vb b/instat/ucrScript.vb index 2f2740ba87b..18ed4a10d54 100644 --- a/instat/ucrScript.vb +++ b/instat/ucrScript.vb @@ -29,6 +29,56 @@ Public Class ucrScript Friend WithEvents clsScriptActive As Scintilla Friend WithEvents clsScriptLog As Scintilla + Public Sub New() + ' This call is required by the designer. + InitializeComponent() + + + ' Add any initialization after the InitializeComponent() call. + SetupInitialLayout() + + End Sub + + Private Sub ucrScript_Load(sender As Object, e As EventArgs) Handles Me.Load + + toolTipScriptWindow.SetToolTip(cmdRunLineSelection, "Run the current line or selection. (Ctrl+Enter)") + toolTipScriptWindow.SetToolTip(cmdRunAll, "Run all the text in the tab. (Ctrl+Alt+R)") + toolTipScriptWindow.SetToolTip(cmdLoadScript, "Load a script from file into the current tab.") + toolTipScriptWindow.SetToolTip(cmdSave, "Save the script in the current tab to a file.") + toolTipScriptWindow.SetToolTip(cmdAddTab, "Add a new tab.") + toolTipScriptWindow.SetToolTip(cmdRemoveTab, "Delete the current tab.") + toolTipScriptWindow.SetToolTip(cmdClear, "Clear the contents of the current tab. (Ctrl+L)") + toolTipScriptWindow.SetToolTip(cmdHelp, "Display the Script Window help information.") + + mnuUndo.ToolTipText = "Undo the last change. (Ctrl+Z)" + mnuRedo.ToolTipText = "Redo the last change. (Ctrl+Y)" + mnuCut.ToolTipText = "Copy the selected text to the clipboard, then delete the text. (Ctrl+X)" + mnuCopy.ToolTipText = "Copy the selected text to the clipboard. (Ctrl+C)" + mnuPaste.ToolTipText = "Paste the contents of the clipboard into the current tab. (Ctrl+V)" + mnuSelectAll.ToolTipText = "Select all the contents of the current tab. (Ctrl+A)" + mnuClear.ToolTipText = "Clear the contents of the current tab. (Ctrl+L)" + mnuRunCurrentLineSelection.ToolTipText = "Run the current line or selection. (Ctrl+Enter)" + mnuRunAllText.ToolTipText = "Run all the text in the tab. (Ctrl+Alt+R)" + mnuOpenScriptasFile.ToolTipText = "Save file to log folder and open file in external editor." + mnuLoadScriptFromFile.ToolTipText = "Load script from file into the current tab." + mnuSaveScript.ToolTipText = "Save the script in the current tab to a file." + mnuHelp.ToolTipText = "Display the Script Window help information." + + 'normally we would do this in the designer, but designer doesn't allow enter key as shortcut + mnuRunCurrentLineSelection.ShortcutKeys = Keys.Enter Or Keys.Control + + 'Make the log tab the selected tab + TabControl.SelectTab(iTabIndexLog) + End Sub + + Private Sub SetupInitialLayout() + 'Create log tab + AddTab(bIsLogTab:=True) + + 'Create script tab + AddTab() + End Sub + ''' ''' The current text in the active tab. ''' @@ -823,42 +873,4 @@ Public Class ucrScript End If End Sub - Private Sub ucrScript_Load(sender As Object, e As EventArgs) Handles MyBase.Load - - toolTipScriptWindow.SetToolTip(cmdRunLineSelection, "Run the current line or selection. (Ctrl+Enter)") - toolTipScriptWindow.SetToolTip(cmdRunAll, "Run all the text in the tab. (Ctrl+Alt+R)") - toolTipScriptWindow.SetToolTip(cmdLoadScript, "Load a script from file into the current tab.") - toolTipScriptWindow.SetToolTip(cmdSave, "Save the script in the current tab to a file.") - toolTipScriptWindow.SetToolTip(cmdAddTab, "Add a new tab.") - toolTipScriptWindow.SetToolTip(cmdRemoveTab, "Delete the current tab.") - toolTipScriptWindow.SetToolTip(cmdClear, "Clear the contents of the current tab. (Ctrl+L)") - toolTipScriptWindow.SetToolTip(cmdHelp, "Display the Script Window help information.") - - mnuUndo.ToolTipText = "Undo the last change. (Ctrl+Z)" - mnuRedo.ToolTipText = "Redo the last change. (Ctrl+Y)" - mnuCut.ToolTipText = "Copy the selected text to the clipboard, then delete the text. (Ctrl+X)" - mnuCopy.ToolTipText = "Copy the selected text to the clipboard. (Ctrl+C)" - mnuPaste.ToolTipText = "Paste the contents of the clipboard into the current tab. (Ctrl+V)" - mnuSelectAll.ToolTipText = "Select all the contents of the current tab. (Ctrl+A)" - mnuClear.ToolTipText = "Clear the contents of the current tab. (Ctrl+L)" - mnuRunCurrentLineSelection.ToolTipText = "Run the current line or selection. (Ctrl+Enter)" - mnuRunAllText.ToolTipText = "Run all the text in the tab. (Ctrl+Alt+R)" - mnuOpenScriptasFile.ToolTipText = "Save file to log folder and open file in external editor." - mnuLoadScriptFromFile.ToolTipText = "Load script from file into the current tab." - mnuSaveScript.ToolTipText = "Save the script in the current tab to a file." - mnuHelp.ToolTipText = "Display the Script Window help information." - - 'normally we would do this in the designer, but designer doesn't allow enter key as shortcut - mnuRunCurrentLineSelection.ShortcutKeys = Keys.Enter Or Keys.Control - - 'Create log tab - AddTab(bIsLogTab:=True) - - 'Create script tab - AddTab() - - 'Make the log tab the selected tab - TabControl.SelectTab(iTabIndexLog) - End Sub - End Class From d9292a61e042cb53b54399259ca096b45f259fa3 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Wed, 23 Aug 2023 12:29:10 +0300 Subject: [PATCH 18/57] Minor code changes --- instat/dlgBarAndPieChart.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 4b3fadd5fab..e1b0b941a51 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -933,7 +933,7 @@ Public Class dlgBarAndPieChart If rdoPie.Checked OrElse rdoDonut.Checked Then If ucrReceiverByFactor.IsEmpty Then clsPieAesFunction.AddParameter("x", "1", iPosition:=0) - clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + clsPieAesFunction.AddParameter("fill", "as.factor(" & ucrVariablesAsFactorForBarChart.GetVariableNames(False) & ")", iPosition:=2) Else clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) From 462efe345552304e85088d24015cc3590fd50ce1 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 23 Aug 2023 18:51:37 +0300 Subject: [PATCH 19/57] changes that prevent recusrions --- instat/ucrReceiverMultiple.vb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/instat/ucrReceiverMultiple.vb b/instat/ucrReceiverMultiple.vb index 8c8dad22495..9be32e92d2e 100644 --- a/instat/ucrReceiverMultiple.vb +++ b/instat/ucrReceiverMultiple.vb @@ -117,6 +117,11 @@ Public Class ucrReceiverMultiple End Sub Public Overrides Sub Clear() + + If lstSelectedVariables.Items.Count = 0 AndAlso lstSelectedVariables.Groups.Count = 0 Then + Exit Sub + End If + lstSelectedVariables.Items.Clear() lstSelectedVariables.Groups.Clear() OnSelectionChanged() @@ -136,6 +141,12 @@ Public Class ucrReceiverMultiple End If Next + 'if there are no items to remove then just exit the sub. No need to raise any events + 'this checks helps prevent raising of events recursively + If lstItemsToRemove.Count = 0 Then + Exit Sub + End If + For Each lvi As ListViewItem In lstItemsToRemove lstSelectedVariables.Items.Remove(lvi) Next @@ -145,6 +156,11 @@ Public Class ucrReceiverMultiple End Sub Private Sub SetGroupHeaderVariablesCount() + + If lstSelectedVariables.Groups.Count = 0 Then + Exit Sub + End If + 'show count selection at the header of the receiver 'todo. support this feature for receivers that have 1 data frame only. 'it's not clear when the receiver will ever have more than one data frame From 39dd0619c754b7ad41549b104c3466a2bdbe1067 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 23 Aug 2023 20:23:09 +0300 Subject: [PATCH 20/57] fixed bug in the data frame and repetitive message box prompts --- instat/dlgDeleteDataFrames.vb | 12 +++-------- instat/ucrColumnMetadata.vb | 38 +++++++++++++++++++++++++---------- instat/ucrReceiver.vb | 2 +- instat/ucrReceiverMultiple.vb | 12 ++++++----- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/instat/dlgDeleteDataFrames.vb b/instat/dlgDeleteDataFrames.vb index c9a6bc31797..05a65d1cb86 100644 --- a/instat/dlgDeleteDataFrames.vb +++ b/instat/dlgDeleteDataFrames.vb @@ -31,13 +31,12 @@ Public Class dlgDeleteDataFrames SetDefaults() End If ReopenDialog() + SetRCodeForControls(bReset) If bUseSelectedDataFrame Then SetDefaultDataFrame() End If - SetRCodeForControls(bReset) bReset = False TestOKEnabled() - CountLevels() autoTranslate(Me) End Sub @@ -64,7 +63,8 @@ Public Class dlgDeleteDataFrames End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + 'SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrReceiverDataFrames.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub Private Sub TestOKEnabled() @@ -110,11 +110,5 @@ Public Class dlgDeleteDataFrames Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverDataFrames.ControlContentsChanged TestOKEnabled() - CountLevels() - End Sub - - Private Sub CountLevels() - lblDeleteNumber.Text = " " & ucrReceiverDataFrames.Count - lblDeleteNumber.Visible = ucrReceiverDataFrames.Count > 0 End Sub End Class \ No newline at end of file diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index bb12e532470..d1d9a3e8647 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -32,6 +32,7 @@ Public Class ucrColumnMetadata Private strLabelsLabel As String = "labels" Private strLabelsScientific As String = "Scientific" Private _Refreshed As Boolean = False + Private bWideDataSetPromptResponse As DialogResult = DialogResult.None Public WriteOnly Property DataBook() As clsDataBook Set(ByVal value As clsDataBook) @@ -62,17 +63,32 @@ Public Class ucrColumnMetadata Exit Sub End If + Dim bFillData As Boolean = True + + 'check for wide data sets and prompt users about it 'todo. this check is necessary for wide data sets 'once the "paging" feature is implemented, then the check can be removed. - If dataFrame.clsColumnMetaData.iRowCount > 1000 AndAlso - DialogResult.No = MessageBox.Show(Me, "Are you sure you need " & dataFrame.strName & " column metadata? If so, be patient. It, will be slow to load the first time", dataFrame.strName & " Column Metadata", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) Then - Exit Sub + 'see issue #7161 and PR #8465 for more discussions + If dataFrame.clsColumnMetaData.iRowCount > 1000 e Then + 'if not asked or no response before then prompt for a response + If bWideDataSetPromptResponse = DialogResult.None OrElse bWideDataSetPromptResponse = DialogResult.Cancel Then + bWideDataSetPromptResponse = MessageBox.Show(Me, "Are you sure you need wide data set(s) column metadata? If so, be patient. It, will be slow to load the first time", "Wide Data Set(s) Detected", + MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) + End If + + 'if response is no or no response given then don't fill the worksheet with data + If bWideDataSetPromptResponse = DialogResult.No OrElse bWideDataSetPromptResponse = DialogResult.Cancel Then + bFillData = False + End If + End If + + If bFillData Then + _grid.CurrentWorksheet = fillWorksheet + _grid.UpdateWorksheetStyle(fillWorksheet) + _grid.AddColumns(dataFrame.clsColumnMetaData) + _grid.AddRowData(dataFrame.clsColumnMetaData) End If - _grid.CurrentWorksheet = fillWorksheet - _grid.UpdateWorksheetStyle(fillWorksheet) - _grid.AddColumns(dataFrame.clsColumnMetaData) - _grid.AddRowData(dataFrame.clsColumnMetaData) dataFrame.clsColumnMetaData.HasChanged = False End Sub @@ -150,19 +166,19 @@ Public Class ucrColumnMetadata Dim clsDeleteLabelsFunction As New RFunction If strColumnName = strLabelsLabel Then - If MsgBox("This will delete the selected label(s) and replace with (NA)." & + If MsgBox("This will delete the selected label(s) And Replace Then With (NA)." & Environment.NewLine & "Continue?", MessageBoxButtons.YesNo, "Delete Labels") = DialogResult.Yes Then clsDeleteLabelsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_variables_metadata") clsDeleteLabelsFunction.AddParameter("data_name", Chr(34) & _grid.CurrentWorksheet.Name & Chr(34), iPosition:=0) clsDeleteLabelsFunction.AddParameter("col_names", frmMain.clsRLink.GetListAsRString(_grid.GetSelectedColumns), iPosition:=1) - clsDeleteLabelsFunction.AddParameter("property", Chr(34) & "labels" & Chr(34), iPosition:=2) + clsDeleteLabelsFunction.AddParameter("Property", Chr(34) & "labels" & Chr(34), iPosition:=2) clsDeleteLabelsFunction.AddParameter("new_val", Chr(34) & Chr(34), iPosition:=3) frmMain.clsRLink.RunScript(clsDeleteLabelsFunction.ToScript()) End If Else - MsgBox("Deleting cells is currently disabled. This feature will be included in future versions." & Environment.NewLine & + MsgBox("Deleting cells Is currently disabled. This feature will be included In future versions." & Environment.NewLine & "To remove a cell's value, replace the value with NA.", MsgBoxStyle.Information, "Cannot delete cells.") End If End Sub @@ -389,7 +405,7 @@ Public Class ucrColumnMetadata End Sub Private Sub columnContextMenuStrip_Opening(sender As Object, e As CancelEventArgs) Handles columnContextMenuStrip.Opening - If IsOnlyOneDataFrameColumnSeleted() Then + If IsOnlyOneDataframeColumnSeleted() Then mnuLevelsLabels.Enabled = IsFirstSelectedDataFrameColumnAFactor() mnuDeleteCol.Text = GetTranslation("Delete Column") mnuInsertColsBefore.Text = GetTranslation("Insert 1 Column Before") diff --git a/instat/ucrReceiver.vb b/instat/ucrReceiver.vb index d34273d7ca4..f6ef51f798b 100644 --- a/instat/ucrReceiver.vb +++ b/instat/ucrReceiver.vb @@ -454,7 +454,7 @@ Public Class ucrReceiver If clsTempParameter IsNot Nothing Then If bChangeParameterValue Then If bParameterIsString AndAlso clsTempParameter.bIsString Then - If strValuesToIgnore Is Nothing OrElse (Not strValuesToIgnore.Contains(clsTempParameter.strArgumentValue)) Then + If (strValuesToIgnore IsNot Nothing AndAlso strValuesToIgnore.Contains(clsTempParameter.strArgumentValue)) OrElse Not String.IsNullOrEmpty(clsTempParameter.strArgumentValue) Then lstCurrentVariables = ExtractItemsFromRList(clsTempParameter.strArgumentValue, strPackageName:=strVariablesListPackageName, strFunctionName:=strVariablesListFunctionName) End If 'TODO how to recover the data frame name in this case diff --git a/instat/ucrReceiverMultiple.vb b/instat/ucrReceiverMultiple.vb index 9be32e92d2e..3aeb7d49494 100644 --- a/instat/ucrReceiverMultiple.vb +++ b/instat/ucrReceiverMultiple.vb @@ -52,6 +52,10 @@ Public Class ucrReceiverMultiple End If Next + If lstActualItemsToAdd.Count = 0 Then + Exit Sub + End If + 'then add the new items For Each kvpTempItem As KeyValuePair(Of String, String) In lstActualItemsToAdd lstSelectedVariables.Items.Add(New ListViewItem With { @@ -117,11 +121,10 @@ Public Class ucrReceiverMultiple End Sub Public Overrides Sub Clear() - + 'as of 23/08/2023. this block can be called several times. to prevent recursive events just exit sub if already empty If lstSelectedVariables.Items.Count = 0 AndAlso lstSelectedVariables.Groups.Count = 0 Then Exit Sub End If - lstSelectedVariables.Items.Clear() lstSelectedVariables.Groups.Clear() OnSelectionChanged() @@ -141,8 +144,7 @@ Public Class ucrReceiverMultiple End If Next - 'if there are no items to remove then just exit the sub. No need to raise any events - 'this checks helps prevent raising of events recursively + 'as of 23/08/2023. this subroutine can be called several times. to prevent recursive events just exit sub if there is nothing to remove If lstItemsToRemove.Count = 0 Then Exit Sub End If @@ -162,7 +164,7 @@ Public Class ucrReceiverMultiple End If 'show count selection at the header of the receiver - 'todo. support this feature for receivers that have 1 data frame only. + 'todo. support this feature for receivers that may have more than 1 data frame later 'it's not clear when the receiver will ever have more than one data frame 'reset the header text with the name From bd7de49fba0abead96962f5b3a7fa64e3acd9840 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 23 Aug 2023 20:28:12 +0300 Subject: [PATCH 21/57] made changes --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index d1d9a3e8647..363e03c26cd 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -69,7 +69,7 @@ Public Class ucrColumnMetadata 'todo. this check is necessary for wide data sets 'once the "paging" feature is implemented, then the check can be removed. 'see issue #7161 and PR #8465 for more discussions - If dataFrame.clsColumnMetaData.iRowCount > 1000 e Then + If dataFrame.clsColumnMetaData.iRowCount > 1000 Then 'if not asked or no response before then prompt for a response If bWideDataSetPromptResponse = DialogResult.None OrElse bWideDataSetPromptResponse = DialogResult.Cancel Then bWideDataSetPromptResponse = MessageBox.Show(Me, "Are you sure you need wide data set(s) column metadata? If so, be patient. It, will be slow to load the first time", "Wide Data Set(s) Detected", From d1bb58726f098e6d4c46f289668083861103e0fd Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 24 Aug 2023 11:57:44 +0300 Subject: [PATCH 22/57] Removed cancel option --- instat/ucrColumnMetadata.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 363e03c26cd..6cb82ed0604 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -71,13 +71,13 @@ Public Class ucrColumnMetadata 'see issue #7161 and PR #8465 for more discussions If dataFrame.clsColumnMetaData.iRowCount > 1000 Then 'if not asked or no response before then prompt for a response - If bWideDataSetPromptResponse = DialogResult.None OrElse bWideDataSetPromptResponse = DialogResult.Cancel Then + If bWideDataSetPromptResponse = DialogResult.None Then bWideDataSetPromptResponse = MessageBox.Show(Me, "Are you sure you need wide data set(s) column metadata? If so, be patient. It, will be slow to load the first time", "Wide Data Set(s) Detected", - MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) + MessageBoxButtons.YesNo, MessageBoxIcon.Warning) End If 'if response is no or no response given then don't fill the worksheet with data - If bWideDataSetPromptResponse = DialogResult.No OrElse bWideDataSetPromptResponse = DialogResult.Cancel Then + If bWideDataSetPromptResponse = DialogResult.No Then bFillData = False End If End If From 9fb0f7b77b6ccda01c81d5912f2a35d8196acdf5 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:52:51 +0300 Subject: [PATCH 23/57] Code changes --- instat/dlgBarAndPieChart.vb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index e1b0b941a51..790bea8b5ef 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -802,25 +802,25 @@ Public Class dlgBarAndPieChart If rdoFrequency.Checked Then clsForecatsInfreq.AddParameter("f", "as.factor(" & ucrVariablesAsFactorForBarChart.GetVariableNames(False) & ")", iPosition:=0) clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrReceiverByFactor.GetVariableNames(False) & ")", iPosition:=0) - If ucrChkReorderFrequency.Checked AndAlso strChangedTextFreq <> strNone Then + If ucrChkReorderFrequency.Checked Then Select Case strChangedTextFreq Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) Case strDescending clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=2) Case strReverse clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) Case strNone clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) End Select End If - If Not ucrReceiverByFactor.IsEmpty AndAlso strChangedTextValue <> strNone Then + If Not ucrReceiverByFactor.IsEmpty Then Select Case strChangedTextValue Case strAscending clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) From 2a2606f6afb222e5a4113ee140f59cfcea8ce1d8 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 30 Aug 2023 20:54:13 +0300 Subject: [PATCH 24/57] commented out the list append --- instat/static/InstatObject/R/data_object_R6.R | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 53239127c6b..1d2fdc62855 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1125,14 +1125,17 @@ DataSheet$set("public", "append_to_variables_metadata", function(col_names, prop DataSheet$set("public", "append_to_changes", function(value) { - if(missing(value)) { - stop("value arguements must be specified.") - }else { + #functionality disabled temporarily + #see PR #8465 and issue #7161 comments + + #if(missing(value)) { + # stop("value arguements must be specified.") + #}else { #see comments in issue #7161 that explain more about why list() was used #primary reason was because of performance when it comes to wide data sets #private$changes[[length(private$changes)+1]] <- value - private$changes<-list(private$changes, value) - } + #private$changes<-list(private$changes, value) + #} } ) From 3527e733aec9b4aa9ce936c45cb3768e59ef05d5 Mon Sep 17 00:00:00 2001 From: n-thony Date: Thu, 31 Aug 2023 10:05:02 +0300 Subject: [PATCH 25/57] fixing some bugs --- instat/dlgBarAndPieChart.vb | 83 +++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 790bea8b5ef..6cbe0fc2fbc 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -807,18 +807,40 @@ Public Class dlgBarAndPieChart Case strAscending clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strDescending clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=2) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) Case strReverse clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strNone clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End Select + Else + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + End If + If ucrChkPolarCoordinates.Checked Then + If rdoPie.Checked OrElse rdoDonut.Checked Then + If ucrReceiverByFactor.IsEmpty Then + clsPieAesFunction.AddParameter("x", "1", iPosition:=0) + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) + Case strDescending + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=2) + Case strReverse + clsForecatsReverse.AddParameter("f", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) + Case strNone + clsPieAesFunction.AddParameter("fill", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=2) + End Select + End If + End If End If If Not ucrReceiverByFactor.IsEmpty Then Select Case strChangedTextValue @@ -839,7 +861,8 @@ Public Class dlgBarAndPieChart End Select End If ElseIf rdoValue.Checked Then - If ucrChkReorderValue.Checked AndAlso strChangeTextReorder <> strNone Then + If ucrChkReorderValue.Checked Then + clsReorderFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) Select Case strChangeTextReorder Case strAscending clsReorderFunction.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) @@ -852,26 +875,50 @@ Public Class dlgBarAndPieChart Case strReverse clsForecatsReverse.AddParameter("f", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsReorderFunction, iPosition:=0) + clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strNone clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=1) - clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=2) + clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) End Select + Else + clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) End If - If Not ucrReceiverByFactor.IsEmpty AndAlso strChangedTextValue <> strNone Then + If ucrChkPolarCoordinates.Checked Then + If rdoPie.Checked OrElse rdoDonut.Checked Then + If ucrReceiverByFactor.IsEmpty Then + clsPieAesFunction.AddParameter("x", "1", iPosition:=0) + Select Case strChangedTextValue + Case strAscending + clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case strDescending + clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + Case strReverse + clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + Case strNone + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + End Select + End If + End If + End If + If Not ucrReceiverByFactor.IsEmpty Then + clsReorderFunctionValue.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) Select Case strChangedTextValue Case strAscending clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strDescending clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strReverse clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) - clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverse, iPosition:=2) - clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunction, iPosition:=2) + clsBarAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) + clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) Case strNone clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) @@ -930,15 +977,6 @@ Public Class dlgBarAndPieChart ElseIf rdoFrequency.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) If ucrChkPolarCoordinates.Checked Then - If rdoPie.Checked OrElse rdoDonut.Checked Then - If ucrReceiverByFactor.IsEmpty Then - clsPieAesFunction.AddParameter("x", "1", iPosition:=0) - clsPieAesFunction.AddParameter("fill", "as.factor(" & ucrVariablesAsFactorForBarChart.GetVariableNames(False) & ")", iPosition:=2) - Else - clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) - End If - End If clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) If ucrChkAddLabelsText.Checked Then @@ -966,6 +1004,7 @@ Public Class dlgBarAndPieChart clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) End If End If + clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_treemap") clsBaseOperator.RemoveParameterByName("geom_text_wordcloud") From 6e8897d8e9832d68f0854a4b6dbd7e42b71c1e4b Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:44:38 +0300 Subject: [PATCH 26/57] Fixed the issue with the reorder but still some issues in the sub-dialogue --- instat/dlgHistogram.designer.vb | 101 +++++++++++++++----- instat/dlgHistogram.resx | 3 + instat/dlgHistogram.vb | 157 ++++++++++++++++++++++++++++---- 3 files changed, 219 insertions(+), 42 deletions(-) diff --git a/instat/dlgHistogram.designer.vb b/instat/dlgHistogram.designer.vb index 2b13fdbd1c5..7ac87b6a68b 100644 --- a/instat/dlgHistogram.designer.vb +++ b/instat/dlgHistogram.designer.vb @@ -51,17 +51,21 @@ Partial Class dlgHistogram Me.toolStripMenuItemDensityOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemDensityRidgesOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemFrequencyPolygonOptions = New System.Windows.Forms.ToolStripMenuItem() + Me.lblReorder = New System.Windows.Forms.Label() + Me.ucrInputAddReorder = New instat.ucrInputComboBox() + Me.ucrVariablesAsFactorforHist = New instat.ucrVariablesAsFactor() Me.cmdOptions = New instat.ucrSplitButton() Me.ucrChkDisplayAsDotPlot = New instat.ucrCheck() Me.ucrChkRidges = New instat.ucrCheck() Me.ucrInputStats = New instat.ucrInputComboBox() Me.ucrChkPercentages = New instat.ucrCheck() Me.ucrSaveHist = New instat.ucrSave() - Me.ucrVariablesAsFactorforHist = New instat.ucrVariablesAsFactor() Me.ucrFactorReceiver = New instat.ucrReceiverSingle() Me.ucrHistogramSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrPnlOptions = New instat.UcrPanel() + Me.lblReorderValue = New System.Windows.Forms.Label() + Me.ucrInputReorderValue = New instat.ucrInputComboBox() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -129,14 +133,15 @@ Partial Class dlgHistogram ' 'lblStats ' - Me.lblStats.Location = New System.Drawing.Point(9, 276) + Me.lblStats.Location = New System.Drawing.Point(9, 278) Me.lblStats.Name = "lblStats" - Me.lblStats.Size = New System.Drawing.Size(56, 19) + Me.lblStats.Size = New System.Drawing.Size(43, 19) Me.lblStats.TabIndex = 11 Me.lblStats.Text = "merge" ' 'contextMenuStripOptions ' + Me.contextMenuStripOptions.ImageScalingSize = New System.Drawing.Size(20, 20) Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemHistogramOptions, Me.toolStripMenuItemDotOptions, Me.toolStripMenuItemDensityOptions, Me.toolStripMenuItemDensityRidgesOptions, Me.toolStripMenuItemFrequencyPolygonOptions}) Me.contextMenuStripOptions.Name = "contextMenuStripOk" Me.contextMenuStripOptions.Size = New System.Drawing.Size(222, 136) @@ -177,6 +182,40 @@ Partial Class dlgHistogram Me.toolStripMenuItemFrequencyPolygonOptions.Size = New System.Drawing.Size(221, 22) Me.toolStripMenuItemFrequencyPolygonOptions.Text = "Frequency Polygon Options" ' + 'lblReorder + ' + Me.lblReorder.AutoSize = True + Me.lblReorder.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblReorder.Location = New System.Drawing.Point(283, 318) + Me.lblReorder.Name = "lblReorder" + Me.lblReorder.Size = New System.Drawing.Size(48, 13) + Me.lblReorder.TabIndex = 44 + 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(283, 335) + Me.ucrInputAddReorder.Name = "ucrInputAddReorder" + Me.ucrInputAddReorder.Size = New System.Drawing.Size(120, 21) + Me.ucrInputAddReorder.TabIndex = 45 + ' + 'ucrVariablesAsFactorforHist + ' + Me.ucrVariablesAsFactorforHist.AutoSize = True + Me.ucrVariablesAsFactorforHist.frmParent = Me + Me.ucrVariablesAsFactorforHist.Location = New System.Drawing.Point(283, 64) + Me.ucrVariablesAsFactorforHist.Name = "ucrVariablesAsFactorforHist" + Me.ucrVariablesAsFactorforHist.Selector = Nothing + Me.ucrVariablesAsFactorforHist.Size = New System.Drawing.Size(125, 75) + Me.ucrVariablesAsFactorforHist.strNcFilePath = "" + Me.ucrVariablesAsFactorforHist.TabIndex = 43 + Me.ucrVariablesAsFactorforHist.ucrSelector = Nothing + Me.ucrVariablesAsFactorforHist.ucrVariableSelector = Nothing + ' 'cmdOptions ' Me.cmdOptions.AutoSize = True @@ -195,6 +234,7 @@ Partial Class dlgHistogram Me.ucrChkDisplayAsDotPlot.AutoSize = True Me.ucrChkDisplayAsDotPlot.Checked = False Me.ucrChkDisplayAsDotPlot.Location = New System.Drawing.Point(283, 256) + Me.ucrChkDisplayAsDotPlot.Margin = New System.Windows.Forms.Padding(5) Me.ucrChkDisplayAsDotPlot.Name = "ucrChkDisplayAsDotPlot" Me.ucrChkDisplayAsDotPlot.Size = New System.Drawing.Size(153, 23) Me.ucrChkDisplayAsDotPlot.TabIndex = 8 @@ -215,7 +255,7 @@ Partial Class dlgHistogram Me.ucrInputStats.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputStats.GetSetSelectedIndex = -1 Me.ucrInputStats.IsReadOnly = False - Me.ucrInputStats.Location = New System.Drawing.Point(73, 272) + Me.ucrInputStats.Location = New System.Drawing.Point(53, 276) Me.ucrInputStats.Margin = New System.Windows.Forms.Padding(5) Me.ucrInputStats.Name = "ucrInputStats" Me.ucrInputStats.Size = New System.Drawing.Size(137, 21) @@ -234,26 +274,12 @@ 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, 385) Me.ucrSaveHist.Margin = New System.Windows.Forms.Padding(5) Me.ucrSaveHist.Name = "ucrSaveHist" Me.ucrSaveHist.Size = New System.Drawing.Size(322, 24) Me.ucrSaveHist.TabIndex = 13 ' - 'ucrVariablesAsFactorforHist - ' - Me.ucrVariablesAsFactorforHist.AutoSize = True - Me.ucrVariablesAsFactorforHist.frmParent = Me - Me.ucrVariablesAsFactorforHist.Location = New System.Drawing.Point(281, 68) - Me.ucrVariablesAsFactorforHist.Margin = New System.Windows.Forms.Padding(5) - Me.ucrVariablesAsFactorforHist.Name = "ucrVariablesAsFactorforHist" - Me.ucrVariablesAsFactorforHist.Selector = Nothing - Me.ucrVariablesAsFactorforHist.Size = New System.Drawing.Size(125, 136) - Me.ucrVariablesAsFactorforHist.strNcFilePath = "" - Me.ucrVariablesAsFactorforHist.TabIndex = 5 - Me.ucrVariablesAsFactorforHist.ucrSelector = Nothing - Me.ucrVariablesAsFactorforHist.ucrVariableSelector = Nothing - ' 'ucrFactorReceiver ' Me.ucrFactorReceiver.AutoSize = True @@ -283,7 +309,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(9, 419) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) @@ -298,12 +324,38 @@ Partial Class dlgHistogram Me.ucrPnlOptions.Size = New System.Drawing.Size(433, 30) Me.ucrPnlOptions.TabIndex = 0 ' + 'lblReorderValue + ' + Me.lblReorderValue.AutoSize = True + Me.lblReorderValue.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblReorderValue.Location = New System.Drawing.Point(280, 142) + Me.lblReorderValue.Name = "lblReorderValue" + Me.lblReorderValue.Size = New System.Drawing.Size(48, 13) + Me.lblReorderValue.TabIndex = 46 + Me.lblReorderValue.Text = "Reorder:" + ' + 'ucrInputReorderValue + ' + Me.ucrInputReorderValue.AddQuotesIfUnrecognised = True + Me.ucrInputReorderValue.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputReorderValue.GetSetSelectedIndex = -1 + Me.ucrInputReorderValue.IsReadOnly = False + Me.ucrInputReorderValue.Location = New System.Drawing.Point(283, 158) + Me.ucrInputReorderValue.Name = "ucrInputReorderValue" + Me.ucrInputReorderValue.Size = New System.Drawing.Size(93, 21) + Me.ucrInputReorderValue.TabIndex = 47 + ' '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, 476) + Me.Controls.Add(Me.ucrInputReorderValue) + Me.Controls.Add(Me.lblReorderValue) + Me.Controls.Add(Me.ucrInputAddReorder) + Me.Controls.Add(Me.lblReorder) + Me.Controls.Add(Me.ucrVariablesAsFactorforHist) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.ucrChkDisplayAsDotPlot) Me.Controls.Add(Me.ucrChkRidges) @@ -311,7 +363,6 @@ Partial Class dlgHistogram Me.Controls.Add(Me.ucrInputStats) Me.Controls.Add(Me.ucrChkPercentages) Me.Controls.Add(Me.ucrSaveHist) - Me.Controls.Add(Me.ucrVariablesAsFactorforHist) Me.Controls.Add(Me.ucrFactorReceiver) Me.Controls.Add(Me.rdoFrequencyPolygon) Me.Controls.Add(Me.rdoDensity_ridges) @@ -339,7 +390,6 @@ Partial Class dlgHistogram Friend WithEvents rdoFrequencyPolygon As RadioButton Friend WithEvents ucrFactorReceiver As ucrReceiverSingle Friend WithEvents lblfactor As Label - Friend WithEvents ucrVariablesAsFactorforHist As ucrVariablesAsFactor Friend WithEvents ucrPnlOptions As UcrPanel Friend WithEvents ucrSaveHist As ucrSave Friend WithEvents ucrInputStats As ucrInputComboBox @@ -355,4 +405,9 @@ Partial Class dlgHistogram Friend WithEvents toolStripMenuItemDensityRidgesOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemFrequencyPolygonOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemDotOptions As ToolStripMenuItem + Friend WithEvents ucrVariablesAsFactorforHist As ucrVariablesAsFactor + Friend WithEvents lblReorder As Label + Friend WithEvents ucrInputAddReorder As ucrInputComboBox + Friend WithEvents lblReorderValue As Label + Friend WithEvents ucrInputReorderValue As ucrInputComboBox End Class \ No newline at end of file diff --git a/instat/dlgHistogram.resx b/instat/dlgHistogram.resx index 4f920f19046..406cc5c74be 100644 --- a/instat/dlgHistogram.resx +++ b/instat/dlgHistogram.resx @@ -120,4 +120,7 @@ 17, 17 + + 31 + \ No newline at end of file diff --git a/instat/dlgHistogram.vb b/instat/dlgHistogram.vb index 4d8fce75cc8..b541ff9562a 100644 --- a/instat/dlgHistogram.vb +++ b/instat/dlgHistogram.vb @@ -43,6 +43,18 @@ Public Class dlgHistogram Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsAnnotateFunction As New RFunction + Private clsReorderFunction As New RFunction + Private clsReorderValueFunction As New RFunction + Private clsGeomTextFunction As New RFunction + Private clsForecatsReverseValue As New RFunction + Private clsForecatsInfreqValue As New RFunction + Private clsForecatsInfreq As New RFunction + Private clsForecatsReverse As New RFunction + + Private clsDummyRev As New RFunction + Private ReadOnly strAscending As String = "Ascending" + Private ReadOnly strDescending As String = "Descending" + Private ReadOnly strNone As String = "None" 'Parameter names for geoms Private strFirstParameterName As String = "geomfunc" @@ -62,7 +74,6 @@ Public Class dlgHistogram bReset = False autoTranslate(Me) TestOkEnabled() - DialogueSize() End Sub Private Sub InitialiseDialog() @@ -99,7 +110,7 @@ Public Class dlgHistogram ucrInputStats.SetLinkedDisplayControl(lblStats) ucrInputStats.AddToLinkedControls(ucrChkPercentages, {"Fractions"}, bNewLinkedHideIfParameterMissing:=True) - ucrChkPercentages.SetText("percentages") + ucrChkPercentages.SetText("Percentages") ucrChkPercentages.AddParameterPresentCondition(True, "scale") ucrChkPercentages.AddParameterPresentCondition(False, "scale", False) @@ -119,6 +130,14 @@ Public Class dlgHistogram ucrVariablesAsFactorforHist.bWithQuotes = False ucrVariablesAsFactorforHist.SetParameterIsString() + ucrInputAddReorder.SetItems({strAscending, strDescending, strNone}) + ucrInputAddReorder.SetDropDownStyleAsNonEditable() + ucrInputAddReorder.SetLinkedDisplayControl(lblReorder) + + ucrInputReorderValue.SetItems({strAscending, strDescending, strNone}) + ucrInputReorderValue.SetDropDownStyleAsNonEditable() + ucrInputReorderValue.SetLinkedDisplayControl(lblReorderValue) + ucrPnlOptions.AddToLinkedControls({ucrChkDisplayAsDotPlot}, {rdoHistogram}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrChkRidges}, {rdoDensity_ridges}, bNewLinkedHideIfParameterMissing:=True) ucrChkRidges.AddToLinkedControls(ucrInputStats, {"FALSE"}, bNewLinkedHideIfParameterMissing:=True) @@ -129,7 +148,6 @@ Public Class dlgHistogram ucrSaveHist.SetCheckBoxText("Save Graph") ucrSaveHist.SetSaveTypeAsGraph() ucrSaveHist.SetAssignToIfUncheckedValue("last_graph") - DialogueSize() End Sub Private Sub SetDefaults() @@ -139,6 +157,15 @@ Public Class dlgHistogram clsRaesFunction = New RFunction clsHistAesFunction = New RFunction clsPercentage = New RFunction + clsGeomTextFunction = New RFunction + clsForecatsReverseValue = New RFunction + clsDummyRev = New RFunction + clsReorderFunction = New RFunction + clsReorderValueFunction = New RFunction + clsForecatsInfreqValue = New RFunction + clsForecatsInfreq = New RFunction + clsForecatsReverse = New RFunction + ucrHistogramSelector.Reset() ucrHistogramSelector.SetGgplotFunction(clsBaseOperator) ucrSaveHist.Reset() @@ -146,6 +173,8 @@ Public Class dlgHistogram bResetSubdialog = True bResetHistLayerSubdialog = True + clsDummyRev.AddParameter("reverse", "FALSE", iPosition:=0) + clsBaseOperator.SetOperation("+") clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRggplotFunction, iPosition:=0) clsBaseOperator.AddParameter(strFirstParameterName, clsRFunctionParameter:=clsRgeomPlotFunction, iPosition:=2) @@ -154,6 +183,11 @@ Public Class dlgHistogram clsRggplotFunction.SetRCommand("ggplot") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction, iPosition:=1) + ucrInputAddReorder.SetText(strNone) + + ucrInputReorderValue.SetText(strNone) + ucrInputReorderValue.bUpdateRCodeFromControl = True + clsRaesFunction.SetPackageName("ggplot2") clsRaesFunction.SetRCommand("aes") @@ -168,6 +202,29 @@ Public Class dlgHistogram clsPercentage.SetPackageName("scales") clsPercentage.SetRCommand("percent_format") + clsGeomTextFunction.SetPackageName("ggplot2") + clsGeomTextFunction.SetRCommand("geom_text") + 'clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) + clsGeomTextFunction.AddParameter("colour", "black", iPosition:=4) + clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) + clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) + + clsForecatsReverseValue.SetPackageName("forcats") + clsForecatsReverseValue.SetRCommand("fct_rev") + + clsReorderFunction.SetRCommand("reorder") + + clsReorderValueFunction.SetRCommand("reorder") + + clsForecatsInfreqValue.SetPackageName("forcats") + clsForecatsInfreqValue.SetRCommand("fct_infreq") + + clsForecatsInfreq.SetPackageName("forcats") + clsForecatsInfreq.SetRCommand("fct_infreq") + + clsForecatsReverse.SetPackageName("forcats") + clsForecatsReverse.SetRCommand("fct_rev") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsYlabFunction = GgplotDefaults.clsYlabTitleFunction.Clone() @@ -200,6 +257,8 @@ Public Class dlgHistogram ucrChkRidges.SetRCode(clsRgeomPlotFunction, bReset) ucrFactorReceiver.SetRCode(clsRaesFunction, bReset) ucrVariablesAsFactorforHist.SetRCode(clsRaesFunction, bReset) + ucrFactorReceiver.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) + ucrVariablesAsFactorforHist.AddAdditionalCodeParameterPair(clsReorderValueFunction, New RParameter("x", 0), iAdditionalPairNo:=1) If bReset Then ucrInputStats.SetRCode(clsHistAesFunction, bReset) End If @@ -207,7 +266,7 @@ Public Class dlgHistogram Private Sub TestOkEnabled() 'Tests when ok can be enabled - If ucrVariablesAsFactorforHist.IsEmpty OrElse Not ucrSaveHist.IsComplete OrElse (ucrChkRidges.Checked AndAlso (ucrFactorReceiver.IsEmpty OrElse ucrFactorReceiver.Enabled = False)) Then + If ucrVariablesAsFactorforHist.IsEmpty OrElse Not ucrSaveHist.IsComplete OrElse ucrFactorReceiver.IsEmpty Then ucrBase.OKEnabled(False) Else ucrBase.OKEnabled(True) @@ -225,6 +284,7 @@ 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") @@ -232,9 +292,27 @@ Public Class dlgHistogram clsRgeomPlotFunction.SetRCommand("geom_histogram") End If ucrFactorReceiver.ChangeParameterName("fill") - If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("histogram") + ' If ucrChkReverse.Checked Then + ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + ' Else + ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) + ' End If + ' If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("histogram") + ' ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() End If If rdoDensity_ridges.Checked Then + ucrFactorReceiver.ChangeParameterName("fill") + 'If ucrChkReverse.Checked Then + ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + 'Else + ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) + 'End If + 'ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() + If Not ucrSaveHist.bUserTyped Then + ucrSaveHist.SetPrefix("density_ridges") + End If If ucrChkRidges.Checked Then ucrFactorReceiver.ChangeParameterName("y") clsHistAesFunction.RemoveParameterByName("y") @@ -242,34 +320,36 @@ Public Class dlgHistogram clsHistAesFunction.AddParameter("y", clsRFunctionParameter:=ucrFactorReceiver.GetVariables(), iPosition:=2) clsRgeomPlotFunction.SetPackageName("ggridges") clsRgeomPlotFunction.SetRCommand("geom_density_ridges") - If Not ucrSaveHist.bUserTyped Then - ucrSaveHist.SetPrefix("density_ridges") - End If Else ucrFactorReceiver.ChangeParameterName("colour") clsRgeomPlotFunction.SetRCommand("geom_density") - If Not ucrSaveHist.bUserTyped Then - ucrSaveHist.SetPrefix("density") - End If End If ElseIf rdoFrequencyPolygon.Checked Then ucrFactorReceiver.ChangeParameterName("colour") clsRgeomPlotFunction.SetRCommand("geom_freqpoly") + If Not ucrSaveHist.bUserTyped Then + ucrSaveHist.SetPrefix("density") + End If + ucrFactorReceiver.ChangeParameterName("fill") + 'If ucrChkReverse.Checked Then + ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) + ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + 'Else + ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) + 'End If + 'ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("frequency_polygon") End If End If autoTranslate(Me) + UpdateParameter() End Sub - Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.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 - toolStripMenuItemDensityRidgesOptions.Enabled = rdoDensity_ridges.Checked AndAlso ucrChkRidges.Checked - toolStripMenuItemFrequencyPolygonOptions.Enabled = rdoFrequencyPolygon.Checked + Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, + ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged, + ucrInputAddReorder.ControlValueChanged, ucrInputReorderValue.ControlValueChanged SetDialogOptions() - DialogueSize() End Sub Private Sub Adding_Percentages(ucrChangedControl As ucrCore) Handles ucrInputStats.ControlValueChanged, ucrChkPercentages.ControlValueChanged @@ -363,9 +443,17 @@ Public Class dlgHistogram SetDialogOptions() End Sub + Private Sub SetGeomTextOptions() + If rdoHistogram.Checked Then + clsGeomTextFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=0) + Else + clsGeomTextFunction.RemoveParameterByName("stat") + End If + End Sub + Private Sub DialogueSize() If rdoHistogram.Checked Then - Me.Size = New Size(464, 409) + Me.Size = New Size(464, 480) Me.ucrSaveHist.Location = New Point(10, 284) Me.ucrBase.Location = New Point(10, 314) ElseIf rdoDensity_ridges.Checked Then @@ -382,4 +470,35 @@ Public Class dlgHistogram Private Sub CoreControls_ControlContentsChanged() Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged TestOkEnabled() End Sub + + Private Sub UpdateParameter() + If rdoHistogram.Checked OrElse rdoDensity_ridges.Checked OrElse rdoFrequencyPolygon.Checked Then + Dim strChangedTextFreq As String = ucrInputReorderValue.GetText() + Dim strChangedTextValue As String = ucrInputAddReorder.GetText() + clsForecatsInfreq.AddParameter("f", "as.factor(" & ucrVariablesAsFactorforHist.GetVariableNames(False) & ")", iPosition:=0) + clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrFactorReceiver.GetVariableNames(False) & ")", iPosition:=0) + Select Case strChangedTextFreq + Case strAscending + clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + clsHistAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) + Case strDescending + clsHistAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) + End Select + Select Case strChangedTextValue + Case strAscending + clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) + clsHistAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) + Case strDescending + clsHistAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=1) + End Select + End If + End Sub + Private Sub ucrPnlOptions_Control(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, + ucrChkRidges.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged, + ucrInputAddReorder.ControlValueChanged, ucrInputReorderValue.ControlValueChanged + UpdateParameter() + End Sub + + Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged + End Sub End Class \ No newline at end of file From 4597b2478471dfc83625bb5577330f6fa701c403 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:52:19 +0300 Subject: [PATCH 27/57] Revert "Fixed the issue with the reorder but still some issues in the sub-dialogue" This reverts commit 6e8897d8e9832d68f0854a4b6dbd7e42b71c1e4b. --- instat/dlgHistogram.designer.vb | 101 +++++--------------- instat/dlgHistogram.resx | 3 - instat/dlgHistogram.vb | 157 ++++---------------------------- 3 files changed, 42 insertions(+), 219 deletions(-) diff --git a/instat/dlgHistogram.designer.vb b/instat/dlgHistogram.designer.vb index 7ac87b6a68b..2b13fdbd1c5 100644 --- a/instat/dlgHistogram.designer.vb +++ b/instat/dlgHistogram.designer.vb @@ -51,21 +51,17 @@ Partial Class dlgHistogram Me.toolStripMenuItemDensityOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemDensityRidgesOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemFrequencyPolygonOptions = New System.Windows.Forms.ToolStripMenuItem() - Me.lblReorder = New System.Windows.Forms.Label() - Me.ucrInputAddReorder = New instat.ucrInputComboBox() - Me.ucrVariablesAsFactorforHist = New instat.ucrVariablesAsFactor() Me.cmdOptions = New instat.ucrSplitButton() Me.ucrChkDisplayAsDotPlot = New instat.ucrCheck() Me.ucrChkRidges = New instat.ucrCheck() Me.ucrInputStats = New instat.ucrInputComboBox() Me.ucrChkPercentages = New instat.ucrCheck() Me.ucrSaveHist = New instat.ucrSave() + Me.ucrVariablesAsFactorforHist = New instat.ucrVariablesAsFactor() Me.ucrFactorReceiver = New instat.ucrReceiverSingle() Me.ucrHistogramSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrPnlOptions = New instat.UcrPanel() - Me.lblReorderValue = New System.Windows.Forms.Label() - Me.ucrInputReorderValue = New instat.ucrInputComboBox() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -133,15 +129,14 @@ Partial Class dlgHistogram ' 'lblStats ' - Me.lblStats.Location = New System.Drawing.Point(9, 278) + Me.lblStats.Location = New System.Drawing.Point(9, 276) Me.lblStats.Name = "lblStats" - Me.lblStats.Size = New System.Drawing.Size(43, 19) + Me.lblStats.Size = New System.Drawing.Size(56, 19) Me.lblStats.TabIndex = 11 Me.lblStats.Text = "merge" ' 'contextMenuStripOptions ' - Me.contextMenuStripOptions.ImageScalingSize = New System.Drawing.Size(20, 20) Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemHistogramOptions, Me.toolStripMenuItemDotOptions, Me.toolStripMenuItemDensityOptions, Me.toolStripMenuItemDensityRidgesOptions, Me.toolStripMenuItemFrequencyPolygonOptions}) Me.contextMenuStripOptions.Name = "contextMenuStripOk" Me.contextMenuStripOptions.Size = New System.Drawing.Size(222, 136) @@ -182,40 +177,6 @@ Partial Class dlgHistogram Me.toolStripMenuItemFrequencyPolygonOptions.Size = New System.Drawing.Size(221, 22) Me.toolStripMenuItemFrequencyPolygonOptions.Text = "Frequency Polygon Options" ' - 'lblReorder - ' - Me.lblReorder.AutoSize = True - Me.lblReorder.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblReorder.Location = New System.Drawing.Point(283, 318) - Me.lblReorder.Name = "lblReorder" - Me.lblReorder.Size = New System.Drawing.Size(48, 13) - Me.lblReorder.TabIndex = 44 - 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(283, 335) - Me.ucrInputAddReorder.Name = "ucrInputAddReorder" - Me.ucrInputAddReorder.Size = New System.Drawing.Size(120, 21) - Me.ucrInputAddReorder.TabIndex = 45 - ' - 'ucrVariablesAsFactorforHist - ' - Me.ucrVariablesAsFactorforHist.AutoSize = True - Me.ucrVariablesAsFactorforHist.frmParent = Me - Me.ucrVariablesAsFactorforHist.Location = New System.Drawing.Point(283, 64) - Me.ucrVariablesAsFactorforHist.Name = "ucrVariablesAsFactorforHist" - Me.ucrVariablesAsFactorforHist.Selector = Nothing - Me.ucrVariablesAsFactorforHist.Size = New System.Drawing.Size(125, 75) - Me.ucrVariablesAsFactorforHist.strNcFilePath = "" - Me.ucrVariablesAsFactorforHist.TabIndex = 43 - Me.ucrVariablesAsFactorforHist.ucrSelector = Nothing - Me.ucrVariablesAsFactorforHist.ucrVariableSelector = Nothing - ' 'cmdOptions ' Me.cmdOptions.AutoSize = True @@ -234,7 +195,6 @@ Partial Class dlgHistogram Me.ucrChkDisplayAsDotPlot.AutoSize = True Me.ucrChkDisplayAsDotPlot.Checked = False Me.ucrChkDisplayAsDotPlot.Location = New System.Drawing.Point(283, 256) - Me.ucrChkDisplayAsDotPlot.Margin = New System.Windows.Forms.Padding(5) Me.ucrChkDisplayAsDotPlot.Name = "ucrChkDisplayAsDotPlot" Me.ucrChkDisplayAsDotPlot.Size = New System.Drawing.Size(153, 23) Me.ucrChkDisplayAsDotPlot.TabIndex = 8 @@ -255,7 +215,7 @@ Partial Class dlgHistogram Me.ucrInputStats.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputStats.GetSetSelectedIndex = -1 Me.ucrInputStats.IsReadOnly = False - Me.ucrInputStats.Location = New System.Drawing.Point(53, 276) + Me.ucrInputStats.Location = New System.Drawing.Point(73, 272) Me.ucrInputStats.Margin = New System.Windows.Forms.Padding(5) Me.ucrInputStats.Name = "ucrInputStats" Me.ucrInputStats.Size = New System.Drawing.Size(137, 21) @@ -274,12 +234,26 @@ Partial Class dlgHistogram 'ucrSaveHist ' Me.ucrSaveHist.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveHist.Location = New System.Drawing.Point(10, 385) + Me.ucrSaveHist.Location = New System.Drawing.Point(10, 311) Me.ucrSaveHist.Margin = New System.Windows.Forms.Padding(5) Me.ucrSaveHist.Name = "ucrSaveHist" Me.ucrSaveHist.Size = New System.Drawing.Size(322, 24) Me.ucrSaveHist.TabIndex = 13 ' + 'ucrVariablesAsFactorforHist + ' + Me.ucrVariablesAsFactorforHist.AutoSize = True + Me.ucrVariablesAsFactorforHist.frmParent = Me + Me.ucrVariablesAsFactorforHist.Location = New System.Drawing.Point(281, 68) + Me.ucrVariablesAsFactorforHist.Margin = New System.Windows.Forms.Padding(5) + Me.ucrVariablesAsFactorforHist.Name = "ucrVariablesAsFactorforHist" + Me.ucrVariablesAsFactorforHist.Selector = Nothing + Me.ucrVariablesAsFactorforHist.Size = New System.Drawing.Size(125, 136) + Me.ucrVariablesAsFactorforHist.strNcFilePath = "" + Me.ucrVariablesAsFactorforHist.TabIndex = 5 + Me.ucrVariablesAsFactorforHist.ucrSelector = Nothing + Me.ucrVariablesAsFactorforHist.ucrVariableSelector = Nothing + ' 'ucrFactorReceiver ' Me.ucrFactorReceiver.AutoSize = True @@ -309,7 +283,7 @@ Partial Class dlgHistogram ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(9, 419) + Me.ucrBase.Location = New System.Drawing.Point(10, 334) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) @@ -324,38 +298,12 @@ Partial Class dlgHistogram Me.ucrPnlOptions.Size = New System.Drawing.Size(433, 30) Me.ucrPnlOptions.TabIndex = 0 ' - 'lblReorderValue - ' - Me.lblReorderValue.AutoSize = True - Me.lblReorderValue.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblReorderValue.Location = New System.Drawing.Point(280, 142) - Me.lblReorderValue.Name = "lblReorderValue" - Me.lblReorderValue.Size = New System.Drawing.Size(48, 13) - Me.lblReorderValue.TabIndex = 46 - Me.lblReorderValue.Text = "Reorder:" - ' - 'ucrInputReorderValue - ' - Me.ucrInputReorderValue.AddQuotesIfUnrecognised = True - Me.ucrInputReorderValue.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrInputReorderValue.GetSetSelectedIndex = -1 - Me.ucrInputReorderValue.IsReadOnly = False - Me.ucrInputReorderValue.Location = New System.Drawing.Point(283, 158) - Me.ucrInputReorderValue.Name = "ucrInputReorderValue" - Me.ucrInputReorderValue.Size = New System.Drawing.Size(93, 21) - Me.ucrInputReorderValue.TabIndex = 47 - ' '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, 476) - Me.Controls.Add(Me.ucrInputReorderValue) - Me.Controls.Add(Me.lblReorderValue) - Me.Controls.Add(Me.ucrInputAddReorder) - Me.Controls.Add(Me.lblReorder) - Me.Controls.Add(Me.ucrVariablesAsFactorforHist) + Me.ClientSize = New System.Drawing.Size(448, 394) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.ucrChkDisplayAsDotPlot) Me.Controls.Add(Me.ucrChkRidges) @@ -363,6 +311,7 @@ Partial Class dlgHistogram Me.Controls.Add(Me.ucrInputStats) Me.Controls.Add(Me.ucrChkPercentages) Me.Controls.Add(Me.ucrSaveHist) + Me.Controls.Add(Me.ucrVariablesAsFactorforHist) Me.Controls.Add(Me.ucrFactorReceiver) Me.Controls.Add(Me.rdoFrequencyPolygon) Me.Controls.Add(Me.rdoDensity_ridges) @@ -390,6 +339,7 @@ Partial Class dlgHistogram Friend WithEvents rdoFrequencyPolygon As RadioButton Friend WithEvents ucrFactorReceiver As ucrReceiverSingle Friend WithEvents lblfactor As Label + Friend WithEvents ucrVariablesAsFactorforHist As ucrVariablesAsFactor Friend WithEvents ucrPnlOptions As UcrPanel Friend WithEvents ucrSaveHist As ucrSave Friend WithEvents ucrInputStats As ucrInputComboBox @@ -405,9 +355,4 @@ Partial Class dlgHistogram Friend WithEvents toolStripMenuItemDensityRidgesOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemFrequencyPolygonOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemDotOptions As ToolStripMenuItem - Friend WithEvents ucrVariablesAsFactorforHist As ucrVariablesAsFactor - Friend WithEvents lblReorder As Label - Friend WithEvents ucrInputAddReorder As ucrInputComboBox - Friend WithEvents lblReorderValue As Label - Friend WithEvents ucrInputReorderValue As ucrInputComboBox End Class \ No newline at end of file diff --git a/instat/dlgHistogram.resx b/instat/dlgHistogram.resx index 406cc5c74be..4f920f19046 100644 --- a/instat/dlgHistogram.resx +++ b/instat/dlgHistogram.resx @@ -120,7 +120,4 @@ 17, 17 - - 31 - \ No newline at end of file diff --git a/instat/dlgHistogram.vb b/instat/dlgHistogram.vb index b541ff9562a..4d8fce75cc8 100644 --- a/instat/dlgHistogram.vb +++ b/instat/dlgHistogram.vb @@ -43,18 +43,6 @@ Public Class dlgHistogram Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction Private clsAnnotateFunction As New RFunction - Private clsReorderFunction As New RFunction - Private clsReorderValueFunction As New RFunction - Private clsGeomTextFunction As New RFunction - Private clsForecatsReverseValue As New RFunction - Private clsForecatsInfreqValue As New RFunction - Private clsForecatsInfreq As New RFunction - Private clsForecatsReverse As New RFunction - - Private clsDummyRev As New RFunction - Private ReadOnly strAscending As String = "Ascending" - Private ReadOnly strDescending As String = "Descending" - Private ReadOnly strNone As String = "None" 'Parameter names for geoms Private strFirstParameterName As String = "geomfunc" @@ -74,6 +62,7 @@ Public Class dlgHistogram bReset = False autoTranslate(Me) TestOkEnabled() + DialogueSize() End Sub Private Sub InitialiseDialog() @@ -110,7 +99,7 @@ Public Class dlgHistogram ucrInputStats.SetLinkedDisplayControl(lblStats) ucrInputStats.AddToLinkedControls(ucrChkPercentages, {"Fractions"}, bNewLinkedHideIfParameterMissing:=True) - ucrChkPercentages.SetText("Percentages") + ucrChkPercentages.SetText("percentages") ucrChkPercentages.AddParameterPresentCondition(True, "scale") ucrChkPercentages.AddParameterPresentCondition(False, "scale", False) @@ -130,14 +119,6 @@ Public Class dlgHistogram ucrVariablesAsFactorforHist.bWithQuotes = False ucrVariablesAsFactorforHist.SetParameterIsString() - ucrInputAddReorder.SetItems({strAscending, strDescending, strNone}) - ucrInputAddReorder.SetDropDownStyleAsNonEditable() - ucrInputAddReorder.SetLinkedDisplayControl(lblReorder) - - ucrInputReorderValue.SetItems({strAscending, strDescending, strNone}) - ucrInputReorderValue.SetDropDownStyleAsNonEditable() - ucrInputReorderValue.SetLinkedDisplayControl(lblReorderValue) - ucrPnlOptions.AddToLinkedControls({ucrChkDisplayAsDotPlot}, {rdoHistogram}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrChkRidges}, {rdoDensity_ridges}, bNewLinkedHideIfParameterMissing:=True) ucrChkRidges.AddToLinkedControls(ucrInputStats, {"FALSE"}, bNewLinkedHideIfParameterMissing:=True) @@ -148,6 +129,7 @@ Public Class dlgHistogram ucrSaveHist.SetCheckBoxText("Save Graph") ucrSaveHist.SetSaveTypeAsGraph() ucrSaveHist.SetAssignToIfUncheckedValue("last_graph") + DialogueSize() End Sub Private Sub SetDefaults() @@ -157,15 +139,6 @@ Public Class dlgHistogram clsRaesFunction = New RFunction clsHistAesFunction = New RFunction clsPercentage = New RFunction - clsGeomTextFunction = New RFunction - clsForecatsReverseValue = New RFunction - clsDummyRev = New RFunction - clsReorderFunction = New RFunction - clsReorderValueFunction = New RFunction - clsForecatsInfreqValue = New RFunction - clsForecatsInfreq = New RFunction - clsForecatsReverse = New RFunction - ucrHistogramSelector.Reset() ucrHistogramSelector.SetGgplotFunction(clsBaseOperator) ucrSaveHist.Reset() @@ -173,8 +146,6 @@ Public Class dlgHistogram bResetSubdialog = True bResetHistLayerSubdialog = True - clsDummyRev.AddParameter("reverse", "FALSE", iPosition:=0) - clsBaseOperator.SetOperation("+") clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRggplotFunction, iPosition:=0) clsBaseOperator.AddParameter(strFirstParameterName, clsRFunctionParameter:=clsRgeomPlotFunction, iPosition:=2) @@ -183,11 +154,6 @@ Public Class dlgHistogram clsRggplotFunction.SetRCommand("ggplot") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction, iPosition:=1) - ucrInputAddReorder.SetText(strNone) - - ucrInputReorderValue.SetText(strNone) - ucrInputReorderValue.bUpdateRCodeFromControl = True - clsRaesFunction.SetPackageName("ggplot2") clsRaesFunction.SetRCommand("aes") @@ -202,29 +168,6 @@ Public Class dlgHistogram clsPercentage.SetPackageName("scales") clsPercentage.SetRCommand("percent_format") - clsGeomTextFunction.SetPackageName("ggplot2") - clsGeomTextFunction.SetRCommand("geom_text") - 'clsGeomTextFunction.AddParameter("mapping", clsRFunctionParameter:=clsLabelAesFunction, iPosition:=1) - clsGeomTextFunction.AddParameter("colour", "black", iPosition:=4) - clsGeomTextFunction.AddParameter("vjust", "-0.25", iPosition:=2) - clsGeomTextFunction.AddParameter("size", "4", iPosition:=5) - - clsForecatsReverseValue.SetPackageName("forcats") - clsForecatsReverseValue.SetRCommand("fct_rev") - - clsReorderFunction.SetRCommand("reorder") - - clsReorderValueFunction.SetRCommand("reorder") - - clsForecatsInfreqValue.SetPackageName("forcats") - clsForecatsInfreqValue.SetRCommand("fct_infreq") - - clsForecatsInfreq.SetPackageName("forcats") - clsForecatsInfreq.SetRCommand("fct_infreq") - - clsForecatsReverse.SetPackageName("forcats") - clsForecatsReverse.SetRCommand("fct_rev") - clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsYlabFunction = GgplotDefaults.clsYlabTitleFunction.Clone() @@ -257,8 +200,6 @@ Public Class dlgHistogram ucrChkRidges.SetRCode(clsRgeomPlotFunction, bReset) ucrFactorReceiver.SetRCode(clsRaesFunction, bReset) ucrVariablesAsFactorforHist.SetRCode(clsRaesFunction, bReset) - ucrFactorReceiver.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) - ucrVariablesAsFactorforHist.AddAdditionalCodeParameterPair(clsReorderValueFunction, New RParameter("x", 0), iAdditionalPairNo:=1) If bReset Then ucrInputStats.SetRCode(clsHistAesFunction, bReset) End If @@ -266,7 +207,7 @@ Public Class dlgHistogram Private Sub TestOkEnabled() 'Tests when ok can be enabled - If ucrVariablesAsFactorforHist.IsEmpty OrElse Not ucrSaveHist.IsComplete OrElse ucrFactorReceiver.IsEmpty Then + If ucrVariablesAsFactorforHist.IsEmpty OrElse Not ucrSaveHist.IsComplete OrElse (ucrChkRidges.Checked AndAlso (ucrFactorReceiver.IsEmpty OrElse ucrFactorReceiver.Enabled = False)) Then ucrBase.OKEnabled(False) Else ucrBase.OKEnabled(True) @@ -284,7 +225,6 @@ 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") @@ -292,27 +232,9 @@ Public Class dlgHistogram clsRgeomPlotFunction.SetRCommand("geom_histogram") End If ucrFactorReceiver.ChangeParameterName("fill") - ' If ucrChkReverse.Checked Then - ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - ' Else - ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) - ' End If - ' If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("histogram") - ' ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() + If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("histogram") End If If rdoDensity_ridges.Checked Then - ucrFactorReceiver.ChangeParameterName("fill") - 'If ucrChkReverse.Checked Then - ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - 'Else - ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) - 'End If - 'ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() - If Not ucrSaveHist.bUserTyped Then - ucrSaveHist.SetPrefix("density_ridges") - End If If ucrChkRidges.Checked Then ucrFactorReceiver.ChangeParameterName("y") clsHistAesFunction.RemoveParameterByName("y") @@ -320,36 +242,34 @@ Public Class dlgHistogram clsHistAesFunction.AddParameter("y", clsRFunctionParameter:=ucrFactorReceiver.GetVariables(), iPosition:=2) clsRgeomPlotFunction.SetPackageName("ggridges") clsRgeomPlotFunction.SetRCommand("geom_density_ridges") + If Not ucrSaveHist.bUserTyped Then + ucrSaveHist.SetPrefix("density_ridges") + End If Else ucrFactorReceiver.ChangeParameterName("colour") clsRgeomPlotFunction.SetRCommand("geom_density") + If Not ucrSaveHist.bUserTyped Then + ucrSaveHist.SetPrefix("density") + End If End If ElseIf rdoFrequencyPolygon.Checked Then ucrFactorReceiver.ChangeParameterName("colour") clsRgeomPlotFunction.SetRCommand("geom_freqpoly") - If Not ucrSaveHist.bUserTyped Then - ucrSaveHist.SetPrefix("density") - End If - ucrFactorReceiver.ChangeParameterName("fill") - 'If ucrChkReverse.Checked Then - ' clsForecatsReverseValue.AddParameter("f", ucrFactorReceiver.GetVariableNames(False), iPosition:=0) - ' clsRaesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - 'Else - ' clsRaesFunction.AddParameter("fill", ucrFactorReceiver.GetVariableNames(False), iPosition:=1) - 'End If - 'ucrChkReverse.Visible = Not ucrFactorReceiver.IsEmpty() If Not ucrSaveHist.bUserTyped Then ucrSaveHist.SetPrefix("frequency_polygon") End If End If autoTranslate(Me) - UpdateParameter() End Sub - Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, - ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged, - ucrInputAddReorder.ControlValueChanged, ucrInputReorderValue.ControlValueChanged + Private Sub ucrPnlOptions_Control() Handles ucrPnlOptions.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrChkRidges.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforHist.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 + toolStripMenuItemDensityRidgesOptions.Enabled = rdoDensity_ridges.Checked AndAlso ucrChkRidges.Checked + toolStripMenuItemFrequencyPolygonOptions.Enabled = rdoFrequencyPolygon.Checked SetDialogOptions() + DialogueSize() End Sub Private Sub Adding_Percentages(ucrChangedControl As ucrCore) Handles ucrInputStats.ControlValueChanged, ucrChkPercentages.ControlValueChanged @@ -443,17 +363,9 @@ Public Class dlgHistogram SetDialogOptions() End Sub - Private Sub SetGeomTextOptions() - If rdoHistogram.Checked Then - clsGeomTextFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=0) - Else - clsGeomTextFunction.RemoveParameterByName("stat") - End If - End Sub - Private Sub DialogueSize() If rdoHistogram.Checked Then - Me.Size = New Size(464, 480) + Me.Size = New Size(464, 409) Me.ucrSaveHist.Location = New Point(10, 284) Me.ucrBase.Location = New Point(10, 314) ElseIf rdoDensity_ridges.Checked Then @@ -470,35 +382,4 @@ Public Class dlgHistogram Private Sub CoreControls_ControlContentsChanged() Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged TestOkEnabled() End Sub - - Private Sub UpdateParameter() - If rdoHistogram.Checked OrElse rdoDensity_ridges.Checked OrElse rdoFrequencyPolygon.Checked Then - Dim strChangedTextFreq As String = ucrInputReorderValue.GetText() - Dim strChangedTextValue As String = ucrInputAddReorder.GetText() - clsForecatsInfreq.AddParameter("f", "as.factor(" & ucrVariablesAsFactorforHist.GetVariableNames(False) & ")", iPosition:=0) - clsForecatsInfreqValue.AddParameter("f", "as.factor(" & ucrFactorReceiver.GetVariableNames(False) & ")", iPosition:=0) - Select Case strChangedTextFreq - Case strAscending - clsForecatsReverse.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - clsHistAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) - Case strDescending - clsHistAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsInfreq, iPosition:=0) - End Select - Select Case strChangedTextValue - Case strAscending - clsForecatsReverseValue.AddParameter("f", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=0) - clsHistAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=1) - Case strDescending - clsHistAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsInfreqValue, iPosition:=1) - End Select - End If - End Sub - Private Sub ucrPnlOptions_Control(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged, ucrFactorReceiver.ControlValueChanged, - ucrChkRidges.ControlValueChanged, ucrChkDisplayAsDotPlot.ControlValueChanged, ucrVariablesAsFactorforHist.ControlValueChanged, - ucrInputAddReorder.ControlValueChanged, ucrInputReorderValue.ControlValueChanged - UpdateParameter() - End Sub - - Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrVariablesAsFactorforHist.ControlContentsChanged, ucrSaveHist.ControlContentsChanged, ucrFactorReceiver.ControlContentsChanged, ucrChkRidges.ControlContentsChanged - End Sub End Class \ No newline at end of file From cc0a7e397a6b00c0ff4d5ebada92e3af37ee0f7e Mon Sep 17 00:00:00 2001 From: n-thony Date: Thu, 31 Aug 2023 12:30:00 +0300 Subject: [PATCH 28/57] minor bug fix --- instat/dlgBarAndPieChart.vb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 6cbe0fc2fbc..1d972d6f922 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -165,7 +165,7 @@ Public Class dlgBarAndPieChart ucrReceiverByFactor.Selector = ucrBarChartSelector ucrReceiverByFactor.SetIncludedDataTypes({"factor"}) ucrReceiverByFactor.strSelectorHeading = "Factors" - ucrReceiverByFactor.SetParameter(New RParameter("fill", 2)) + 'ucrReceiverByFactor.SetParameter(New RParameter("fill", 2)) ucrReceiverByFactor.bWithQuotes = False ucrReceiverByFactor.SetParameterIsString() @@ -604,8 +604,8 @@ Public Class dlgBarAndPieChart ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) - ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) - ucrReceiverX.SetRCode(clsBarAesFunction, bReset) + 'ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) + 'ucrReceiverX.SetRCode(clsBarAesFunction, bReset) ucrSaveBar.SetRCode(clsBaseOperator, bReset) ucrBarChartSelector.SetRCode(clsRggplotFunction, bReset) ucrChkPolarCoordinates.SetRCode(clsPolarCoordFunction, bReset) @@ -638,7 +638,7 @@ Public Class dlgBarAndPieChart ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset) - ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) + 'ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) End If End Sub @@ -692,7 +692,7 @@ Public Class dlgBarAndPieChart If clsParam.strArgumentValue = Chr(34) & Chr(34) Then ucrReceiverX.Clear() Else - ucrReceiverX.Add(clsParam.strArgumentValue) + 'ucrReceiverX.Add(clsParam.strArgumentValue) End If 'In the y case, the value stored in the clsReasFunction in the multiple variables ' case is "value", however that one shouldn't be written in the multiple @@ -816,11 +816,11 @@ Public Class dlgBarAndPieChart clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strNone - clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End Select Else - clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If If ucrChkPolarCoordinates.Checked Then @@ -877,7 +877,7 @@ Public Class dlgBarAndPieChart clsBarAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) clsPieAesFunction.AddParameter("x", clsRFunctionParameter:=clsForecatsReverse, iPosition:=0) Case strNone - clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=1) + clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) End Select Else @@ -987,7 +987,6 @@ Public Class dlgBarAndPieChart clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) clsTextAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else - clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) clsTextAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If If ucrReceiverByFactor.IsEmpty Then From 7a6c6a9be3aa02dd8c20dc160250c6020b64c26c Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Thu, 31 Aug 2023 12:44:32 +0300 Subject: [PATCH 29/57] Code changes. Fixes bug in bar chart sub dialogue and reorder when 2 variables are filled. --- instat/dlgBarAndPieChart.vb | 2 -- 1 file changed, 2 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 1d972d6f922..0b7ab85d394 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -604,8 +604,6 @@ Public Class dlgBarAndPieChart ucrReceiverX.AddAdditionalCodeParameterPair(clsReorderFunction, New RParameter("x", 0), iAdditionalPairNo:=1) ucrInputLayout.AddAdditionalCodeParameterPair(clsGeomTreemapTextFunction, New RParameter("layout", 1), iAdditionalPairNo:=1) - 'ucrVariablesAsFactorForBarChart.SetRCode(clsBarAesFunction, bReset) - 'ucrReceiverX.SetRCode(clsBarAesFunction, bReset) ucrSaveBar.SetRCode(clsBaseOperator, bReset) ucrBarChartSelector.SetRCode(clsRggplotFunction, bReset) ucrChkPolarCoordinates.SetRCode(clsPolarCoordFunction, bReset) From c919ec043bbdcea8c153046761d2faed0c6bf12f Mon Sep 17 00:00:00 2001 From: n-thony Date: Sun, 3 Sep 2023 11:25:46 +0300 Subject: [PATCH 30/57] minor bug fix --- instat/dlgBarAndPieChart.vb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 1d972d6f922..2b57482159b 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -861,8 +861,9 @@ Public Class dlgBarAndPieChart End Select End If ElseIf rdoValue.Checked Then + clsReorderFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) + clsReorderFunctionValue.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) If ucrChkReorderValue.Checked Then - clsReorderFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) Select Case strChangeTextReorder Case strAscending clsReorderFunction.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) @@ -888,7 +889,7 @@ Public Class dlgBarAndPieChart If rdoPie.Checked OrElse rdoDonut.Checked Then If ucrReceiverByFactor.IsEmpty Then clsPieAesFunction.AddParameter("x", "1", iPosition:=0) - Select Case strChangedTextValue + Select Case strChangeTextReorder Case strAscending clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) @@ -896,16 +897,15 @@ Public Class dlgBarAndPieChart clsReorderFunctionValue.AddParameter("X", "-" & ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsReorderFunctionValue, iPosition:=2) Case strReverse - clsForecatsReverseValue.AddParameter("f", ucrReceiverByFactor.GetVariableNames(False), iPosition:=0) + clsForecatsReverseValue.AddParameter("f", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsPieAesFunction.AddParameter("fill", clsRFunctionParameter:=clsForecatsReverseValue, iPosition:=2) Case strNone - clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) + clsPieAesFunction.AddParameter("fill", ucrReceiverX.GetVariableNames(False), iPosition:=2) End Select End If End If End If If Not ucrReceiverByFactor.IsEmpty Then - clsReorderFunctionValue.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) Select Case strChangedTextValue Case strAscending clsReorderFunctionValue.AddParameter("X", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) @@ -944,6 +944,10 @@ Public Class dlgBarAndPieChart clsPieAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) + If ucrChkPolarCoordinates.Checked Then + clsRggplotFunction.RemoveParameterByName("mapping") + clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) + End If clsGeomLollipopAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsGeomLollipopAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) clsGeomLollipopAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=2) From 1a4720360ff9226baaecf10ed598aaa9a3bfe9df Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:31:48 +0300 Subject: [PATCH 31/57] Minor bug fix --- instat/dlgBarAndPieChart.vb | 2 -- 1 file changed, 2 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index e112a4e69b3..ca24afb9611 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -165,7 +165,6 @@ Public Class dlgBarAndPieChart ucrReceiverByFactor.Selector = ucrBarChartSelector ucrReceiverByFactor.SetIncludedDataTypes({"factor"}) ucrReceiverByFactor.strSelectorHeading = "Factors" - 'ucrReceiverByFactor.SetParameter(New RParameter("fill", 2)) ucrReceiverByFactor.bWithQuotes = False ucrReceiverByFactor.SetParameterIsString() @@ -636,7 +635,6 @@ Public Class dlgBarAndPieChart ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset) ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset) ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset) - 'ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) End If End Sub From eef51190a2abe8d9b65a7e07ffda60b7e776b984 Mon Sep 17 00:00:00 2001 From: n-thony Date: Tue, 5 Sep 2023 08:55:31 +0300 Subject: [PATCH 32/57] minor change --- instat/dlgBarAndPieChart.vb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 2b57482159b..3177c2bcff0 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -936,6 +936,9 @@ Public Class dlgBarAndPieChart clsPieAesFunction.RemoveParameterByName("fill") clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.RemoveParameterByName("aes") + clsGeomLollipopAesFunction.RemoveParameterByName("x") + clsGeomLollipopAesFunction.RemoveParameterByName("y") + clsGeomLollipopAesFunction.RemoveParameterByName("fill") If rdoValue.Checked Then clsBarAesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False), iPosition:=0) clsBarAesFunction.AddParameter("y", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) From 187aa1881752e6629a927cb79b17ccd1cd13c6c0 Mon Sep 17 00:00:00 2001 From: n-thony Date: Tue, 5 Sep 2023 09:07:30 +0300 Subject: [PATCH 33/57] minor change --- instat/dlgBarAndPieChart.vb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 3177c2bcff0..2ed789392e4 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -976,7 +976,7 @@ Public Class dlgBarAndPieChart If ucrChkLollipop.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) End If clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") @@ -987,27 +987,27 @@ Public Class dlgBarAndPieChart clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) End If Else If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - clsTextAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + ' clsTextAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else - clsTextAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + ' clsTextAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) End If If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) - clsTextAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + ' clsTextAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) Else clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsTextAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + ' clsTextAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) End If clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsRgeomBarFunction2.RemoveParameterByName("stat") If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsTextAesFunction, iPosition:=1) + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) End If End If clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) From bea74aea75cf7ed387b1a73500dbaeebfcfa28d6 Mon Sep 17 00:00:00 2001 From: n-thony Date: Tue, 5 Sep 2023 10:08:11 +0300 Subject: [PATCH 34/57] more fixes --- instat/dlgBarAndPieChart.vb | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 2ed789392e4..c1ececf4558 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -975,9 +975,6 @@ Public Class dlgBarAndPieChart End If If ucrChkLollipop.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) - If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) - End If clsBaseOperator.AddParameter("geom_lollipop", clsRFunctionParameter:=clsGeomLollipopFunction, iPosition:=2) clsBaseOperator.RemoveParameterByName("geom_bar") End If @@ -986,29 +983,25 @@ Public Class dlgBarAndPieChart If ucrChkPolarCoordinates.Checked Then clsRggplotFunction.RemoveParameterByName("mapping") clsRggplotFunction.AddParameter("aes", clsRFunctionParameter:=clsPieAesFunction, iPosition:=1, bIncludeArgumentName:=False) - If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) - End If Else If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - ' clsTextAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + clsPieAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) Else - ' clsTextAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=0) + clsBarAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("x", ucrVariablesAsFactorForBarChart.GetVariableNames(False), iPosition:=1) End If If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) - ' clsTextAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + clsPieAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) Else clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - ' clsTextAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) + clsRgeomBarFunction.RemoveParameterByName("position") End If clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsRgeomBarFunction2.RemoveParameterByName("stat") - If ucrChkAddLabelsText.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=1) - End If End If clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) @@ -1119,7 +1112,6 @@ Public Class dlgBarAndPieChart clsBaseOperator.AddParameter("geom_text", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=5) Else clsBaseOperator.RemoveParameterByName("geom_text") - clsRggplotFunction.RemoveParameterByName("mapping") End If End Sub From 39bd56f68e333e925c6a2ccbcf95034c486319ca Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 5 Sep 2023 16:10:15 +0200 Subject: [PATCH 35/57] Update instat/dlgDeleteDataFrames.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/dlgDeleteDataFrames.vb | 1 - 1 file changed, 1 deletion(-) diff --git a/instat/dlgDeleteDataFrames.vb b/instat/dlgDeleteDataFrames.vb index 05a65d1cb86..008e12be7fe 100644 --- a/instat/dlgDeleteDataFrames.vb +++ b/instat/dlgDeleteDataFrames.vb @@ -63,7 +63,6 @@ Public Class dlgDeleteDataFrames End Sub Private Sub SetRCodeForControls(bReset As Boolean) - 'SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) ucrReceiverDataFrames.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub From 8da08fb05e25907c05606047627895603c7b0da6 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 5 Sep 2023 16:10:45 +0200 Subject: [PATCH 36/57] Update instat/dlgTransposeColumns.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/dlgTransposeColumns.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgTransposeColumns.vb b/instat/dlgTransposeColumns.vb index 42b9265afe9..0673dacc656 100644 --- a/instat/dlgTransposeColumns.vb +++ b/instat/dlgTransposeColumns.vb @@ -140,7 +140,7 @@ Public Class dlgTransposeColumns ClearSelector() If Not ucrReceiverColumnsToTranspose.IsEmpty Then '------------------------- - 'todo. this cod block below requires more refactoring. + 'todo. this code block below requires more refactoring. 'it should use the selector functions for adding items instead of accessing the selector controls Dim arrItems As String() = ucrReceiverColumnsToTranspose.GetVariableNamesList(False) If arrItems.Count > 1 Then From 5cbb07e171d07f8686fe7c6cd00cf98c1acf6962 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 5 Sep 2023 17:04:18 +0200 Subject: [PATCH 37/57] Update instat/ucrColumnMetadata.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 6cb82ed0604..aa7d94ec50e 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -166,7 +166,7 @@ Public Class ucrColumnMetadata Dim clsDeleteLabelsFunction As New RFunction If strColumnName = strLabelsLabel Then - If MsgBox("This will delete the selected label(s) And Replace Then With (NA)." & + If MsgBox("This will delete the selected label(s) and replace them with (NA)." & Environment.NewLine & "Continue?", MessageBoxButtons.YesNo, "Delete Labels") = DialogResult.Yes Then From e52d3f752b3f021d9d4e3674d8de2b02c8488f91 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 5 Sep 2023 17:04:33 +0200 Subject: [PATCH 38/57] Update instat/ucrColumnMetadata.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index aa7d94ec50e..e614c2360da 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -173,7 +173,7 @@ Public Class ucrColumnMetadata clsDeleteLabelsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_variables_metadata") clsDeleteLabelsFunction.AddParameter("data_name", Chr(34) & _grid.CurrentWorksheet.Name & Chr(34), iPosition:=0) clsDeleteLabelsFunction.AddParameter("col_names", frmMain.clsRLink.GetListAsRString(_grid.GetSelectedColumns), iPosition:=1) - clsDeleteLabelsFunction.AddParameter("Property", Chr(34) & "labels" & Chr(34), iPosition:=2) + clsDeleteLabelsFunction.AddParameter("property", Chr(34) & "labels" & Chr(34), iPosition:=2) clsDeleteLabelsFunction.AddParameter("new_val", Chr(34) & Chr(34), iPosition:=3) frmMain.clsRLink.RunScript(clsDeleteLabelsFunction.ToScript()) End If From de284a9902144810593c6324c2a32f6bb723141b Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 5 Sep 2023 17:05:12 +0200 Subject: [PATCH 39/57] Update instat/ucrReceiverExpression.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrReceiverExpression.vb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/instat/ucrReceiverExpression.vb b/instat/ucrReceiverExpression.vb index f4f297c1a45..e8c6eda3f49 100644 --- a/instat/ucrReceiverExpression.vb +++ b/instat/ucrReceiverExpression.vb @@ -139,11 +139,7 @@ Public Class ucrReceiverExpression End Sub Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String - If bWithQuotes Then - Return Chr(34) & cboExpression.Text & Chr(34) - Else - Return cboExpression.Text - End If + Return If(bWithQuotes, strQuotes & cboExpression.Text & strQuotes, cboExpression.Text) End Function Private Sub cboExpression_GotFocus(sender As Object, e As EventArgs) Handles cboExpression.GotFocus From 8d032dc72927ccf800b1b95758ebbd8bda712da4 Mon Sep 17 00:00:00 2001 From: EstherNjeri <74548350+EstherNjeriLiberatta@users.noreply.github.com> Date: Wed, 6 Sep 2023 09:00:49 +0300 Subject: [PATCH 40/57] Removed reorder from Treemap and Wordcloud, minor changes in the code --- instat/dlgBarAndPieChart.vb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 8be392b5df6..7e7205e4d3d 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -133,8 +133,8 @@ Public Class dlgBarAndPieChart ucrPnlOptions.AddFunctionNamesCondition(rdoWordCloud, {"geom_text_wordcloud", "scale_size_area"}) ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates, ucrChkPolarCoordinates, ucrReceiverByFactor, ucrInputBarChartPositions, ucrChkAddLabelsText, ucrVariablesAsFactorForBarChart, ucrChkBacktoback}, {rdoFrequency, rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrPnlOptions.AddToLinkedControls({ucrReceiverX, ucrChkReorderValue, ucrChkLollipop}, {rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrPnlOptions.AddToLinkedControls(ucrChkReorderFrequency, {rdoFrequency}, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls({ucrReceiverX, ucrChkReorderValue, ucrInputAddReorder, ucrChkLollipop}, {rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls({ucrChkReorderFrequency, ucrInputAddReorder}, {rdoFrequency}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrReceiverArea, ucrReceiverFill, ucrChkLayout, ucrChkStart, ucrChkAddLabelsTreemap}, {rdoTreeMap}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls({ucrReceiverWordcloudAngle, ucrReceiverWordcloudColor, ucrReceiverWordcloudLabel, ucrReceiverWordcloudSize, ucrChkIncreaseSize}, {rdoWordCloud}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverByFactor.SetLinkedDisplayControl(lblByFactor) @@ -761,9 +761,7 @@ Public Class dlgBarAndPieChart End If ucrVariablesAsFactorForBarChart.RemoveIncludedMetadataProperty("class") ucrVariablesAsFactorForBarChart.strSelectorHeading = "Variables" - ucrInputBarChartPositions.Visible = Not ucrReceiverByFactor.IsEmpty() - ElseIf rdoTreeMap.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomTreemapAesFunction, iPosition:=1) Else From 9e43a8862d6042afdff463b5b2fb751661365745 Mon Sep 17 00:00:00 2001 From: n-thony Date: Wed, 6 Sep 2023 10:52:58 +0300 Subject: [PATCH 41/57] minor code change --- instat/dlgBarAndPieChart.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index c1ececf4558..19b6abd17de 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -964,6 +964,7 @@ Public Class dlgBarAndPieChart If ucrReceiverX.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) clsPieAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) + clsRgeomBarFunction.RemoveParameterByName("position") End If If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("y", Chr(34) & Chr(34), iPosition:=1) From d31b639fb869ef89667f786b66f9683424487e8b Mon Sep 17 00:00:00 2001 From: n-thony Date: Wed, 6 Sep 2023 10:58:50 +0300 Subject: [PATCH 42/57] corrected the fill parameter --- instat/dlgBarAndPieChart.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 19b6abd17de..9ea0d531734 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -964,7 +964,6 @@ Public Class dlgBarAndPieChart If ucrReceiverX.IsEmpty Then clsBarAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) clsPieAesFunction.AddParameter("x", Chr(34) & Chr(34), iPosition:=0) - clsRgeomBarFunction.RemoveParameterByName("position") End If If ucrVariablesAsFactorForBarChart.IsEmpty Then clsBarAesFunction.AddParameter("y", Chr(34) & Chr(34), iPosition:=1) @@ -973,6 +972,7 @@ Public Class dlgBarAndPieChart If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=2) clsPieAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=2) + clsRgeomBarFunction.RemoveParameterByName("position") End If If ucrChkLollipop.Checked Then clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsGeomLollipopAesFunction, iPosition:=1) @@ -995,10 +995,10 @@ Public Class dlgBarAndPieChart If ucrReceiverByFactor.IsEmpty Then clsBarAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) clsPieAesFunction.AddParameter("fill", Chr(34) & Chr(34), iPosition:=1) + clsRgeomBarFunction.RemoveParameterByName("position") Else clsBarAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) clsPieAesFunction.AddParameter("fill", ucrReceiverByFactor.GetVariableNames(False), iPosition:=1) - clsRgeomBarFunction.RemoveParameterByName("position") End If clsRgeomBarFunction1.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=2) clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) From 4b32efa776d124ea7d94c71aa6dd9355cd2e7a30 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 12:31:03 +0300 Subject: [PATCH 43/57] removed strQuotes parameter --- instat/ucrReceiver.vb | 2 +- instat/ucrReceiverExpression.vb | 4 ++-- instat/ucrReceiverMultiple.vb | 2 +- instat/ucrReceiverSingle.vb | 10 +++++++--- instat/ucrVariablesAsFactor.vb | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/instat/ucrReceiver.vb b/instat/ucrReceiver.vb index f6ef51f798b..8594abe6044 100644 --- a/instat/ucrReceiver.vb +++ b/instat/ucrReceiver.vb @@ -154,7 +154,7 @@ Public Class ucrReceiver Return New RFunction End Function - Public Overridable Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Public Overridable Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String Return "" End Function diff --git a/instat/ucrReceiverExpression.vb b/instat/ucrReceiverExpression.vb index e8c6eda3f49..6916cdf0e80 100644 --- a/instat/ucrReceiverExpression.vb +++ b/instat/ucrReceiverExpression.vb @@ -138,8 +138,8 @@ Public Class ucrReceiverExpression OnSelectionChanged() End Sub - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String - Return If(bWithQuotes, strQuotes & cboExpression.Text & strQuotes, cboExpression.Text) + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String + Return If(bWithQuotes, Chr(34) & cboExpression.Text & Chr(34), cboExpression.Text) End Function Private Sub cboExpression_GotFocus(sender As Object, e As EventArgs) Handles cboExpression.GotFocus diff --git a/instat/ucrReceiverMultiple.vb b/instat/ucrReceiverMultiple.vb index 3aeb7d49494..16063dcb64e 100644 --- a/instat/ucrReceiverMultiple.vb +++ b/instat/ucrReceiverMultiple.vb @@ -289,7 +289,7 @@ Public Class ucrReceiverMultiple Return lstColumnFunctions End Function - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String Dim strTempBuilder As New Text.StringBuilder Dim strQuoteHolder As String = If(bWithQuotes, Chr(34), "") diff --git a/instat/ucrReceiverSingle.vb b/instat/ucrReceiverSingle.vb index 49e4fd96c3c..6ae7be192e6 100644 --- a/instat/ucrReceiverSingle.vb +++ b/instat/ucrReceiverSingle.vb @@ -218,12 +218,16 @@ Public Class ucrReceiverSingle End If End Function - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String - Return If(bWithQuotes, strQuotes & txtReceiverSingle.Text & strQuotes, txtReceiverSingle.Text) + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String + Return If(bWithQuotes, Chr(34) & txtReceiverSingle.Text & Chr(34), txtReceiverSingle.Text) End Function Public Overrides Function GetVariableNameslist(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String() - Return {GetVariableNames(bWithQuotes:=bWithQuotes, strQuotes:=strQuotes)} + If bWithQuotes Then + Return {strQuotes & txtReceiverSingle.Text & strQuotes} + Else + Return {txtReceiverSingle.Text} + End If End Function Public Function GetDataName() As String diff --git a/instat/ucrVariablesAsFactor.vb b/instat/ucrVariablesAsFactor.vb index 6ed854247d1..1909cf33d05 100644 --- a/instat/ucrVariablesAsFactor.vb +++ b/instat/ucrVariablesAsFactor.vb @@ -62,7 +62,7 @@ Public Class ucrVariablesAsFactor OnSelectionChanged() End Sub - Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True, Optional strQuotes As String = Chr(34)) As String + Public Overrides Function GetVariableNames(Optional bWithQuotes As Boolean = True) As String 'This sub provides the name of the variable that should be used by external components that want to access the "content" of this receiver. If it is in single mode, this is simply providing the name of the variable in use. 'However in multiple mode, a New variable will be created using the "stack" And "measure.vars" explained in SetReceiverStatus. Dim strVariables As String = "" From 6dee6684d428d4e9007b4fafce63f7757e3462a7 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 11:32:05 +0200 Subject: [PATCH 44/57] Update instat/ucrColumnMetadata.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index e614c2360da..ca27ae28eeb 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -178,7 +178,7 @@ Public Class ucrColumnMetadata frmMain.clsRLink.RunScript(clsDeleteLabelsFunction.ToScript()) End If Else - MsgBox("Deleting cells Is currently disabled. This feature will be included In future versions." & Environment.NewLine & + MsgBox("Deleting cells is currently disabled. This feature will be included in future versions." & Environment.NewLine & "To remove a cell's value, replace the value with NA.", MsgBoxStyle.Information, "Cannot delete cells.") End If End Sub From 427aaa1d70ebb90a5fb3ad2328acd0d8485d9021 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 11:34:48 +0200 Subject: [PATCH 45/57] Update instat/ucrColumnMetadata.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index ca27ae28eeb..3f928c3d021 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -405,7 +405,7 @@ Public Class ucrColumnMetadata End Sub Private Sub columnContextMenuStrip_Opening(sender As Object, e As CancelEventArgs) Handles columnContextMenuStrip.Opening - If IsOnlyOneDataframeColumnSeleted() Then + If IsOnlyOneDataframeColumnSelected() Then mnuLevelsLabels.Enabled = IsFirstSelectedDataFrameColumnAFactor() mnuDeleteCol.Text = GetTranslation("Delete Column") mnuInsertColsBefore.Text = GetTranslation("Insert 1 Column Before") From e9dd36d5304306c62d4b63a2e7f8253cc5969f8d Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 11:38:21 +0200 Subject: [PATCH 46/57] Update instat/ucrSelector.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrSelector.vb | 1 - 1 file changed, 1 deletion(-) diff --git a/instat/ucrSelector.vb b/instat/ucrSelector.vb index fd628cd26ea..39437eaef48 100644 --- a/instat/ucrSelector.vb +++ b/instat/ucrSelector.vb @@ -202,7 +202,6 @@ Public Class ucrSelector Public Overridable Sub Reset() RaiseEvent ResetReceivers() - 'lstVariablesInReceivers.Clear() LoadList() End Sub From 4e79429215a0ee8233c6bae3557a24dc91ffaeb7 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 11:39:39 +0200 Subject: [PATCH 47/57] Update instat/ucrSelector.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrSelector.vb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/instat/ucrSelector.vb b/instat/ucrSelector.vb index 39437eaef48..3f425f71c30 100644 --- a/instat/ucrSelector.vb +++ b/instat/ucrSelector.vb @@ -316,15 +316,6 @@ Public Class ucrSelector ucrLinkedSelector = ucrNewLinkedSelector End Sub - 'Public lstVariablesInReceivers As List(Of Tuple(Of String, String)) - 'Public Sub AddToVariablesList(strVariable As String, Optional strDataFrame As String = "") - ' If strDataFrame = "" OrElse strDataFrame = strCurrentDataFrame Then - ' lstVariablesInReceivers.Add(New Tuple(Of String, String)(strVariable, strDataFrame)) - ' If ucrLinkedSelector IsNot Nothing Then - ' ucrLinkedSelector.AddToVariablesList(strVariable, strCurrentDataFrame) - ' End If - ' End If - 'End Sub 'Public Sub RemoveFromVariablesList(strVariable As String, Optional strDataFrame As String = "") ' For i As Integer = lstVariablesInReceivers.Count - 1 To 0 Step -1 From 96975351405debae81de605602632a7a3415b841 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 11:40:11 +0200 Subject: [PATCH 48/57] Update instat/ucrSelector.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrSelector.vb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/instat/ucrSelector.vb b/instat/ucrSelector.vb index 3f425f71c30..19c21d3620b 100644 --- a/instat/ucrSelector.vb +++ b/instat/ucrSelector.vb @@ -317,16 +317,6 @@ Public Class ucrSelector End Sub - 'Public Sub RemoveFromVariablesList(strVariable As String, Optional strDataFrame As String = "") - ' For i As Integer = lstVariablesInReceivers.Count - 1 To 0 Step -1 - ' If lstVariablesInReceivers(i).Item1 = strVariable AndAlso (strDataFrame = "" OrElse lstVariablesInReceivers(i).Item2 = strDataFrame) Then - ' lstVariablesInReceivers.RemoveAt(i) - ' End If - ' Next - ' If ucrLinkedSelector IsNot Nothing Then - ' ucrLinkedSelector.RemoveFromVariablesList(strVariable, strCurrentDataFrame) - ' End If - 'End Sub Public Sub AddIncludedMetadataProperty(strProperty As String, strInclude As String()) Dim iIncludeIndex As Integer From 296dbc04769c9affc2bab15e72047429897a2c59 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 6 Sep 2023 12:40:53 +0300 Subject: [PATCH 49/57] changes suggested --- instat/ucrColumnMetadata.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 3f928c3d021..d6fe3461573 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -342,7 +342,7 @@ Public Class ucrColumnMetadata Return selectedDataframeColumns End Function - Private Function IsOnlyOneDataframeColumnSeleted() As Boolean + Private Function IsOnlyOneDataframeColumnSelected() As Boolean Return _grid.GetSelectedRows().Count = 1 End Function From fc2582711146c4ba875fbd86e28c952a38f55b4e Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:17:29 +0200 Subject: [PATCH 50/57] Ensured the Key checkbox worked correctly in dlgRownamesOrNumbers --- instat/dlgRownamesOrNumbers.vb | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/instat/dlgRownamesOrNumbers.vb b/instat/dlgRownamesOrNumbers.vb index 71b4ef06d77..55c0408081e 100644 --- a/instat/dlgRownamesOrNumbers.vb +++ b/instat/dlgRownamesOrNumbers.vb @@ -22,7 +22,9 @@ Public Class dlgRowNamesOrNumbers Private clsGetRowNamesFunction As New RFunction Private clsSetRowNamesFunction As New RFunction Private clsAddKeyFunction As New RFunction - Private clsAsNumericFunction As New RFunction + Private clsAsBaseFunction As New RFunction + Private clsAsSapplyFunction As New RFunction + Private clsAsRownamesFunction As New RFunction Private clsDummyFunction As New RFunction Private Sub dlgRowNamesOrNumbers_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -33,7 +35,6 @@ Public Class dlgRowNamesOrNumbers If bReset Then SetDefaults() - IdentifyKey() End If SetRCodeForControls(bReset) bReset = False @@ -66,7 +67,7 @@ Public Class dlgRowNamesOrNumbers ucrPnlOverallOptions.AddParameterValuesCondition(rdoResetintoPositiveIntegers, "checked_rdo", "reset_row") ucrPnlOverallOptions.AddParameterValuesCondition(rdoSortbyRowNames, "checked_rdo", "sort_row") - ucrPnlOverallOptions.AddToLinkedControls({ucrNewColumnName, ucrChkMakeColumnIntoKey}, {rdoCopyRowNamesIntoFirstColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOverallOptions.AddToLinkedControls({ucrNewColumnName, ucrChkMakeColumnIntoKey}, {rdoCopyRowNamesIntoFirstColumn}, bNewLinkedHideIfParameterMissing:=True) ucrPnlOverallOptions.AddToLinkedControls(ucrReceiverRowNames, {rdoSetRowNamesFromColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOverallOptions.AddToLinkedControls(ucrPnlSortOptions, {rdoSortbyRowNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOverallOptions.AddToLinkedControls(ucrChkAsNumeric, {rdoSortbyRowNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -92,7 +93,7 @@ Public Class dlgRowNamesOrNumbers ucrChkMakeColumnIntoKey.SetText("Make the Column a Key for the Data Frame") ucrChkMakeColumnIntoKey.AddParameterValuesCondition(True, "add_key", "TRUE") ucrChkMakeColumnIntoKey.AddParameterValuesCondition(False, "add_key", "FALSE") - IdentifyKey() + 'ucrNewColumnName ucrNewColumnName.SetIsComboBox() ucrNewColumnName.SetPrefix("row") @@ -106,25 +107,34 @@ Public Class dlgRowNamesOrNumbers clsAddKeyFunction = New RFunction clsDummyFunction = New RFunction clsSetRowNamesFunction = New RFunction - clsAsNumericFunction = New RFunction + clsAsBaseFunction = New RFunction + clsAsSapplyFunction = New RFunction + clsAsRownamesFunction = New RFunction ucrNewColumnName.Reset() ucrSelectorRowNames.Reset() ucrBase.clsRsyntax.lstAfterCodes.Clear() clsDummyFunction.AddParameter("checked_rdo", "copy_row", iPosition:=1) - clsDummyFunction.AddParameter("add_key", "FALSE", iPosition:=2) + clsDummyFunction.AddParameter("add_key", "TRUE", iPosition:=2) - clsAddKeyFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_key") + clsAsRownamesFunction.SetRCommand("rownames") + clsAsRownamesFunction.AddParameter("data", ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bIncludeArgumentName:=False) + + clsAsSapplyFunction.SetRCommand("sapply") + clsAsSapplyFunction.AddParameter("x", clsRFunctionParameter:=clsAsRownamesFunction, bIncludeArgumentName:=False, iPosition:=0) + clsAsSapplyFunction.AddParameter("numeric", "is.numeric", bIncludeArgumentName:=False, iPosition:=1) - clsAsNumericFunction.SetRCommand("as.numeric") - clsAsNumericFunction.AddParameter("x", clsRFunctionParameter:=clsGetRowNamesFunction, iPosition:=0) + clsAsBaseFunction.SetRCommand("all") + clsAsBaseFunction.AddParameter("all", clsRFunctionParameter:=clsAsSapplyFunction, bIncludeArgumentName:=False, iPosition:=0) + + clsAddKeyFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_key") clsGetRowNamesFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_row_names") clsGetRowNamesFunction.SetAssignTo(strTemp:=ucrNewColumnName.GetText(), strTempDataframe:=ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnName.GetText()) clsSetRowNamesFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_row_names") - + ucrBase.clsRsyntax.AddToBeforeCodes(clsAsBaseFunction) ucrBase.clsRsyntax.SetBaseRFunction(clsGetRowNamesFunction) End Sub @@ -137,9 +147,9 @@ Public Class dlgRowNamesOrNumbers ucrChkMakeColumnIntoKey.SetRCode(clsDummyFunction, bReset) ucrPnlOverallOptions.SetRCode(clsDummyFunction, bReset) ucrNewColumnName.AddAdditionalRCode(clsGetRowNamesFunction, bReset) - ucrNewColumnName.SetRCode(clsAsNumericFunction, bReset) + ucrNewColumnName.SetRCode(clsGetRowNamesFunction, bReset) ucrChkAsNumeric.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - IdentifyKey() + End Sub Private Sub TestOKEnabled() @@ -165,7 +175,7 @@ Public Class dlgRowNamesOrNumbers Else ucrSelectorRowNames.SetVariablesVisible(False) If rdoCopyRowNamesIntoFirstColumn.Checked Then - ucrBase.clsRsyntax.SetBaseRFunction(clsAsNumericFunction) + ucrBase.clsRsyntax.SetBaseRFunction(clsGetRowNamesFunction) clsDummyFunction.AddParameter("checked_rdo", "copy_row", iPosition:=1) ElseIf rdoResetintoPositiveIntegers.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsSetRowNamesFunction) @@ -190,13 +200,8 @@ Public Class dlgRowNamesOrNumbers End If End Sub - Private Sub IdentifyKey() - ucrChkMakeColumnIntoKey.Checked = Not frmMain.clsRLink.IsVariablesMetadata(ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Is_Key") - End Sub - Private Sub ucrChkMakeColumnIntoKey_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkMakeColumnIntoKey.ControlValueChanged AddRemoveKeyFromAfterCodes() - IdentifyKey() End Sub Private Sub ucrNewColumnName_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrNewColumnName.ControlValueChanged @@ -210,6 +215,5 @@ Public Class dlgRowNamesOrNumbers End Sub Private Sub ucrSelectorRowNames_DataFrameChanged() Handles ucrSelectorRowNames.DataFrameChanged - IdentifyKey() End Sub End Class \ No newline at end of file From a85fadbc86935080e3fa688f315c94dbf6f7bab5 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:21:12 +0200 Subject: [PATCH 51/57] Code Changes --- instat/dlgRownamesOrNumbers.vb | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/instat/dlgRownamesOrNumbers.vb b/instat/dlgRownamesOrNumbers.vb index 55c0408081e..64557363c9d 100644 --- a/instat/dlgRownamesOrNumbers.vb +++ b/instat/dlgRownamesOrNumbers.vb @@ -22,9 +22,6 @@ Public Class dlgRowNamesOrNumbers Private clsGetRowNamesFunction As New RFunction Private clsSetRowNamesFunction As New RFunction Private clsAddKeyFunction As New RFunction - Private clsAsBaseFunction As New RFunction - Private clsAsSapplyFunction As New RFunction - Private clsAsRownamesFunction As New RFunction Private clsDummyFunction As New RFunction Private Sub dlgRowNamesOrNumbers_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -107,9 +104,6 @@ Public Class dlgRowNamesOrNumbers clsAddKeyFunction = New RFunction clsDummyFunction = New RFunction clsSetRowNamesFunction = New RFunction - clsAsBaseFunction = New RFunction - clsAsSapplyFunction = New RFunction - clsAsRownamesFunction = New RFunction ucrNewColumnName.Reset() ucrSelectorRowNames.Reset() @@ -118,23 +112,12 @@ Public Class dlgRowNamesOrNumbers clsDummyFunction.AddParameter("checked_rdo", "copy_row", iPosition:=1) clsDummyFunction.AddParameter("add_key", "TRUE", iPosition:=2) - clsAsRownamesFunction.SetRCommand("rownames") - clsAsRownamesFunction.AddParameter("data", ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bIncludeArgumentName:=False) - - clsAsSapplyFunction.SetRCommand("sapply") - clsAsSapplyFunction.AddParameter("x", clsRFunctionParameter:=clsAsRownamesFunction, bIncludeArgumentName:=False, iPosition:=0) - clsAsSapplyFunction.AddParameter("numeric", "is.numeric", bIncludeArgumentName:=False, iPosition:=1) - - clsAsBaseFunction.SetRCommand("all") - clsAsBaseFunction.AddParameter("all", clsRFunctionParameter:=clsAsSapplyFunction, bIncludeArgumentName:=False, iPosition:=0) - clsAddKeyFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_key") clsGetRowNamesFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_row_names") clsGetRowNamesFunction.SetAssignTo(strTemp:=ucrNewColumnName.GetText(), strTempDataframe:=ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnName.GetText()) clsSetRowNamesFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_row_names") - ucrBase.clsRsyntax.AddToBeforeCodes(clsAsBaseFunction) ucrBase.clsRsyntax.SetBaseRFunction(clsGetRowNamesFunction) End Sub From a6a86c042fe35cfc2d088879ec4db2eaca512674 Mon Sep 17 00:00:00 2001 From: Barbra2020 Date: Mon, 11 Sep 2023 11:57:24 +0300 Subject: [PATCH 52/57] minor code change --- instat/dlgOneVariableSummarise.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index 2085628dc26..056dd0c575f 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -270,7 +270,6 @@ Public Class dlgOneVariableSummarise ucrChkOmitMissing.AddAdditionalCodeParameterPair(clsSummaryTableFunction, New RParameter("na.rm", iNewPosition:=2), iAdditionalPairNo:=1) ucrSaveSummary.AddAdditionalRCode(clsSummaryFunction, iAdditionalPairNo:=1) ucrSaveSummary.AddAdditionalRCode(clsJoiningPipeOperator, iAdditionalPairNo:=2) - ucrNudMaxSum.SetRCode(clsSummaryFunction, bReset) ucrReceiverOneVarSummarise.SetRCode(clsSummaryFunction, bReset) ucrChkOmitMissing.SetRCode(clsSummaryFunction, bReset) @@ -282,6 +281,7 @@ Public Class dlgOneVariableSummarise If bReset Then ucrChkDisplayMissing.SetRCode(clsDummyFunction, bReset) ucrPnlColumnFactor.SetRCode(clsDummyFunction, bReset) + ucrNudMaxSum.SetRCode(clsSummaryFunction, bReset) End If bRCodeSet = True FillListView() From 34719a51d01ecd32e7387142ee5f069c882850a4 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:19:22 +0200 Subject: [PATCH 53/57] Code changes --- instat/dlgRownamesOrNumbers.vb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/instat/dlgRownamesOrNumbers.vb b/instat/dlgRownamesOrNumbers.vb index 64557363c9d..dee1a9c4e04 100644 --- a/instat/dlgRownamesOrNumbers.vb +++ b/instat/dlgRownamesOrNumbers.vb @@ -23,6 +23,9 @@ Public Class dlgRowNamesOrNumbers Private clsSetRowNamesFunction As New RFunction Private clsAddKeyFunction As New RFunction Private clsDummyFunction As New RFunction + Private clsGetVectorFunction As New RFunction + Private clsHmiscFunction As New RFunction + Private Sub dlgRowNamesOrNumbers_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then @@ -104,6 +107,9 @@ Public Class dlgRowNamesOrNumbers clsAddKeyFunction = New RFunction clsDummyFunction = New RFunction clsSetRowNamesFunction = New RFunction + clsGetVectorFunction = New RFunction + clsHmiscFunction = New RFunction + ucrNewColumnName.Reset() ucrSelectorRowNames.Reset() @@ -114,6 +120,14 @@ Public Class dlgRowNamesOrNumbers clsAddKeyFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_key") + clsGetVectorFunction.SetRCommand("what=c") + clsGetVectorFunction.AddParameter("vector", Chr(34) & "vector" & Chr(34), bIncludeArgumentName:=False) + + clsHmiscFunction.SetPackageName("Hmisc") + clsHmiscFunction.SetRCommand("all.is.numeric") + clsHmiscFunction.AddParameter("row", clsRFunctionParameter:=clsGetRowNamesFunction, bIncludeArgumentName:=False, iPosition:=0) + clsHmiscFunction.AddParameter("vector", clsRFunctionParameter:=clsGetVectorFunction, bIncludeArgumentName:=False, iPosition:=1) + clsGetRowNamesFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_row_names") clsGetRowNamesFunction.SetAssignTo(strTemp:=ucrNewColumnName.GetText(), strTempDataframe:=ucrSelectorRowNames.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnName.GetText()) @@ -130,7 +144,7 @@ Public Class dlgRowNamesOrNumbers ucrChkMakeColumnIntoKey.SetRCode(clsDummyFunction, bReset) ucrPnlOverallOptions.SetRCode(clsDummyFunction, bReset) ucrNewColumnName.AddAdditionalRCode(clsGetRowNamesFunction, bReset) - ucrNewColumnName.SetRCode(clsGetRowNamesFunction, bReset) + ucrNewColumnName.SetRCode(clsHmiscFunction, bReset) ucrChkAsNumeric.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub @@ -158,7 +172,7 @@ Public Class dlgRowNamesOrNumbers Else ucrSelectorRowNames.SetVariablesVisible(False) If rdoCopyRowNamesIntoFirstColumn.Checked Then - ucrBase.clsRsyntax.SetBaseRFunction(clsGetRowNamesFunction) + ucrBase.clsRsyntax.SetBaseRFunction(clsHmiscFunction) clsDummyFunction.AddParameter("checked_rdo", "copy_row", iPosition:=1) ElseIf rdoResetintoPositiveIntegers.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsSetRowNamesFunction) From 483f1b7682ca7c62d702d30a4b7aad42ebd9e704 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 13 Sep 2023 10:16:16 +0300 Subject: [PATCH 54/57] fixed double imports when using script window --- instat/clsRLink.vb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index b96462c6da6..b690c17b391 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -824,15 +824,8 @@ Public Class RLink End If ElseIf iCallType = 5 Then 'else if script comes from script window - Dim bSuccess As Boolean = Evaluate(strScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride) - - 'if not an assignment operation, then capture the output - If Not strScript.Contains("<-") AndAlso bSuccess Then - Dim strScriptAsSingleLine As String = strScript.Replace(vbCrLf, String.Empty) - strScriptAsSingleLine = strScriptAsSingleLine.Replace(vbCr, String.Empty) - strScriptAsSingleLine = strScriptAsSingleLine.Replace(vbLf, String.Empty) - strOutput = GetFileOutput("view_object_data(object = " & strScriptAsSingleLine & " , object_format = 'text' )", bSilent, bSeparateThread, bShowWaitDialogOverride) - End If + 'wrap command inside view_object_data just incase there is an output object + strOutput = GetFileOutput("view_object_data(object = " & strScript & " , object_format = 'text' )", bSilent, bSeparateThread, bShowWaitDialogOverride) Else 'else if script output should not be ignored or not stored as an object or variable @@ -883,7 +876,8 @@ Public Class RLink Dim expTemp As RDotNet.SymbolicExpression Dim strNewAssignedToScript As String = ConstructAssignTo(strTempAssignTo, strScript) Evaluate(strNewAssignedToScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride) - expTemp = GetSymbol(strTempAssignTo, bSilent:=bSilent) + 'get file path. If not found then silently return nothing + expTemp = GetSymbol(strTempAssignTo, bSilent:=False) Evaluate("rm(" & strTempAssignTo & ")", bSilent:=True) If expTemp IsNot Nothing Then 'get the file path name, check if it exists and whether it has contents From 7134ce1cef46ec244201ad086d01084e5bd42eeb Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 13 Sep 2023 10:46:35 +0300 Subject: [PATCH 55/57] allows comments to go to the output window when run from script window --- instat/clsRLink.vb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index b690c17b391..b6d918f5c5d 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -912,17 +912,8 @@ Public Class RLink Public Function RunScriptFromWindow(strNewScript As String, strNewComment As String) As String Dim strScriptCmd As String = "" - 'for each line in script For Each strScriptLine As String In strNewScript.Split(Environment.NewLine) - 'remove any comments (character '#' and anything after) - Dim iCommentPos As Integer = strScriptLine.IndexOf("#") - Select Case iCommentPos - Case 0 'a normal comment line (starts with '#') - Continue For - Case Is > 0 ' a line with an appended comment (e.g. 'x <- 1 # generate data' converted to 'x <- 1 ') - strScriptLine = strScriptLine.Substring(0, iCommentPos - 1) - End Select 'if line is empty or only whitespace then ignore line Dim strTrimmedLine As String = strScriptLine.Trim(vbLf).Trim() From d9329a5a8cf902d69f9662c92410db2aa675bc6c Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 14 Sep 2023 10:41:01 +0300 Subject: [PATCH 56/57] restored functionality --- instat/clsRLink.vb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index b6d918f5c5d..8f2b6d6175e 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -877,7 +877,7 @@ Public Class RLink Dim strNewAssignedToScript As String = ConstructAssignTo(strTempAssignTo, strScript) Evaluate(strNewAssignedToScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride) 'get file path. If not found then silently return nothing - expTemp = GetSymbol(strTempAssignTo, bSilent:=False) + expTemp = GetSymbol(strTempAssignTo, bSilent:=True) Evaluate("rm(" & strTempAssignTo & ")", bSilent:=True) If expTemp IsNot Nothing Then 'get the file path name, check if it exists and whether it has contents @@ -914,6 +914,14 @@ Public Class RLink 'for each line in script For Each strScriptLine As String In strNewScript.Split(Environment.NewLine) + 'remove any comments (character '#' and anything after) + Dim iCommentPos As Integer = strScriptLine.IndexOf("#") + Select Case iCommentPos + Case 0 'a normal comment line (starts with '#') + Continue For + Case Is > 0 ' a line with an appended comment (e.g. 'x <- 1 # generate data' converted to 'x <- 1 ') + strScriptLine = strScriptLine.Substring(0, iCommentPos - 1) + End Select 'if line is empty or only whitespace then ignore line Dim strTrimmedLine As String = strScriptLine.Trim(vbLf).Trim() From b94bc5dd899a922c99485796eb98c82c99b626b7 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 14 Sep 2023 10:41:44 +0300 Subject: [PATCH 57/57] added line --- instat/clsRLink.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 8f2b6d6175e..76c2baca7d9 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -912,6 +912,7 @@ Public Class RLink Public Function RunScriptFromWindow(strNewScript As String, strNewComment As String) As String Dim strScriptCmd As String = "" + 'for each line in script For Each strScriptLine As String In strNewScript.Split(Environment.NewLine) 'remove any comments (character '#' and anything after)