Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/rsharp-lang/ggplot
Browse files Browse the repository at this point in the history
  • Loading branch information
xieguigang committed Dec 21, 2024
2 parents 3420955 + 618c9ee commit dc503c6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/ggplot/Internal/ggplot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ Public Class ggplot : Inherits Plot
End Sub

Private Sub DrawMultiple(all As IggplotLegendElement(), g As IGraphics, canvas As GraphicsRegion, pos As PointF)
Dim width As Double = canvas.Padding.Right / (all.Length + 1)
Dim css As CSSEnvirnment = g.LoadEnvironment
Dim box As Rectangle = canvas.PlotRegion(css)
Dim padding As PaddingLayout = PaddingLayout.EvaluateFromCSS(CSS, canvas.Padding)
Dim width As Double = padding.Right / (all.Length + 1)
Dim box As Rectangle = canvas.PlotRegion(CSS)
Dim x As Double
Dim y As Double

Expand Down
3 changes: 2 additions & 1 deletion src/ggplot/Internal/layers/ggplotLayer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Namespace layers
Dim padding As New GraphicsRegion(g.Size, theme.padding)
Dim legend As ColorMapLegend
Dim css As CSSEnvirnment = g.LoadEnvironment
Dim margin As PaddingLayout = PaddingLayout.EvaluateFromCSS(css, theme.padding)

If TypeOf colorMap Is ggplotColorPalette Then
legend = New ColorMapLegend(DirectCast(palette.colorMap, String), maplevels)
Expand All @@ -161,7 +162,7 @@ Namespace layers

legends = New legendColorMapElement With {
.colorMapLegend = legend,
.width = padding.Padding.Right * 3 / 4,
.width = margin.Right * 3 / 4,
.height = padding.PlotRegion(css).Height
}

Expand Down
5 changes: 3 additions & 2 deletions src/ggplot/Internal/layers/groupPlot/ggplotPie.vb
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ Namespace layers
End Function) _
.ToArray
Dim css As CSSEnvirnment = stream.g.LoadEnvironment
Dim padding As PaddingLayout = PaddingLayout.EvaluateFromCSS(css, stream.canvas.Padding)
Dim labelFont As Font = css.GetFont(CSSFont.TryParse(stream.theme.tagCSS))
Dim plotRegion As Rectangle = stream.canvas.PlotRegion(css)
Dim r As Single = std.Min(plotRegion.Height, plotRegion.Width) / 2
Dim topLeft As New Point With {
.X = stream.canvas.Padding.Left,
.Y = stream.canvas.Padding.Top
.X = padding.Left,
.Y = padding.Top
}

Call stream.g.PlotPie(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,12 @@ Namespace layers
Call base.cat(anova.ToString, env:=stream.ggplot.environment)

Dim css As CSSEnvirnment = stream.g.LoadEnvironment
Dim padding As PaddingLayout = PaddingLayout.EvaluateFromCSS(css, stream.canvas.Padding)
Dim pvalue As Double = anova.singlePvalue
Dim ptag As String = If(pvalue.ToString = "0", "<1e-100", "=" & pvalue.ToString("G3"))
Dim tagStr As String = $"ANOVA, p-value{ptag}"
Dim font As Font = css.GetFont(CSSFont.TryParse(stream.theme.tagCSS))
Dim pos As New PointF(stream.scale.X.rangeMin + 10, stream.canvas.Padding.Top)
Dim pos As New PointF(stream.scale.X.rangeMin + 10, padding.Top)

Call stream.g.DrawString(tagStr, font, Brushes.Black, pos)
End Sub
Expand Down
4 changes: 3 additions & 1 deletion src/ggplot/Internal/layers/scatter/ggplotScatterheatmap.vb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Namespace layers
Call stream.g.FillRectangle(colors(layerIndex(i)), cell)
Next

Dim padding As PaddingLayout = PaddingLayout.EvaluateFromCSS(css, stream.canvas.Padding)

Return New legendColorMapElement With {
.colorMapLegend = New ColorMapLegend(stream.theme.colorSet, maplevels) With {
.title = Me.layer,
Expand All @@ -147,7 +149,7 @@ Namespace layers
.ticks = layerdata.CreateAxisTicks,
.titleFont = css.GetFont(CSSFont.TryParse(stream.theme.legendTitleCSS))
},
.width = stream.canvas.Padding.Right * 3 / 4,
.width = padding.Right * 3 / 4,
.height = stream.canvas.PlotRegion(css).Height
}
End Function
Expand Down
3 changes: 2 additions & 1 deletion src/ggplot/Internal/layers/scatter/ggplotTileLayer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Namespace layers
Dim textures As Brush() = colors.Select(Function(c) c.GetBrush).ToArray
Dim rxi, ryi As Double
Dim css As CSSEnvirnment = stream.g.LoadEnvironment
Dim padding As PaddingLayout = PaddingLayout.EvaluateFromCSS(css, stream.canvas.Padding)

For i As Integer = 0 To x.Length - 1
rxi = stream.scale.TranslateX(x(i)) - tile_size.Width
Expand All @@ -158,7 +159,7 @@ Namespace layers
.ticks = fillData.CreateAxisTicks,
.titleFont = css.GetFont(stream.theme.legendTitleCSS)
},
.width = stream.canvas.Padding.Right * 3 / 4,
.width = padding.Right * 3 / 4,
.height = stream.canvas.PlotRegion(css).Height
}
End Function
Expand Down

0 comments on commit dc503c6

Please sign in to comment.