Skip to content

Commit

Permalink
Merge pull request #119 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
getting latest version
  • Loading branch information
Lunalo authored Jun 9, 2017
2 parents 449799e + f24ff5d commit 953603b
Show file tree
Hide file tree
Showing 78 changed files with 5,433 additions and 1,851 deletions.
205 changes: 120 additions & 85 deletions instat/UcrGeomListWithAes.designer.vb

Large diffs are not rendered by default.

398 changes: 247 additions & 151 deletions instat/UcrGeomListWithAes.vb

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion instat/UcrPanel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Public Class UcrPanel

Protected Overrides Sub SetToValue(objTemp As Object)
Dim rdoTemp As RadioButton

If objTemp IsNot Nothing Then
If TypeOf objTemp Is RadioButton Then
rdoTemp = DirectCast(objTemp, RadioButton)
Expand All @@ -86,7 +87,10 @@ Public Class UcrPanel
End If
Else
'If no value reset to a default value
dctRadioButtonValues.Keys(0).Checked = True
If pnlRadios.Controls.Count > 0 AndAlso TypeOf pnlRadios.Controls(0) Is RadioButton Then
rdoTemp = DirectCast(pnlRadios.Controls(0), RadioButton)
rdoTemp.Checked = True
End If
End If
End Sub

Expand Down
212 changes: 210 additions & 2 deletions instat/clsGgplotDefaults.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
End Get
End Property

Public Shared ReadOnly Property clsDefaultTheme As RParameter
Public Shared ReadOnly Property clsDefaultThemeParameter As RParameter
Get
Dim clsTempParam As New RParameter

Expand Down Expand Up @@ -79,4 +79,212 @@
Return clsFacetTempFunc
End Get
End Property
End Class

Public Shared ReadOnly Property dctThemeFunctions As Dictionary(Of String, RFunction)
Get
Dim dctTemp As New Dictionary(Of String, RFunction)
Dim clsElementText As RFunction
Dim clsElementLine As RFunction
Dim clsElementRect As RFunction

Dim clsUnit As RFunction

clsElementText = New RFunction
clsElementLine = New RFunction
clsElementRect = New RFunction
clsElementRect = New RFunction

clsUnit = New RFunction

clsUnit.SetPackageName("grid")
clsElementText.SetPackageName("ggplot2")
clsElementLine.SetPackageName("ggplot2")
clsElementRect.SetPackageName("ggplot2")
clsElementText.SetRCommand("element_text")
clsElementLine.SetRCommand("element_line")
clsElementRect.SetRCommand("element_rect")
clsUnit.SetRCommand("unit")

dctTemp.Add("line", clsElementLine.Clone())
dctTemp.Add("rect", clsElementRect.Clone())
dctTemp.Add("text", clsElementText.Clone())
dctTemp.Add("title", clsElementText.Clone())
'dctTemp.Add("aspect.ratio", clsElementText.Clone())
dctTemp.Add("axis.title", clsElementText.Clone())
dctTemp.Add("axis.title.x", clsElementText.Clone())
dctTemp.Add("axis.title.x.top", clsElementText.Clone())
dctTemp.Add("axis.title.y", clsElementText.Clone())
dctTemp.Add("axis.title.y.right", clsElementText.Clone())
dctTemp.Add("axis.text", clsElementText.Clone())
dctTemp.Add("axis.text.x", clsElementText.Clone())
dctTemp.Add("axis.text.x.top", clsElementText.Clone())
dctTemp.Add("axis.text.y", clsElementText.Clone())
dctTemp.Add("axis.text.y.right", clsElementText.Clone())
dctTemp.Add("axis.ticks", clsElementLine.Clone())
dctTemp.Add("axis.ticks.x", clsElementLine.Clone())
dctTemp.Add("axis.ticks.y", clsElementLine.Clone())
dctTemp.Add("axis.ticks.length", clsUnit.Clone())
dctTemp.Add("axis.line", clsElementLine.Clone())
dctTemp.Add("axis.line.x", clsElementLine.Clone())
dctTemp.Add("axis.line.y", clsElementLine.Clone())
dctTemp.Add("legend.background", clsElementRect.Clone())
' dctTemp.Add("legend.margin", clsElementLine.Clone())
dctTemp.Add("legend.spacing", clsUnit.Clone())
dctTemp.Add("legend.spacing.x", clsUnit.Clone())
dctTemp.Add("legend.spacing.y", clsUnit.Clone())
dctTemp.Add("legend.key", clsElementRect.Clone())
dctTemp.Add("legend.key.size", clsUnit.Clone())
dctTemp.Add("legend.key.height", clsUnit.Clone())
dctTemp.Add("legend.key.width", clsUnit.Clone())
dctTemp.Add("legend.text", clsElementText.Clone())
'dctTemp.Add("legend.text.align", clsElementText.Clone())
dctTemp.Add("legend.title", clsElementText.Clone())
'dctTemp.Add("legend.title.align", clsElementText.Clone())

