* UIDoughnutChart: 数据显示的小数位数重构调整至Option.DecimalPlaces
* UIPieChart: 数据显示的小数位数重构调整至Option.DecimalPlaces
This commit is contained in:
parent
55fe87d8f3
commit
2cc9ef5308
@ -220,7 +220,7 @@ namespace Sunny.UI
|
||||
foreach (var series in Option.Series)
|
||||
{
|
||||
str += '\n';
|
||||
str += series.Name + " : " + series.Data[i].ToString(Option.ToolTip.ValueFormat);
|
||||
//str += series.Name + " : " + series.Data[i].ToString(Option.ToolTip.ValueFormat);
|
||||
}
|
||||
|
||||
Bars[0][i].Tips = str;
|
||||
@ -527,23 +527,23 @@ namespace Sunny.UI
|
||||
|
||||
if (Option.ShowValue)
|
||||
{
|
||||
string value = info.Value.ToString(Option.ToolTip.ValueFormat);
|
||||
SizeF sf = g.MeasureString(value, TempFont);
|
||||
if (info.Top)
|
||||
{
|
||||
float top = info.Rect.Top - sf.Height;
|
||||
if (top > Option.Grid.Top)
|
||||
{
|
||||
g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, top);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.Rect.Bottom + sf.Height + Option.Grid.Bottom < Height)
|
||||
{
|
||||
g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, info.Rect.Bottom);
|
||||
}
|
||||
}
|
||||
//string value = info.Value.ToString(Option.ToolTip.ValueFormat);
|
||||
//SizeF sf = g.MeasureString(value, TempFont);
|
||||
//if (info.Top)
|
||||
//{
|
||||
// float top = info.Rect.Top - sf.Height;
|
||||
// if (top > Option.Grid.Top)
|
||||
// {
|
||||
// g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, top);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (info.Rect.Bottom + sf.Height + Option.Grid.Bottom < Height)
|
||||
// {
|
||||
// g.DrawString(value, TempFont, info.Color, info.Rect.Center().X - sf.Width / 2, info.Rect.Bottom);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,6 @@ namespace Sunny.UI
|
||||
public UIBarToolTip()
|
||||
{
|
||||
Formatter = "{{b}} : {{c}}";
|
||||
ValueFormat = "F0";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*
|
||||
* 2020-06-06: V2.2.5 增加文件说明
|
||||
* 2021-07-22: V3.0.5 增加更新数据的方法
|
||||
* 2022-07-29: V3.2.2 数据显示的小数位数重构调整至Option.DecimalPlaces
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -134,7 +135,7 @@ namespace Sunny.UI
|
||||
UITemplate template = new UITemplate(Option.ToolTip.Formatter);
|
||||
template.Set("a", pie.Name);
|
||||
template.Set("b", pie.Data[i].Name);
|
||||
template.Set("c", pie.Data[i].Value.ToString(Option.ToolTip.ValueFormat));
|
||||
template.Set("c", pie.Data[i].Value.ToString("F" + Option.DecimalPlaces));
|
||||
template.Set("d", percent.ToString("F2"));
|
||||
text = template.Render();
|
||||
}
|
||||
|
@ -36,8 +36,6 @@ namespace Sunny.UI
|
||||
public bool Visible { get; set; }
|
||||
|
||||
public string Formatter { get; set; }
|
||||
|
||||
public string ValueFormat { get; set; }
|
||||
}
|
||||
|
||||
public class UIScaleLine
|
||||
|
@ -18,6 +18,7 @@
|
||||
*
|
||||
* 2020-06-06: V2.2.5 增加文件说明
|
||||
* 2021-07-22: V3.0.5 增加更新数据的方法
|
||||
* 2022-07-29: V3.2.2 数据显示的小数位数重构调整至Option.DecimalPlaces
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -136,13 +137,13 @@ namespace Sunny.UI
|
||||
UITemplate template = new UITemplate(Option.ToolTip.Formatter);
|
||||
template.Set("a", pie.Name);
|
||||
template.Set("b", pie.Data[i].Name);
|
||||
template.Set("c", pie.Data[i].Value.ToString(Option.ToolTip.ValueFormat));
|
||||
template.Set("c", pie.Data[i].Value.ToString("F" + Option.DecimalPlaces));
|
||||
template.Set("d", percent.ToString("F2"));
|
||||
text = template.Render();
|
||||
}
|
||||
catch
|
||||
{
|
||||
text = pie.Data[i].Name + " : " + pie.Data[i].Value.ToString("F2") + "(" + percent.ToString("F2") + "%)";
|
||||
text = pie.Data[i].Name + " : " + pie.Data[i].Value.ToString("F" + Option.DecimalPlaces) + "(" + percent.ToString("F2") + "%)";
|
||||
if (pie.Name.IsValid()) text = pie.Name + '\n' + text;
|
||||
}
|
||||
}
|
||||
@ -191,7 +192,7 @@ namespace Sunny.UI
|
||||
string name = Option.Legend != null ? Option.Legend.Data[azIndex] + " : " : "";
|
||||
if (pie.Data[azIndex].Value > 0)
|
||||
{
|
||||
string text = name + pie.Data[azIndex].Value.ToString("F0");
|
||||
string text = name + pie.Data[azIndex].Value.ToString("F" + Option.DecimalPlaces);
|
||||
SizeF sf = g.MeasureString(text, TempFont);
|
||||
PointF pf;
|
||||
int added = 9;
|
||||
|
@ -64,6 +64,13 @@ namespace Sunny.UI
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int decimalPlaces = 0;
|
||||
public int DecimalPlaces
|
||||
{
|
||||
get => decimalPlaces;
|
||||
set => decimalPlaces = Math.Max(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class UIDoughnutOption : UIOption, IDisposable
|
||||
@ -105,6 +112,13 @@ namespace Sunny.UI
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int decimalPlaces = 0;
|
||||
public int DecimalPlaces
|
||||
{
|
||||
get => decimalPlaces;
|
||||
set => decimalPlaces = Math.Max(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class UIPieToolTip : UIChartToolTip
|
||||
@ -112,7 +126,6 @@ namespace Sunny.UI
|
||||
public UIPieToolTip()
|
||||
{
|
||||
Formatter = "{{a}}" + '\n' + "{{b}} : {{c}} ({{d}}%)";
|
||||
ValueFormat = "F0";
|
||||
Visible = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user