From 4cf7239d076a5cfc649e788067cf024bddb5f7a5 Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 4 Oct 2023 12:08:17 +0800 Subject: [PATCH] =?UTF-8?q?*=20UILineChart:=20=E5=A2=9E=E5=8A=A0=E4=BA=86Y?= =?UTF-8?q?=E8=BD=B4=E6=95=B0=E6=8D=AE=E7=94=B1=E4=B8=8A=E5=90=91=E4=B8=8B?= =?UTF-8?q?=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Charts/UILineChart.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SunnyUI/Charts/UILineChart.cs b/SunnyUI/Charts/UILineChart.cs index 6eb7dc73..e5c21e76 100644 --- a/SunnyUI/Charts/UILineChart.cs +++ b/SunnyUI/Charts/UILineChart.cs @@ -820,6 +820,8 @@ namespace Sunny.UI } int idx = 0; + float xmin = -9999; + float ymin = Option.Grid.Top + 4; if (XScale != null) { foreach (var line in Option.XAxisScaleLines) @@ -835,19 +837,25 @@ namespace Sunny.UI pn.DashPattern = new float[] { 3, 3 }; } - g.DrawLine(pn, pos, DrawOrigin.Y - 1, pos, Option.Grid.Top + 1); + g.DrawLine(pn, pos, Height - Option.Grid.Bottom - 1, pos, Option.Grid.Top + 1); } Size sf = TextRenderer.MeasureText(line.Name, TempFont); float x = pos - sf.Width; if (x < Option.Grid.Left) x = pos + 2; - float y = Option.Grid.Top + 4 + sf.Height * idx; + float y; + if (x > xmin) + y = ymin; + else + y = ymin + sf.Height; + if (y > Height - Option.Grid.Bottom) { - idx = 0; - y = Option.Grid.Top + 4 + sf.Height * idx; + y = Option.Grid.Top + 4; } + xmin = x + sf.Width; + ymin = y; idx++; g.DrawString(line.Name, TempFont, line.Color, new Rectangle((int)x, (int)y, Width, Height), ContentAlignment.TopLeft); }