'dctTemp.Add("legend.box.margin", clsElementText.Clone())
dctTemp.Add("legend.box.background", clsElementRect.Clone())
'dctTemp.Add("legend.box.spacing", clsElementText.Clone())
dctTemp.Add("panel.background", clsElementRect.Clone())
dctTemp.Add("panel.border", clsElementRect.Clone())
dctTemp.Add("panel.spacing", clsUnit.Clone())
dctTemp.Add("panel.spacing.x", clsUnit.Clone())
dctTemp.Add("panel.spacing.y", clsUnit.Clone())
dctTemp.Add("panel.grid", clsElementLine.Clone())
dctTemp.Add("panel.grid.major", clsElementLine.Clone())
dctTemp.Add("panel.grid.minor", clsElementLine.Clone())
dctTemp.Add("panel.grid.major.x", clsElementLine.Clone())
dctTemp.Add("panel.grid.major.y", clsElementLine.Clone())
dctTemp.Add("panel.grid.minor.x", clsElementLine.Clone())
dctTemp.Add("panel.grid.minor.y", clsElementLine.Clone())
'dctTemp.Add("Panel.ontop", clsElementRect.Clone())
dctTemp.Add("plot.background", clsElementRect.Clone())
dctTemp.Add("plot.title", clsElementText.Clone())
dctTemp.Add("plot.subtitle", clsElementText.Clone())
dctTemp.Add("plot.caption", clsElementText.Clone())
dctTemp.Add("plot.margin", clsUnit.Clone())
dctTemp.Add("strip.background", clsElementRect.Clone())
' dctTemp.Add("strip.placement", clsElementLine.Clone())
dctTemp.Add("strip.text", clsElementText.Clone())
dctTemp.Add("strip.text.x", clsElementText.Clone())
dctTemp.Add("strip.text.y", clsElementText.Clone())
dctTemp.Add("strip.switch.pad.grid", clsUnit.Clone())
dctTemp.Add("strip.switch.pad.wrap", clsUnit.Clone())
Return dctTemp
End Get
End Property

