* 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,32 +855,32 @@ namespace Sunny.UI
if (idx > 0) sb.Append('\n');
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 (PointFormat != null)
{
if (Option.XAxisType == UIAxisType.DateTime)
sb.Append(new DateTimeInt64(point.X).ToString(point.Series.XAxisDateTimeFormat.IsValid() ? point.Series.XAxisDateTimeFormat : XScale.Format));
else
sb.Append(point.X.ToString(point.Series.XAxisDecimalPlaces >= 0 ? "F" + point.Series.XAxisDecimalPlaces : XScale.Format));
sb.Append(PointFormat(this, point));
}
sb.Append('\n');
if (point.Series.IsY2)
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));
{
sb.Append(point.Series.Name);
sb.Append('\n');
sb.Append(Option.XAxis.Name + ": ");
string customlabel = "";
if (customlabel.IsNullOrEmpty())
{
if (Option.XAxisType == UIAxisType.DateTime)
sb.Append(new DateTimeInt64(point.X).ToString(point.Series.XAxisDateTimeFormat.IsValid() ? point.Series.XAxisDateTimeFormat : XScale.Format));
else
sb.Append(point.X.ToString(point.Series.XAxisDecimalPlaces >= 0 ? "F" + point.Series.XAxisDecimalPlaces : XScale.Format));
}
sb.Append('\n');
if (point.Series.IsY2)
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,7 +914,10 @@ namespace Sunny.UI
}
}
PointValue?.Invoke(this, selectPoints.ToArray());
if (selectPoints.Count > 0)
{
PointValue?.Invoke(this, selectPoints.ToArray());
}
}
}
else
@ -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;