From 88c242fb269279eb0367fff066f78c46ac0a9dd7 Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Thu, 5 Dec 2019 12:30:07 +0300 Subject: [PATCH 1/6] made designer changes - removed column chart radio button --- instat/dlgBarAndPieChart.Designer.vb | 33 +++--- instat/dlgBarAndPieChart.resx | 153 ++++++++++++++------------- instat/dlgBarAndPieChart.vb | 103 ++---------------- 3 files changed, 106 insertions(+), 183 deletions(-) diff --git a/instat/dlgBarAndPieChart.Designer.vb b/instat/dlgBarAndPieChart.Designer.vb index e3f2f494c8a..d155035a3b5 100644 --- a/instat/dlgBarAndPieChart.Designer.vb +++ b/instat/dlgBarAndPieChart.Designer.vb @@ -47,7 +47,6 @@ Partial Class dlgBarAndPieChart Me.rdoBarChart = New System.Windows.Forms.RadioButton() Me.cmdBarChartOptions = New System.Windows.Forms.Button() Me.lblPosition = New System.Windows.Forms.Label() - Me.rdoColumnChart = New System.Windows.Forms.RadioButton() Me.lblYvariable = New System.Windows.Forms.Label() Me.cmdColumnChartOptions = New System.Windows.Forms.Button() Me.ucrReceiverY = New instat.ucrReceiverSingle() @@ -59,6 +58,8 @@ Partial Class dlgBarAndPieChart Me.ucrBarChartSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.ucrPnlOptions = New instat.UcrPanel() + Me.lblYValue = New System.Windows.Forms.Label() + Me.ucrInputYValue = New instat.ucrInputComboBox() Me.SuspendLayout() ' 'lblVariable @@ -123,18 +124,6 @@ Partial Class dlgBarAndPieChart resources.ApplyResources(Me.lblPosition, "lblPosition") Me.lblPosition.Name = "lblPosition" ' - 'rdoColumnChart - ' - resources.ApplyResources(Me.rdoColumnChart, "rdoColumnChart") - Me.rdoColumnChart.BackColor = System.Drawing.SystemColors.Control - Me.rdoColumnChart.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoColumnChart.FlatAppearance.BorderSize = 2 - Me.rdoColumnChart.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoColumnChart.Name = "rdoColumnChart" - Me.rdoColumnChart.TabStop = True - Me.rdoColumnChart.Tag = "Column_Chart" - Me.rdoColumnChart.UseVisualStyleBackColor = False - ' 'lblYvariable ' resources.ApplyResources(Me.lblYvariable, "lblYvariable") @@ -210,14 +199,27 @@ Partial Class dlgBarAndPieChart resources.ApplyResources(Me.ucrPnlOptions, "ucrPnlOptions") Me.ucrPnlOptions.Name = "ucrPnlOptions" ' + 'lblYValue + ' + resources.ApplyResources(Me.lblYValue, "lblYValue") + Me.lblYValue.Name = "lblYValue" + ' + 'ucrInputYValue + ' + Me.ucrInputYValue.AddQuotesIfUnrecognised = True + Me.ucrInputYValue.IsReadOnly = False + resources.ApplyResources(Me.ucrInputYValue, "ucrInputYValue") + Me.ucrInputYValue.Name = "ucrInputYValue" + ' 'dlgBarAndPieChart ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.ucrInputYValue) + Me.Controls.Add(Me.lblYValue) Me.Controls.Add(Me.cmdColumnChartOptions) Me.Controls.Add(Me.lblYvariable) Me.Controls.Add(Me.ucrReceiverY) - Me.Controls.Add(Me.rdoColumnChart) Me.Controls.Add(Me.lblPosition) Me.Controls.Add(Me.ucrInputBarChartPosition) Me.Controls.Add(Me.ucrSaveBar) @@ -260,8 +262,9 @@ Partial Class dlgBarAndPieChart Friend WithEvents cmdBarChartOptions As Button Friend WithEvents ucrInputBarChartPosition As ucrInputComboBox Friend WithEvents lblPosition As Label - Friend WithEvents rdoColumnChart As RadioButton Friend WithEvents lblYvariable As Label Friend WithEvents ucrReceiverY As ucrReceiverSingle Friend WithEvents cmdColumnChartOptions As Button + Friend WithEvents ucrInputYValue As ucrInputComboBox + Friend WithEvents lblYValue As Label End Class \ No newline at end of file diff --git a/instat/dlgBarAndPieChart.resx b/instat/dlgBarAndPieChart.resx index 7c81550356d..b690e6b85a9 100644 --- a/instat/dlgBarAndPieChart.resx +++ b/instat/dlgBarAndPieChart.resx @@ -130,13 +130,13 @@ 255, 76 - 48, 13 + 58, 13 4 - Variable: + X Variable: lblVariable @@ -148,7 +148,7 @@ $this - 12 + 13 True @@ -157,7 +157,7 @@ NoControl - 255, 126 + 255, 226 103, 13 @@ -178,7 +178,7 @@ $this - 11 + 12 NoControl @@ -205,7 +205,7 @@ $this - 10 + 11 NoControl @@ -232,7 +232,7 @@ $this - 18 + 19 Button @@ -244,7 +244,7 @@ NoControl - 176, 10 + 206, 12 110, 28 @@ -268,7 +268,7 @@ $this - 9 + 10 Button @@ -280,7 +280,7 @@ NoControl - 66, 10 + 98, 12 110, 28 @@ -304,7 +304,7 @@ $this - 8 + 9 NoControl @@ -331,7 +331,7 @@ $this - 17 + 18 True @@ -340,7 +340,7 @@ NoControl - 256, 171 + 255, 276 47, 13 @@ -361,43 +361,7 @@ $this - 4 - - - Button - - - Flat - - - NoControl - - - 286, 10 - - - 110, 28 - - - 15 - - - Column Chart - - - MiddleCenter - - - rdoColumnChart - - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 + 5 True @@ -406,16 +370,16 @@ NoControl - 255, 171 + 255, 176 - 63, 13 + 58, 13 17 - By Variable: + Y Variable: lblYvariable @@ -427,7 +391,7 @@ $this - 1 + 3 NoControl @@ -454,7 +418,7 @@ $this - 0 + 2 True @@ -463,10 +427,58 @@ 6, 13 - 431, 411 + 415, 411 + + + 255, 141 + + + 92, 21 + + + 20 + + + ucrInputYValue + + + instat.ucrInputComboBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + True + + + 255, 126 + + + 47, 13 + + + 19 + + + Y Value: + + + lblYValue + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 - 255, 184 + 255, 291 21, 17, 21, 17 @@ -487,7 +499,7 @@ $this - 5 + 6 9, 328 @@ -508,7 +520,7 @@ $this - 6 + 7 9, 302 @@ -529,10 +541,10 @@ $this - 7 + 8 - 255, 141 + 255, 241 0, 0, 0, 0 @@ -553,7 +565,7 @@ $this - 13 + 14 255, 91 @@ -577,7 +589,7 @@ $this - 14 + 15 10, 41 @@ -601,7 +613,7 @@ $this - 15 + 16 9, 358 @@ -622,7 +634,7 @@ $this - 16 + 17 66, 6 @@ -643,16 +655,13 @@ $this - 19 - - - NoControl + 20 CenterScreen - Bar, Pie and Column Chart + Bar and Pie Chart dlgBarAndPieChart @@ -661,7 +670,7 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 255, 184 + 255, 191 0, 0, 0, 0 @@ -682,6 +691,6 @@ $this - 2 + 4 \ No newline at end of file diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 97d8e1801b3..46f77bdf754 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -21,8 +21,6 @@ Public Class dlgBarAndPieChart Private clsRgeomBarFunction As New RFunction Private clsBarAesFunction As New RFunction Private clsPieAesFunction As New RFunction - Private clsRColFunction As New RFunction - Private clsColAesFunction As New RFunction Private clsLocalRaesFunction As New RFunction Private clsBaseOperator As New ROperator Private clsRCoordPolarParam As New RParameter @@ -68,18 +66,20 @@ Public Class dlgBarAndPieChart ucrPnlOptions.AddRadioButton(rdoBarChart) ucrPnlOptions.AddRadioButton(rdoPieChart) - ucrPnlOptions.AddRadioButton(rdoColumnChart) ucrPnlOptions.AddParameterPresentCondition(rdoPieChart, "coord_polar") ucrPnlOptions.AddParameterPresentCondition(rdoBarChart, "geom_bar") - ucrPnlOptions.AddParameterPresentCondition(rdoColumnChart, "geom_col") - ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates}, {rdoColumnChart, rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + + ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlOptions.AddToLinkedControls(ucrInputBarChartPosition, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrInputBarChartPosition.SetLinkedDisplayControl(lblPosition) - ucrPnlOptions.AddToLinkedControls({ucrReceiverByFactor}, {rdoBarChart, rdoColumnChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls({ucrReceiverByFactor}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverByFactor.SetLinkedDisplayControl(lblByFactor) - ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoColumnChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverY.SetLinkedDisplayControl(lblYvariable) + ucrPnlOptions.AddToLinkedControls({ucrInputYValue}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrInputYValue.SetLinkedDisplayControl(lblYValue) + ucrBarChartSelector.SetParameter(New RParameter("data", 0)) ucrBarChartSelector.SetParameterIsrfunction() @@ -144,8 +144,6 @@ Public Class dlgBarAndPieChart clsRgeomBarFunction = New RFunction clsBarAesFunction = New RFunction clsPieAesFunction = New RFunction - clsColAesFunction = New RFunction - clsRColFunction = New RFunction ucrBarChartSelector.Reset() ucrBarChartSelector.SetGgplotFunction(clsBaseOperator) @@ -162,8 +160,6 @@ Public Class dlgBarAndPieChart clsRggplotFunction.SetPackageName("ggplot2") clsRggplotFunction.SetRCommand("ggplot") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsColAesFunction, iPosition:=1) - clsBarAesFunction.SetPackageName("ggplot2") clsBarAesFunction.SetRCommand("aes") @@ -176,15 +172,6 @@ Public Class dlgBarAndPieChart clsRgeomBarFunction.SetRCommand("geom_bar") clsRgeomBarFunction.AddParameter("position", Chr(34) & "dodge" & Chr(34), iPosition:=0) - clsColAesFunction.SetPackageName("ggplot2") - clsColAesFunction.SetRCommand("aes") - clsColAesFunction.AddParameter("x", Chr(34) & Chr(34)) - clsColAesFunction.AddParameter("y", Chr(34) & Chr(34)) - - clsRColFunction.SetPackageName("ggplot2") - clsRColFunction.SetRCommand("geom_col") - - clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() clsXlabFunction = GgplotDefaults.clsXlabTitleFunction.Clone() @@ -205,13 +192,7 @@ Public Class dlgBarAndPieChart Private Sub SetRCodeForControls(bReset As Boolean) ucrReceiverFirst.SetRCode(clsBarAesFunction, bReset) ucrReceiverFirst.AddAdditionalCodeParameterPair(clsPieAesFunction, New RParameter("fill", 0), iAdditionalPairNo:=1) - ucrReceiverFirst.AddAdditionalCodeParameterPair(clsColAesFunction, New RParameter("x", 0), iAdditionalPairNo:=2) - ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) - ucrReceiverByFactor.AddAdditionalCodeParameterPair(clsColAesFunction, New RParameter("fill", 0), iAdditionalPairNo:=1) - - ucrReceiverY.SetRCode(clsColAesFunction, bReset) - ucrSaveBar.SetRCode(clsBaseOperator, bReset) ucrBarChartSelector.SetRCode(clsRggplotFunction, bReset) ucrPnlOptions.SetRCode(clsBaseOperator, bReset) @@ -232,12 +213,6 @@ Public Class dlgBarAndPieChart Else ucrBase.OKEnabled(True) End If - ElseIf rdoColumnChart.Checked Then - If Not ucrReceiverFirst.IsEmpty AndAlso Not ucrReceiverY.IsEmpty AndAlso ucrSaveBar.IsComplete Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If End If End Sub @@ -281,29 +256,6 @@ Public Class dlgBarAndPieChart TestOkEnabled() End Sub - Private Sub cmdColumnChartOptions_Click(sender As Object, e As EventArgs) Handles cmdColumnChartOptions.Click - sdgLayerOptions.SetupLayer(clsNewGgPlot:=clsRggplotFunction, clsNewGeomFunc:=clsRColFunction, clsNewGlobalAesFunc:=clsColAesFunction, clsNewLocalAes:=clsLocalRaesFunction, bFixGeom:=True, ucrNewBaseSelector:=ucrBarChartSelector, bApplyAesGlobally:=True, bReset:=bResetBarLayerSubdialog) - sdgLayerOptions.ShowDialog() - bResetBarLayerSubdialog = False - If clsColAesFunction.ContainsParameter("x") Then - ucrReceiverFirst.Add(clsColAesFunction.GetParameter("x").strArgumentValue) - Else - ucrReceiverFirst.Clear() - End If - If clsColAesFunction.ContainsParameter("y") Then - ucrReceiverY.Add(clsColAesFunction.GetParameter("y").strArgumentValue) - Else - ucrReceiverY.Clear() - End If - If clsColAesFunction.ContainsParameter("fill") Then - ucrReceiverByFactor.Add(clsColAesFunction.GetParameter("fill").strArgumentValue) - Else - ucrReceiverByFactor.Clear() - End If - TestOkEnabled() - End Sub - - Private Sub cmdPieChartOptions_Click(sender As Object, e As EventArgs) Handles cmdPieChartOptions.Click sdgLayerOptions.SetupLayer(clsNewGgPlot:=clsRggplotFunction, clsNewGeomFunc:=clsRgeomBarFunction, clsNewGlobalAesFunc:=clsPieAesFunction, clsNewLocalAes:=clsLocalRaesFunction, bFixGeom:=True, ucrNewBaseSelector:=ucrBarChartSelector, bApplyAesGlobally:=True, bReset:=bResetBarLayerSubdialog) sdgLayerOptions.ShowDialog() @@ -354,52 +306,11 @@ Public Class dlgBarAndPieChart If Not {"factor", "logical"}.Contains(ucrReceiverFirst.strCurrDataType) Then ucrReceiverFirst.Clear() End If - ElseIf rdoColumnChart.Checked Then - clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsColAesFunction, iPosition:=1) - cmdPieChartOptions.Visible = False - cmdBarChartOptions.Visible = False - cmdColumnChartOptions.Visible = True - ucrReceiverFirst.SetIncludedDataTypes({"numeric", "factor"}) - clsBaseOperator.RemoveParameterByName("geom_bar") - clsBaseOperator.RemoveParameter(clsRCoordPolarParam) - clsBaseOperator.AddParameter("geom_col", clsRFunctionParameter:=clsRColFunction, iPosition:=2) - ucrReceiverY.SetMeAsReceiver() - If Not ucrSaveBar.bUserTyped Then - ucrSaveBar.SetPrefix("column") - End If - End If - End Sub - Private Sub ChangeReceiverLocation() - If rdoBarChart.Checked Then - lblVariable.Text = "Variable" - lblVariable.Location = New Point(255, 76) - ucrReceiverFirst.Location = New Point(255, 91) - lblByFactor.Text = "By Factor (Optional):" - lblByFactor.Location = New Point(255, 126) - ucrReceiverByFactor.Location = New Point(255, 141) - lblPosition.Text = "Position" - lblPosition.Location = New Point(255, 171) - ucrInputBarChartPosition.Location = New Point(255, 184) - ElseIf rdoColumnChart.Checked Then - lblYvariable.Text = "Y Variable:" - lblYvariable.Location = New Point(255, 76) - ucrReceiverY.Location = New Point(255, 91) - lblVariable.Text = "X Variable:" - lblVariable.Location = New Point(255, 126) - ucrReceiverFirst.Location = New Point(255, 141) - lblByFactor.Text = "By Factor (Optional):" - lblByFactor.Location = New Point(255, 171) - ucrReceiverByFactor.Location = New Point(255, 184) - ElseIf rdoPieChart.Checked Then - lblVariable.Text = "Variable" - lblVariable.Location = New Point(255, 76) - ucrReceiverFirst.Location = New Point(255, 91) End If End Sub Private Sub ucrPnlOptions_ControlValueChanged() Handles ucrPnlOptions.ControlValueChanged SetDialogOptions() - ChangeReceiverLocation() End Sub Private Sub CoreControls_ContentsChanged() Handles ucrReceiverFirst.ControlContentsChanged, ucrReceiverY.ControlContentsChanged, ucrSaveBar.ControlContentsChanged From 78dfd4a6fad0a347ebcaea043ff271f3111e4ebd Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Thu, 5 Dec 2019 13:18:35 +0300 Subject: [PATCH 2/6] Added dictionary for y values options --- instat/dlgBarAndPieChart.vb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 46f77bdf754..2369181e9a4 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -59,6 +59,7 @@ Public Class dlgBarAndPieChart Dim clsCoordFlipParam As New RParameter Dim clsRCoordPolarFunction As New RFunction Dim dctPositionPairs As New Dictionary(Of String, String) + Dim dctStatOptions As New Dictionary(Of String, String) ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False ucrBase.clsRsyntax.iCallType = 3 @@ -125,6 +126,13 @@ Public Class dlgBarAndPieChart ucrChkFlipCoordinates.SetText("Flip Coordinates") ucrChkFlipCoordinates.SetParameter(clsCoordFlipParam, bNewChangeParameterValue:=False, bNewAddRemoveParameter:=True) + ucrInputYValue.SetParameter(New RParameter("stat", 0)) + dctStatOptions.Add("Count", Chr(34) & "count" & Chr(34)) + dctStatOptions.Add("Column", Chr(34) & "identity" & Chr(34)) + ucrInputYValue.SetItems(dctStatOptions) + ucrInputYValue.SetDropDownStyleAsNonEditable() + ucrInputYValue.SetRDefault(Chr(34) & "count" & Chr(34)) + ucrInputBarChartPosition.SetParameter(New RParameter("position", 0)) dctPositionPairs.Add("Stack", Chr(34) & "stack" & Chr(34)) dctPositionPairs.Add("Dodge", Chr(34) & "dodge" & Chr(34)) @@ -156,7 +164,6 @@ Public Class dlgBarAndPieChart clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRggplotFunction, iPosition:=0) clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2) - clsRggplotFunction.SetPackageName("ggplot2") clsRggplotFunction.SetRCommand("ggplot") clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1) @@ -171,6 +178,7 @@ Public Class dlgBarAndPieChart clsRgeomBarFunction.SetPackageName("ggplot2") clsRgeomBarFunction.SetRCommand("geom_bar") clsRgeomBarFunction.AddParameter("position", Chr(34) & "dodge" & Chr(34), iPosition:=0) + clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=0) clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() From f7334cd6993a4aa571b2d2bf3bb31b7ad1b03890 Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Thu, 5 Dec 2019 13:39:01 +0300 Subject: [PATCH 3/6] set rcode for new controls --- instat/dlgBarAndPieChart.vb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 2369181e9a4..92aa0be876b 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -200,12 +200,14 @@ Public Class dlgBarAndPieChart Private Sub SetRCodeForControls(bReset As Boolean) ucrReceiverFirst.SetRCode(clsBarAesFunction, bReset) ucrReceiverFirst.AddAdditionalCodeParameterPair(clsPieAesFunction, New RParameter("fill", 0), iAdditionalPairNo:=1) + ucrReceiverY.SetRCode(clsBarAesFunction, bReset) ucrReceiverByFactor.SetRCode(clsBarAesFunction, bReset) ucrSaveBar.SetRCode(clsBaseOperator, bReset) ucrBarChartSelector.SetRCode(clsRggplotFunction, bReset) ucrPnlOptions.SetRCode(clsBaseOperator, bReset) ucrChkFlipCoordinates.SetRCode(clsBaseOperator, bReset) ucrInputBarChartPosition.SetRCode(clsRgeomBarFunction, bReset) + ucrInputYValue.SetRCode(clsRgeomBarFunction, bReset) End Sub Private Sub TestOkEnabled() From fbb31c2040d909cbb91a676dcd58b6665c54abce Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Thu, 5 Dec 2019 17:33:50 +0300 Subject: [PATCH 4/6] set conditions for ucrReceiverY --- instat/dlgBarAndPieChart.vb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 92aa0be876b..822a3bd7738 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.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 instat Imports instat.Translations Public Class dlgBarAndPieChart @@ -68,7 +69,7 @@ Public Class dlgBarAndPieChart ucrPnlOptions.AddRadioButton(rdoBarChart) ucrPnlOptions.AddRadioButton(rdoPieChart) ucrPnlOptions.AddParameterPresentCondition(rdoPieChart, "coord_polar") - ucrPnlOptions.AddParameterPresentCondition(rdoBarChart, "geom_bar") + ucrPnlOptions.AddParameterPresentCondition(rdoBarChart, "coord_polar", False) ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -76,12 +77,12 @@ Public Class dlgBarAndPieChart ucrInputBarChartPosition.SetLinkedDisplayControl(lblPosition) ucrPnlOptions.AddToLinkedControls({ucrReceiverByFactor}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverByFactor.SetLinkedDisplayControl(lblByFactor) - ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedDisabledIfParameterMissing:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverY.SetLinkedDisplayControl(lblYvariable) + ucrPnlOptions.AddToLinkedControls({ucrInputYValue}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrInputYValue.SetLinkedDisplayControl(lblYValue) - ucrBarChartSelector.SetParameter(New RParameter("data", 0)) ucrBarChartSelector.SetParameterIsrfunction() @@ -178,7 +179,7 @@ Public Class dlgBarAndPieChart clsRgeomBarFunction.SetPackageName("ggplot2") clsRgeomBarFunction.SetRCommand("geom_bar") clsRgeomBarFunction.AddParameter("position", Chr(34) & "dodge" & Chr(34), iPosition:=0) - clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=0) + clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1) clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() @@ -323,6 +324,21 @@ Public Class dlgBarAndPieChart SetDialogOptions() End Sub + Private Sub setColumnChartOption() + If ucrInputYValue.GetValue = "Column" Then + ucrReceiverY.Enabled = True + Else + ucrReceiverY.Enabled = False + ucrReceiverY.Clear() + clsRgeomBarFunction.RemoveParameterByName("y") + + End If + End Sub + + Private Sub ucrInputYValue_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputYValue.ControlValueChanged + setColumnChartOption() + End Sub + Private Sub CoreControls_ContentsChanged() Handles ucrReceiverFirst.ControlContentsChanged, ucrReceiverY.ControlContentsChanged, ucrSaveBar.ControlContentsChanged TestOkEnabled() End Sub From e28f00f829ee6c395f8067c33febe93d1ab40b98 Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Thu, 5 Dec 2019 22:28:32 +0300 Subject: [PATCH 5/6] set conditions for ok enables --- instat/dlgBarAndPieChart.vb | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 822a3bd7738..4a1491661ca 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -50,8 +50,10 @@ Public Class dlgBarAndPieChart SetDefaults() End If SetRCodeForControls(bReset) + bReset = False autoTranslate(Me) + changeLabel() 'TODO. this has been put here temporarily because there is a problem with the translation of the label TestOkEnabled() End Sub @@ -77,7 +79,7 @@ Public Class dlgBarAndPieChart ucrInputBarChartPosition.SetLinkedDisplayControl(lblPosition) ucrPnlOptions.AddToLinkedControls({ucrReceiverByFactor}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverByFactor.SetLinkedDisplayControl(lblByFactor) - ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedDisabledIfParameterMissing:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlOptions.AddToLinkedControls(ucrReceiverY, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrReceiverY.SetLinkedDisplayControl(lblYvariable) ucrPnlOptions.AddToLinkedControls({ucrInputYValue}, {rdoBarChart}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -213,10 +215,10 @@ Public Class dlgBarAndPieChart Private Sub TestOkEnabled() If rdoBarChart.Checked Then - If ucrReceiverFirst.IsEmpty OrElse Not ucrSaveBar.IsComplete Then - ucrBase.OKEnabled(False) - Else + If Not ucrReceiverFirst.IsEmpty AndAlso Not (ucrReceiverY.IsEmpty AndAlso ucrReceiverY.Visible) AndAlso ucrSaveBar.IsComplete Then ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) End If ElseIf rdoPieChart.Checked Then If ucrReceiverFirst.IsEmpty OrElse Not ucrSaveBar.IsComplete Then @@ -320,23 +322,31 @@ Public Class dlgBarAndPieChart End If End Sub + Private Sub changeLabel() + lblVariable.Text = If(rdoBarChart.Checked, "X Variable", "Variable") + End Sub + Private Sub ucrPnlOptions_ControlValueChanged() Handles ucrPnlOptions.ControlValueChanged SetDialogOptions() + changeLabel() + setColumnChartOption() + TestOkEnabled() + End Sub Private Sub setColumnChartOption() - If ucrInputYValue.GetValue = "Column" Then - ucrReceiverY.Enabled = True + If rdoBarChart.Checked AndAlso ucrInputYValue.GetValue = "Column" Then + ucrReceiverY.SetVisible(True) + ucrReceiverY.AddOrRemoveParameter(True) Else - ucrReceiverY.Enabled = False - ucrReceiverY.Clear() - clsRgeomBarFunction.RemoveParameterByName("y") - + ucrReceiverY.SetVisible(False) + ucrReceiverY.AddOrRemoveParameter(False) End If End Sub Private Sub ucrInputYValue_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputYValue.ControlValueChanged setColumnChartOption() + TestOkEnabled() End Sub Private Sub CoreControls_ContentsChanged() Handles ucrReceiverFirst.ControlContentsChanged, ucrReceiverY.ControlContentsChanged, ucrSaveBar.ControlContentsChanged From b3402a9b4f2933fde44326b56723038bb09dd54c Mon Sep 17 00:00:00 2001 From: Yvonne Achieng Date: Fri, 6 Dec 2019 10:54:47 +0300 Subject: [PATCH 6/6] minor edit --- instat/dlgBarAndPieChart.vb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 4a1491661ca..d0c8f4b170f 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -40,7 +40,6 @@ Public Class dlgBarAndPieChart Private clsCoordPolarFunction As New RFunction Private clsCoordPolarStartOperator As New ROperator - Private Sub cmdOptions_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then InitialiseDialog() @@ -53,7 +52,7 @@ Public Class dlgBarAndPieChart bReset = False autoTranslate(Me) - changeLabel() 'TODO. this has been put here temporarily because there is a problem with the translation of the label + ChangeLabel() 'TODO. this has been put here temporarily because there is a problem with the translation of the label TestOkEnabled() End Sub @@ -322,16 +321,15 @@ Public Class dlgBarAndPieChart End If End Sub - Private Sub changeLabel() + Private Sub ChangeLabel() lblVariable.Text = If(rdoBarChart.Checked, "X Variable", "Variable") End Sub Private Sub ucrPnlOptions_ControlValueChanged() Handles ucrPnlOptions.ControlValueChanged SetDialogOptions() - changeLabel() + ChangeLabel() setColumnChartOption() TestOkEnabled() - End Sub Private Sub setColumnChartOption()