Public Shared ReadOnly Property dctFonts As Dictionary(Of String, String)
Get
Dim dctTemp As New Dictionary(Of String, String)
dctTemp.Add("Times Roman", Chr(34) & "Times" & Chr(34))
dctTemp.Add("Courier", Chr(34) & "Courier" & Chr(34))
dctTemp.Add("Couriersans", Chr(34) & "Couriersans" & Chr(34))
dctTemp.Add("Serif", Chr(34) & "serif" & Chr(34))
dctTemp.Add("NimbusSanCond", Chr(34) & "NimbusSanCond" & Chr(34))
dctTemp.Add("CenturySch", Chr(34) & "CenturySch" & Chr(34))
dctTemp.Add("NewCenturySchoolbook", Chr(34) & "NewCenturySchoolbook" & Chr(34))
dctTemp.Add("Palatino", Chr(34) & "Palatino" & Chr(34))
dctTemp.Add("Bookman", Chr(34) & "Bookman" & Chr(34))
dctTemp.Add("URWBookman", Chr(34) & "URWBookman" & Chr(34))
dctTemp.Add("URWGothic", Chr(34) & "URWGothic" & Chr(34))
dctTemp.Add("NimbusRom", Chr(34) & "NimbusRom" & Chr(34))
dctTemp.Add("URWPalladioURWTimes", Chr(34) & "URWPalladioURWTimes" & Chr(34))
dctTemp.Add("NimbusMonURWHelvetica", Chr(34) & "NimbusMonURWHelvetica" & Chr(34))
dctTemp.Add("Helvetica - Narrow", Chr(34) & "Helvetica - Narrow" & Chr(34))
dctTemp.Add("Helveticaserif", Chr(34) & "Helveticaserif" & Chr(34))
dctTemp.Add("Short", Chr(34) & "Short" & Chr(34))
dctTemp.Add("Canonicalmono", Chr(34) & "Canonicalmono" & Chr(34))
dctTemp.Add("AvantGarde", Chr(34) & "AvantGarde" & Chr(34))

Return dctTemp
End Get
End Property

Public Shared ReadOnly Property dctFontFace As Dictionary(Of String, String)
Get
Dim dctTempFontFace As New Dictionary(Of String, String)
dctTempFontFace.Add("Plain", Chr(34) & "plain" & Chr(34))
dctTempFontFace.Add("Bold", Chr(34) & "bold" & Chr(34))
dctTempFontFace.Add("Italic", Chr(34) & "italic" & Chr(34))
dctTempFontFace.Add("Bold italic", Chr(34) & "bold.italic" & Chr(34))
Return dctTempFontFace
End Get
End Property

Public Shared ReadOnly Property dctColour As Dictionary(Of String, String)
Get
Dim dctTempColour As New Dictionary(Of String, String)
dctTempColour.Add("Black", Chr(34) & "black" & Chr(34))
dctTempColour.Add("Red", Chr(34) & "red" & Chr(34))
dctTempColour.Add("Blue", Chr(34) & "blue" & Chr(34))
dctTempColour.Add("Grey", Chr(34) & "grey" & Chr(34))
dctTempColour.Add("Yellow", Chr(34) & "yellow" & Chr(34))
dctTempColour.Add("Yellow-Green", Chr(34) & "yellowgreen" & Chr(34))
Return dctTempColour
End Get
End Property

Public Shared ReadOnly Property dctLineType As Dictionary(Of String, String)
Get
Dim dctTempLineType As New Dictionary(Of String, String)
dctTempLineType.Add("Blank", Chr(34) & "blank" & Chr(34))
dctTempLineType.Add("Solid", Chr(34) & "solid" & Chr(34))
dctTempLineType.Add("Dashed", Chr(34) & "dashed" & Chr(34))
dctTempLineType.Add("Dotted", Chr(34) & "dotted" & Chr(34))
dctTempLineType.Add("Dot-dash", Chr(34) & "dotdash" & Chr(34))
dctTempLineType.Add("Long-dash", Chr(34) & "longdash" & Chr(34))
dctTempLineType.Add("Two-Dash", Chr(34) & "twodash" & Chr(34))
dctTempLineType.Add("1F", Chr(34) & "1F" & Chr(34))
dctTempLineType.Add("F1", Chr(34) & "F1" & Chr(34))
dctTempLineType.Add("4C88C488", Chr(34) & "4C88C488" & Chr(34))
dctTempLineType.Add("12345678", Chr(34) & "12345678" & Chr(34))
Return dctTempLineType
End Get
End Property

Public Shared ReadOnly Property dctLineEnd As Dictionary(Of String, String)
Get
Dim dctTempLineEnd As New Dictionary(Of String, String)
dctTempLineEnd.Add("None", Chr(34) & "NULL" & Chr(34))
dctTempLineEnd.Add("round", Chr(34) & "round" & Chr(34))
dctTempLineEnd.Add("butt", Chr(34) & "butt" & Chr(34))
dctTempLineEnd.Add("square", Chr(34) & "square" & Chr(34))
Return dctTempLineEnd
End Get
End Property

