第一条曲线,标记最大最小点和平均线

This commit is contained in:
智能大石头 2025-07-25 17:11:15 +08:00
parent 7e8c2715ed
commit 3e2fc9bc32
2 changed files with 18 additions and 3 deletions

View File

@ -177,7 +177,6 @@ public class ECharts : IExtend
public YAxis SetY(String name, String type = "value")
{
var axis = new YAxis { Name = name, Type = type };
if (type == "value") axis.Min = "dataMin";
YAxis.Add(axis);
return axis;
}
@ -195,7 +194,6 @@ public class ECharts : IExtend
public YAxis SetY(String name, String type, String formatter)
{
var axis = new YAxis { Name = name, Type = type, AxisLabel = new { formatter } };
if (type == "value") axis.Min = "dataMin";
YAxis.Add(axis);
return axis;
}

View File

@ -968,13 +968,30 @@ public partial class ReadOnlyEntityController<TEntity> : ControllerBaseX where T
}
}
chart.Add(data, yFields, seriesType);
var ss = chart.Add(data, yFields, seriesType);
// 第一条曲线,标记最大最小点和平均线
if (ss != null && ss.Count > 0 && seriesType == SeriesTypes.Line)
{
if (ss[0] is SeriesLine line)
{
line.SetMarkLine(true);
line.SetMarkPoint(true, true);
}
}
// 如果没有Y轴自动补上
if (yFields.Length > 0 && (chart.YAxis == null || chart.YAxis.Count == 0))
chart.SetY(yFields[0].Name, "value");
}
// Y轴最小值自动使用数据最小值
var axis = chart.YAxis.FirstOrDefault();
if (axis != null)
{
if (axis.Type == "value") axis.Min = "dataMin";
}
if (seriesType == SeriesTypes.Pie)
chart.SetTooltip("item", null, null);
else