* 修改图表控件的一些小BUG

This commit is contained in:
Sunny 2020-07-18 10:00:31 +08:00
parent 26c2013848
commit 7c5d84185f
7 changed files with 51 additions and 25 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -196,6 +196,8 @@ namespace Sunny.UI
{ {
base.OnMouseMove(e); base.OnMouseMove(e);
try
{
if (BarOption.ToolTip == null) return; if (BarOption.ToolTip == null) return;
if (e.Location.X > BarOption.Grid.Left && e.Location.X < Width - BarOption.Grid.Right if (e.Location.X > BarOption.Grid.Left && e.Location.X < Width - BarOption.Grid.Right
&& e.Location.Y > BarOption.Grid.Top && && e.Location.Y > BarOption.Grid.Top &&
@ -208,7 +210,7 @@ namespace Sunny.UI
SelectIndex = -1; SelectIndex = -1;
} }
if (SelectIndex >= 0) if (SelectIndex >= 0 && Bars.Count > 0)
{ {
if (tip.Text != Bars[0][selectIndex].Tips) if (tip.Text != Bars[0][selectIndex].Tips)
{ {
@ -228,6 +230,11 @@ namespace Sunny.UI
if (!tip.Visible) tip.Visible = Bars[0][selectIndex].Tips.IsValid(); if (!tip.Visible) tip.Visible = Bars[0][selectIndex].Tips.IsValid();
} }
} }
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
[Browsable(false)] [Browsable(false)]
private UIBarOption BarOption private UIBarOption BarOption

View File

@ -36,6 +36,7 @@ namespace Sunny.UI
public double Value { get; set; } public double Value { get; set; }
public string Name { get; set; } public string Name { get; set; }
public Color Color { get; set; } public Color Color { get; set; }
public UILeftAlignment Left { get; set; }
} }
public class UILegend public class UILegend

View File

@ -68,6 +68,8 @@ namespace Sunny.UI
DrawLegend(g, PieOption.Legend); DrawLegend(g, PieOption.Legend);
} }
private bool AllIsZero;
protected override void CalcData(UIOption option) protected override void CalcData(UIOption option)
{ {
Angles.Clear(); Angles.Clear();
@ -85,6 +87,7 @@ namespace Sunny.UI
all += data.Value; all += data.Value;
} }
AllIsZero = all.IsZero();
if (all.IsZero()) return; if (all.IsZero()) return;
float start = 0; float start = 0;
for (int i = 0; i < pie.Data.Count; i++) for (int i = 0; i < pie.Data.Count; i++)
@ -120,6 +123,17 @@ namespace Sunny.UI
{ {
if (series == null || series.Count == 0) return; if (series == null || series.Count == 0) return;
if (AllIsZero)
{
if (series.Count > 0)
{
RectangleF rect = GetSeriesRect(series[0]);
g.DrawEllipse(Color.Red, rect);
}
return;
}
for (int pieIndex = 0; pieIndex < series.Count; pieIndex++) for (int pieIndex = 0; pieIndex < series.Count; pieIndex++)
{ {
var pie = series[pieIndex]; var pie = series[pieIndex];
@ -184,6 +198,8 @@ namespace Sunny.UI
return; return;
} }
if (AllIsZero) return;
for (int pieIndex = 0; pieIndex < PieOption.SeriesCount; pieIndex++) for (int pieIndex = 0; pieIndex < PieOption.SeriesCount; pieIndex++)
{ {
RectangleF rect = GetSeriesRect(PieOption.Series[pieIndex]); RectangleF rect = GetSeriesRect(PieOption.Series[pieIndex]);

View File

@ -179,6 +179,8 @@ namespace Sunny.UI
{ {
Checked = true; Checked = true;
} }
base.OnClick(e);
} }
public override void SetStyleColor(UIBaseStyle uiColor) public override void SetStyleColor(UIBaseStyle uiColor)