From dde715d3cb87af3ea92102e58c51ba317979597f Mon Sep 17 00:00:00 2001 From: maxwell fundi Date: Fri, 28 Oct 2016 17:15:03 +0300 Subject: [PATCH] Additions of population Pyramid --- instat/dlgPopulationPyramids.Designer.vb | 16 ++++- instat/dlgPopulationPyramids.vb | 85 ++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 7 deletions(-) diff --git a/instat/dlgPopulationPyramids.Designer.vb b/instat/dlgPopulationPyramids.Designer.vb index 176a9d07fb4..39a8646c65b 100644 --- a/instat/dlgPopulationPyramids.Designer.vb +++ b/instat/dlgPopulationPyramids.Designer.vb @@ -30,17 +30,20 @@ Partial Class dlgPopulationPyramids Me.ucrYVariableReceiver = New instat.ucrReceiverSingle() Me.lblSecondFactor = New System.Windows.Forms.Label() Me.ucrSecondFactorReceiver = New instat.ucrReceiverSingle() + Me.ucrSavePopulationPyramid = New instat.ucrSaveGraph() Me.SuspendLayout() ' 'ucrBase ' - Me.ucrBase.Location = New System.Drawing.Point(10, 207) + Me.ucrBase.Location = New System.Drawing.Point(10, 244) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(410, 52) Me.ucrBase.TabIndex = 0 ' 'ucrPopulationPyramidselector ' + Me.ucrPopulationPyramidselector.bShowHiddenColumns = False + Me.ucrPopulationPyramidselector.bUseCurrentFilter = False Me.ucrPopulationPyramidselector.Location = New System.Drawing.Point(10, 10) Me.ucrPopulationPyramidselector.Margin = New System.Windows.Forms.Padding(0) Me.ucrPopulationPyramidselector.Name = "ucrPopulationPyramidselector" @@ -101,11 +104,19 @@ Partial Class dlgPopulationPyramids Me.ucrSecondFactorReceiver.Size = New System.Drawing.Size(120, 20) Me.ucrSecondFactorReceiver.TabIndex = 3 ' + 'ucrSavePopulationPyramid + ' + Me.ucrSavePopulationPyramid.Location = New System.Drawing.Point(10, 209) + Me.ucrSavePopulationPyramid.Name = "ucrSavePopulationPyramid" + Me.ucrSavePopulationPyramid.Size = New System.Drawing.Size(265, 20) + Me.ucrSavePopulationPyramid.TabIndex = 4 + ' 'dlgPopulationPyramids ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(419, 261) + Me.ClientSize = New System.Drawing.Size(421, 298) + Me.Controls.Add(Me.ucrSavePopulationPyramid) Me.Controls.Add(Me.ucrSecondFactorReceiver) Me.Controls.Add(Me.lblSecondFactor) Me.Controls.Add(Me.ucrYVariableReceiver) @@ -132,4 +143,5 @@ Partial Class dlgPopulationPyramids Friend WithEvents ucrYVariableReceiver As ucrReceiverSingle Friend WithEvents lblSecondFactor As Label Friend WithEvents ucrSecondFactorReceiver As ucrReceiverSingle + Friend WithEvents ucrSavePopulationPyramid As ucrSaveGraph End Class diff --git a/instat/dlgPopulationPyramids.vb b/instat/dlgPopulationPyramids.vb index b301bcf7a6a..d34b808c8c3 100644 --- a/instat/dlgPopulationPyramids.vb +++ b/instat/dlgPopulationPyramids.vb @@ -14,7 +14,12 @@ ' You should have received a copy of the GNU General Public License k ' along with this program. If not, see . Imports instat.Translations -Public Class dlgPopulationPyramids +Public Class dlgPopulationPyramids + Private clsRggplotFunction As New RFunction + Private clsRgeom_bar As New RFunction + Private clsRgeom_bar2 As New RFunction + Private clsRaesFunction As New RFunction + Private clsRgeom_CoordFlip As New RFunction Private bFirstLoad As Boolean = True Private Sub dlgPopulationPyramids_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then @@ -31,21 +36,91 @@ Public Class dlgPopulationPyramids Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 455 - + ucrBase.clsRsyntax.SetOperation("+") + clsRggplotFunction.SetRCommand("ggplot") + clsRaesFunction.SetRCommand("aes") + clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction) + ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction) + clsRgeom_bar.SetRCommand("geom_bar") + clsRgeom_bar.AddParameter("stat", Chr(34) & "identity" & Chr(34)) + ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_bar) + + clsRgeom_bar2.SetRCommand("geom_bar") + clsRgeom_bar2.AddParameter("stat", Chr(34) & "identity" & Chr(34)) + ucrBase.clsRsyntax.AddOperatorParameter("geom_bar", clsRFunc:=clsRgeom_bar) + + clsRgeom_CoordFlip.SetRCommand("coord_flip") + ucrBase.clsRsyntax.AddOperatorParameter("coord_flip", "coord_flip") + + ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False + + ucrXVariableReceiver.Selector = ucrPopulationPyramidselector + ucrYVariableReceiver.Selector = ucrPopulationPyramidselector + ucrSecondFactorReceiver.Selector = ucrPopulationPyramidselector + End Sub - Private Sub SetDefaults() - + Private Sub SetDefaults() + ucrPopulationPyramidselector.Reset() + ucrXVariableReceiver.SetMeAsReceiver() + TestOkEnabled() End Sub Private Sub ReopenDialog() End Sub Private Sub TestOkEnabled() + If (ucrXVariableReceiver.IsEmpty AndAlso ucrYVariableReceiver.IsEmpty) Then + ucrBase.OKEnabled(False) + Else + ucrBase.OKEnabled(True) + End If End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() - End Sub + End Sub + + Private Sub ucrPopulationPyramidselector_DataFrameChanged() Handles ucrPopulationPyramidselector.DataFrameChanged + clsRggplotFunction.AddParameter("data", clsRFunctionParameter:=ucrPopulationPyramidselector.ucrAvailableDataFrames.clsCurrDataFrame) + End Sub + Private Sub ucrXVariableReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrXVariableReceiver.SelectionChanged + If Not ucrXVariableReceiver.IsEmpty Then + clsRaesFunction.AddParameter("x", ucrXVariableReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("x") + End If + TestOkEnabled() + End Sub + + Private Sub ucrYVariableReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrYVariableReceiver.SelectionChanged + If Not ucrYVariableReceiver.IsEmpty Then + clsRaesFunction.AddParameter("y", ucrYVariableReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("y") + End If + TestOkEnabled() + End Sub + + Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged + If Not ucrSecondFactorReceiver.IsEmpty Then + clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("fill") + End If + End Sub + + Private Sub ucrSavePopulationPyramid_ContentsChanged() Handles ucrSavePopulationPyramid.ContentsChanged + TestOkEnabled() + End Sub + + Private Sub ucrSavePopulationPyramid_GraphNameChanged() Handles ucrSavePopulationPyramid.GraphNameChanged, ucrSavePopulationPyramid.SaveGraphCheckedChanged + If ucrSavePopulationPyramid.bSaveGraph Then + ucrBase.clsRsyntax.SetAssignTo(ucrSavePopulationPyramid.strGraphName, strTempDataframe:=ucrPopulationPyramidselector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:=ucrSavePopulationPyramid.strGraphName) + Else + ucrBase.clsRsyntax.SetAssignTo("last_graph", strTempDataframe:=ucrPopulationPyramidselector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph") + End If + TestOkEnabled() + End Sub End Class \ No newline at end of file