Public Shared ReadOnly Property dctUnits As Dictionary(Of String, String)
Get
Dim dctTempUnits As New Dictionary(Of String, String)
dctTempUnits.Add("Normalised Parent Coordinates", Chr(34) & "npc" & Chr(34))
dctTempUnits.Add("Centimetres", Chr(34) & "cm" & Chr(34))
dctTempUnits.Add("Inches", Chr(34) & "inches" & Chr(34))
dctTempUnits.Add("Millimetres", Chr(34) & "mm" & Chr(34))
dctTempUnits.Add("Points", Chr(34) & "points" & Chr(34))
dctTempUnits.Add("Picas", Chr(34) & "picas" & Chr(34))
dctTempUnits.Add("Big Points", Chr(34) & "bigpts" & Chr(34))
dctTempUnits.Add("Dida", Chr(34) & "dida" & Chr(34))
dctTempUnits.Add("Cicero", Chr(34) & "cicero" & Chr(34))
dctTempUnits.Add("Scaled Points", Chr(34) & "scaledpts" & Chr(34))
dctTempUnits.Add("Lines", Chr(34) & "lines" & Chr(34))
dctTempUnits.Add("Character", Chr(34) & "char" & Chr(34))
dctTempUnits.Add("Native", Chr(34) & "native" & Chr(34))
dctTempUnits.Add("String Width", Chr(34) & "strwidth" & Chr(34))
dctTempUnits.Add("String Height", Chr(34) & "strheight" & Chr(34))
dctTempUnits.Add("Square Normalised Parent Coordinates", Chr(34) & "snpc" & Chr(34))
dctTempUnits.Add("Grop Height", Chr(34) & "grobheight" & Chr(34))
dctTempUnits.Add("Grop Width", Chr(34) & "grobwidth" & Chr(34))
Return dctTempUnits
End Get
End Property
Public Shared ReadOnly Property clsDefaultThemeFunction As RFunction
Get
Dim clsTempFunc As New RFunction

clsTempFunc.SetPackageName("ggplot2")
clsTempFunc.SetRCommand("theme")

Return clsTempFunc
End Get
End Property
End Class
2 changes: 2 additions & 0 deletions instat/clsRFunction.vb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Public Class RFunction

Dim clsRFunction As New RFunction
Dim clsRParam As RParameter

