* 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)
|
public void AddSeries(UIBarSeries series)
|
||||||
{
|
{
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series.Name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series.Name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Series.Add(series);
|
Series.Add(series);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,12 +199,22 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddData(string name, double value)
|
public void AddData(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
BarName.Add(name);
|
BarName.Add(name);
|
||||||
AddData(value);
|
AddData(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddData(string name, double value, Color color)
|
public void AddData(string name, double value, Color color)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
BarName.Add(name);
|
BarName.Add(name);
|
||||||
AddData(value, color);
|
AddData(value, color);
|
||||||
}
|
}
|
||||||
|
@ -69,18 +69,36 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public UILineSeries AddSeries(UILineSeries series)
|
public UILineSeries AddSeries(UILineSeries series)
|
||||||
{
|
{
|
||||||
if (series == null) return null;
|
if (series == null)
|
||||||
if (series.Name.IsNullOrEmpty()) return null;
|
{
|
||||||
|
throw new NullReferenceException("series 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series.Name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series.Name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
if (ExistsSeries(series.Name)) return series;
|
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);
|
Series.TryAdd(series.Name, series);
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UILineSeries AddSeries(string seriesName, bool isY2 = false)
|
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];
|
if (ExistsSeries(seriesName)) return Series[seriesName];
|
||||||
|
|
||||||
UILineSeries series = new UILineSeries(seriesName, isY2);
|
UILineSeries series = new UILineSeries(seriesName, isY2);
|
||||||
@ -339,6 +357,11 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
public UILineSeries(string name, bool isY2 = false)
|
public UILineSeries(string name, bool isY2 = false)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Name = name;
|
Name = name;
|
||||||
Color = UIColor.Blue;
|
Color = UIColor.Blue;
|
||||||
IsY2 = isY2;
|
IsY2 = isY2;
|
||||||
@ -346,6 +369,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public UILineSeries(string name, Color color, bool isY2 = false)
|
public UILineSeries(string name, Color color, bool isY2 = false)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Name = name;
|
Name = name;
|
||||||
Color = color;
|
Color = color;
|
||||||
CustomColor = true;
|
CustomColor = true;
|
||||||
|
@ -34,6 +34,16 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddSeries(UIPieSeries series)
|
public void AddSeries(UIPieSeries series)
|
||||||
{
|
{
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series.Name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series.Name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Series.Clear();
|
Series.Clear();
|
||||||
Series.Add(series);
|
Series.Add(series);
|
||||||
}
|
}
|
||||||
@ -82,6 +92,16 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddSeries(UIDoughnutSeries series)
|
public void AddSeries(UIDoughnutSeries series)
|
||||||
{
|
{
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series.Name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("series.Name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Series.Clear();
|
Series.Clear();
|
||||||
Series.Add(series);
|
Series.Add(series);
|
||||||
}
|
}
|
||||||
@ -151,6 +171,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddData(string name, double value)
|
public void AddData(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
if (DataColorChange != null)
|
if (DataColorChange != null)
|
||||||
{
|
{
|
||||||
Color color = DataColorChange.Invoke(value);
|
Color color = DataColorChange.Invoke(value);
|
||||||
@ -164,6 +189,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddData(string name, double value, Color color)
|
public void AddData(string name, double value, Color color)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Data.Add(new UIPieSeriesData(name, value, color));
|
Data.Add(new UIPieSeriesData(name, value, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,6 +207,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Update(string name, double value)
|
public void Update(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in Data)
|
foreach (var item in Data)
|
||||||
{
|
{
|
||||||
if (item.Name == name)
|
if (item.Name == name)
|
||||||
@ -214,11 +249,21 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void AddData(string name, double value)
|
public void AddData(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Data.Add(new UIPieSeriesData(name, value));
|
Data.Add(new UIPieSeriesData(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddData(string name, double value, Color color)
|
public void AddData(string name, double value, Color color)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Data.Add(new UIPieSeriesData(name, value, color));
|
Data.Add(new UIPieSeriesData(name, value, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +277,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Update(string name, double value)
|
public void Update(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in Data)
|
foreach (var item in Data)
|
||||||
{
|
{
|
||||||
if (item.Name == name)
|
if (item.Name == name)
|
||||||
@ -250,12 +300,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public bool StyleCustomMode { get; private set; }
|
public bool StyleCustomMode { get; private set; }
|
||||||
|
|
||||||
public UIPieSeriesData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public UIPieSeriesData(string name, double value)
|
public UIPieSeriesData(string name, double value)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Name = name;
|
Name = name;
|
||||||
Value = value;
|
Value = value;
|
||||||
StyleCustomMode = false;
|
StyleCustomMode = false;
|
||||||
@ -263,6 +314,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public UIPieSeriesData(string name, double value, Color color)
|
public UIPieSeriesData(string name, double value, Color color)
|
||||||
{
|
{
|
||||||
|
if (name.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("name 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
Name = name;
|
Name = name;
|
||||||
Value = value;
|
Value = value;
|
||||||
Color = color;
|
Color = color;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user