* UILineChart: 修复X轴文字重叠问题

This commit is contained in:
Sunny 2023-06-06 22:10:32 +08:00
parent 184bf0ca8b
commit ce7cbd9e11

View File

@ -44,6 +44,7 @@
* 2023-04-23: V3.3.5 Smooth绘制
* 2023-05-12: V3.3.6 线
* 2023-05-14: V3.3.6 DrawString函数
* 2023-06-06: V3.3.7 X轴文字重叠问题
******************************************************************************/
using System;
@ -339,10 +340,11 @@ namespace Sunny.UI
label = Option.XAxis.CustomLabels.GetLabel(i);
}
Size sf = TextRenderer.MeasureText(label, TempFont);
SizeF sf = TextRenderer.MeasureText(label, TempFont);
float xx = x - sf.Width / 2.0f;
if (xx > xr && xx + sf.Width < Width)
{
xr = xx + sf.Width;
g.DrawString(label, TempFont, ForeColor, new Rectangle((int)x - Width, DrawOrigin.Y + Option.XAxis.AxisTick.Length, Width * 2, Height), ContentAlignment.TopCenter);
}
}