clsRFunction.strPackageName = strPackageName
clsRFunction.strRCommand = strRCommand
clsRFunction.strAssignTo = strAssignTo
clsRFunction.strAssignToDataFrame = strAssignToDataFrame
Expand Down
1 change: 1 addition & 0 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ Public Class RLink
Try
If iCallType = 3 Then
If strGraphDisplayOption = "view_output_window" OrElse strGraphDisplayOption = "view_separate_window" Then
clsPNGFunction.SetPackageName("grDevices")
clsPNGFunction.SetRCommand("png")
clsPNGFunction.AddParameter("filename", Chr(34) & System.IO.Path.Combine(strTempGraphsDirectory & "/Graph.png").Replace("\", "/") & Chr(34))
clsPNGFunction.AddParameter("width", 4000)
Expand Down
1 change: 1 addition & 0 deletions instat/dlgAppend.vb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Public Class dlgAppend
ucrSelectorDataframes.Reset()
ucrSaveGraph.Reset()

clsBindRows.SetPackageName("dplyr")
clsBindRows.SetRCommand("bind_rows")
clsBindRows.AddParameter(".id", Chr(34) & "id" & Chr(34))
clsBindRows.SetAssignTo(ucrSaveGraph.GetText(), strTempDataframe:=ucrSaveGraph.GetText())
Expand Down
15 changes: 9 additions & 6 deletions instat/dlgBarAndPieChart.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Public Class dlgBarAndPieChart
Private clsYlabFunction As New RFunction
Private clsXScalecontinuousFunction As New RFunction
Private clsRFacetFunction As New RFunction

Private clsThemeFuction As New RFunction
Private dctThemeFunctions As New Dictionary(Of String, RFunction)
Private bReset As Boolean = True
Private bFirstLoad As Boolean = True
Private bResetSubdialog As Boolean = True
Expand Down Expand Up @@ -162,8 +163,9 @@ Public Class dlgBarAndPieChart
clsYlabFunction = GgplotDefaults.clsYlabTitleFunction.Clone()
clsXScalecontinuousFunction = GgplotDefaults.clsXScalecontinuousFunction.Clone()
clsRFacetFunction = GgplotDefaults.clsFacetFunction.Clone()
clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultTheme.Clone())

clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone())
clsThemeFuction = GgplotDefaults.clsDefaultThemeFunction.Clone
dctThemeFunctions = New Dictionary(Of String, RFunction)(GgplotDefaults.dctThemeFunctions)
clsBaseOperator.SetAssignTo("last_graph", strTempDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph")
ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator)
End Sub
Expand Down Expand Up @@ -197,15 +199,16 @@ Public Class dlgBarAndPieChart
End Sub

Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.SetRCode(clsBaseOperator, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewXLabsTitleFunction:=clsXlabFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, strNewDataFrame:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bReset:=bResetSubdialog)
sdgPlots.SetRCode(clsNewOperator:=clsBaseOperator, clsNewThemeFunction:=clsThemeFuction, dctNewThemeFunctions:=dctThemeFunctions, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewXLabsTitleFunction:=clsXlabFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, strNewDataFrame:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bReset:=bResetSubdialog)
'sdgPlots.SetDataFrame(strNewDataFrame:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
sdgPlots.ShowDialog()
bResetSubdialog = False
'Warning, when coordinate flip is added to coordinates tab on sdgPLots, then link with ucrChkFlipCoordinates...
End Sub

Private Sub cmdBarChartOptions_Click(sender As Object, e As EventArgs) Handles cmdBarChartOptions.Click
sdgLayerOptions.SetupLayer(clsTempGgPlot:=clsRggplotFunction, clsTempGeomFunc:=clsRgeomBarFunction, clsTempAesFunc:=clsBarAesFunction, bFixAes:=True, bFixGeom:=True, strDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bApplyAesGlobally:=True, bIgnoreGlobalAes:=False)
'What should global and local aes be?
sdgLayerOptions.SetupLayer(clsNewGgPlot:=clsRggplotFunction, clsNewGeomFunc:=clsRgeomBarFunction, clsNewGlobalAesFunc:=clsBarAesFunction, clsNewLocalAes:=clsBarAesFunction, bFixGeom:=True, strDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bApplyAesGlobally:=True)
sdgLayerOptions.ShowDialog()
For Each clsParam In clsBarAesFunction.clsParameters
If clsParam.strArgumentName = "x" Then
Expand All @@ -218,7 +221,7 @@ Public Class dlgBarAndPieChart
End Sub

Private Sub cmdPieChartOptions_Click(sender As Object, e As EventArgs) Handles cmdPieChartOptions.Click
sdgLayerOptions.SetupLayer(clsTempGgPlot:=clsRggplotFunction, clsTempGeomFunc:=clsRgeomBarFunction, clsTempAesFunc:=clsPieAesFunction, bFixAes:=True, bFixGeom:=True, strDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bApplyAesGlobally:=True)
'sdgLayerOptions.SetupLayer(clsTempGgPlot:=clsRggplotFunction, clsTempGeomFunc:=clsRgeomBarFunction, clsTempAesFunc:=clsPieAesFunction, bFixAes:=True, bFixGeom:=True, strDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bApplyAesGlobally:=True)
sdgLayerOptions.ShowDialog()
For Each clsParam In clsPieAesFunction.clsParameters
If clsParam.strArgumentName = "x" Then
Expand Down
Loading

0 comments on commit 953603b

Please sign in to comment.