* UIBarChart: 增加了一个快捷的显示数据函数ShowData

This commit is contained in:
Sunny 2024-10-25 10:44:56 +08:00
parent 49c9419590
commit 2d98153089

View File

@ -31,7 +31,8 @@
* 2023-05-13: V3.3.6 Option.BarInterval,Bar之间间隔-1
* 2023-05-14: V3.3.6 DrawString函数
* 2023-06-06: V3.3.7 Y轴文字居中
* 2025-06-08: V3.6.6 X轴文字带角度显示时居中
* 2024-06-08: V3.6.6 X轴文字带角度显示时居中
* 2024-10-25: V3.7.2 ShowData
******************************************************************************/
using System;
@ -646,5 +647,23 @@ namespace Sunny.UI
public UIBarSeries Series { get; set; }
}
public void ShowData(string[] labels, double[] values, string title = "")
{
int len = Math.Min(labels.Length, values.Length);
if (len == 0) return;
UIBarOption option = new UIBarOption();
option.Title.Text = title;
var series = new UIBarSeries();
for (int i = 0; i < len; i++)
{
option.XAxis.Data.Add(labels[i]);
series.AddData(values[i]);
}
option.Series.Add(series);
SetOption(option);
}
}
}