* UIPieOption, UIDoughnutOption, UIBarOption, UILineOption: 增加了一些为空的判断
This commit is contained in:
parent
e217e0ce32
commit
27ea7d7d99
@ -87,6 +87,16 @@ namespace Sunny.UI
|
||||
|
||||
public void AddSeries(UIBarSeries series)
|
||||
{
|
||||
if (series == null)
|
||||
{
|
||||
throw new NullReferenceException("series 不能为空");
|
||||
}
|
||||
|
||||
if (series.Name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("series.Name 不能为空");
|
||||
}
|
||||
|
||||
Series.Add(series);
|
||||
}
|
||||
|
||||
@ -189,12 +199,22 @@ namespace Sunny.UI
|
||||
|
||||
public void AddData(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
BarName.Add(name);
|
||||
AddData(value);
|
||||
}
|
||||
|
||||
public void AddData(string name, double value, Color color)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
BarName.Add(name);
|
||||
AddData(value, color);
|
||||
}
|
||||
|
@ -69,18 +69,36 @@ namespace Sunny.UI
|
||||
|
||||
public UILineSeries AddSeries(UILineSeries series)
|
||||
{
|
||||
if (series == null) return null;
|
||||
if (series.Name.IsNullOrEmpty()) return null;
|
||||
if (series == null)
|
||||
{
|
||||
throw new NullReferenceException("series 不能为空");
|
||||
}
|
||||
|
||||
if (series.Name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("series.Name 不能为空");
|
||||
}
|
||||
|
||||
if (ExistsSeries(series.Name)) return series;
|
||||
|
||||
series.Index = Series.Count;
|
||||
int idx = 0;
|
||||
foreach (var item in Series.Values)
|
||||
{
|
||||
idx = Math.Max(idx, item.Index);
|
||||
}
|
||||
|
||||
series.Index = idx + 1;
|
||||
Series.TryAdd(series.Name, series);
|
||||
return series;
|
||||
}
|
||||
|
||||
public UILineSeries AddSeries(string seriesName, bool isY2 = false)
|
||||
{
|
||||
if (seriesName.IsNullOrEmpty()) return null;
|
||||
if (seriesName.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("seriesName 不能为空");
|
||||
}
|
||||
|
||||
if (ExistsSeries(seriesName)) return Series[seriesName];
|
||||
|
||||
UILineSeries series = new UILineSeries(seriesName, isY2);
|
||||
@ -339,6 +357,11 @@ namespace Sunny.UI
|
||||
{
|
||||
public UILineSeries(string name, bool isY2 = false)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Color = UIColor.Blue;
|
||||
IsY2 = isY2;
|
||||
@ -346,6 +369,11 @@ namespace Sunny.UI
|
||||
|
||||
public UILineSeries(string name, Color color, bool isY2 = false)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Color = color;
|
||||
CustomColor = true;
|
||||
|
@ -34,6 +34,16 @@ namespace Sunny.UI
|
||||
|
||||
public void AddSeries(UIPieSeries series)
|
||||
{
|
||||
if (series == null)
|
||||
{
|
||||
throw new NullReferenceException("series 不能为空");
|
||||
}
|
||||
|
||||
if (series.Name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("series.Name 不能为空");
|
||||
}
|
||||
|
||||
Series.Clear();
|
||||
Series.Add(series);
|
||||
}
|
||||
@ -82,6 +92,16 @@ namespace Sunny.UI
|
||||
|
||||
public void AddSeries(UIDoughnutSeries series)
|
||||
{
|
||||
if (series == null)
|
||||
{
|
||||
throw new NullReferenceException("series 不能为空");
|
||||
}
|
||||
|
||||
if (series.Name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("series.Name 不能为空");
|
||||
}
|
||||
|
||||
Series.Clear();
|
||||
Series.Add(series);
|
||||
}
|
||||
@ -151,6 +171,11 @@ namespace Sunny.UI
|
||||
|
||||
public void AddData(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
if (DataColorChange != null)
|
||||
{
|
||||
Color color = DataColorChange.Invoke(value);
|
||||
@ -164,6 +189,11 @@ namespace Sunny.UI
|
||||
|
||||
public void AddData(string name, double value, Color color)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Data.Add(new UIPieSeriesData(name, value, color));
|
||||
}
|
||||
|
||||
@ -177,6 +207,11 @@ namespace Sunny.UI
|
||||
|
||||
public void Update(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
foreach (var item in Data)
|
||||
{
|
||||
if (item.Name == name)
|
||||
@ -214,11 +249,21 @@ namespace Sunny.UI
|
||||
|
||||
public void AddData(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Data.Add(new UIPieSeriesData(name, value));
|
||||
}
|
||||
|
||||
public void AddData(string name, double value, Color color)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Data.Add(new UIPieSeriesData(name, value, color));
|
||||
}
|
||||
|
||||
@ -232,6 +277,11 @@ namespace Sunny.UI
|
||||
|
||||
public void Update(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
foreach (var item in Data)
|
||||
{
|
||||
if (item.Name == name)
|
||||
@ -250,12 +300,13 @@ namespace Sunny.UI
|
||||
|
||||
public bool StyleCustomMode { get; private set; }
|
||||
|
||||
public UIPieSeriesData()
|
||||
{
|
||||
}
|
||||
|
||||
public UIPieSeriesData(string name, double value)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
StyleCustomMode = false;
|
||||
@ -263,6 +314,11 @@ namespace Sunny.UI
|
||||
|
||||
public UIPieSeriesData(string name, double value, Color color)
|
||||
{
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
throw new NullReferenceException("name 不能为空");
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
Color = color;
|
||||
|
Loading…
x
Reference in New Issue
Block a user