* UILineChart: 增加PointFormat,鼠标选中值显示格式化事件

This commit is contained in:
Sunny 2023-07-02 19:50:10 +08:00
parent b68415a152
commit 43d3369365

View File

@ -45,6 +45,7 @@
* 2023-05-12: V3.3.6 线
* 2023-05-14: V3.3.6 DrawString函数
* 2023-06-06: V3.3.7 X轴文字重叠问题
* 2024-07-02: V3.3.9 PointFormat
******************************************************************************/
using System;
@ -854,18 +855,17 @@ namespace Sunny.UI
if (idx > 0) sb.Append('\n');
if (PointFormat != null)
{
sb.Append(PointFormat(this, point));
}
else
{
sb.Append(point.Series.Name);
sb.Append('\n');
sb.Append(Option.XAxis.Name + ": ");
string customlabel = "";
//if (Option.XAxis.HaveCustomLabels)
//{
// int ci = (int)((point.X - Option.XAxis.CustomLabels.Start) / Option.XAxis.CustomLabels.Interval);
// customlabel = Option.XAxis.CustomLabels.GetLabel(ci);
// sb.Append(customlabel);
//}
if (customlabel.IsNullOrEmpty())
{
if (Option.XAxisType == UIAxisType.DateTime)
@ -880,6 +880,7 @@ namespace Sunny.UI
sb.Append(Option.Y2Axis.Name + ": " + point.Y.ToString(point.Series.YAxisDecimalPlaces >= 0 ? "F" + point.Series.YAxisDecimalPlaces : Y2Scale.Format));
else
sb.Append(Option.YAxis.Name + ": " + point.Y.ToString(point.Series.YAxisDecimalPlaces >= 0 ? "F" + point.Series.YAxisDecimalPlaces : YScale.Format));
}
idx++;
}
@ -913,9 +914,12 @@ namespace Sunny.UI
}
}
if (selectPoints.Count > 0)
{
PointValue?.Invoke(this, selectPoints.ToArray());
}
}
}
else
{
if (MouseZoom && e.Button == MouseButtons.Left && e.X > Option.Grid.Left && e.X < Width - Option.Grid.Right &&
@ -929,8 +933,12 @@ namespace Sunny.UI
public delegate void OnPointValue(object sender, UILineSelectPoint[] points);
public delegate string OnPointFormat(object sender, UILineSelectPoint point);
public event OnPointValue PointValue;
public event OnPointFormat PointFormat;
private bool IsMouseDown;
private Point StartPoint, StopPoint;