* UIBarChart:可设置柱状图最小宽度
This commit is contained in:
parent
c989dbf925
commit
169be3c9e3
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -79,23 +79,23 @@ namespace Sunny.UI
|
||||
float barX = DrawOrigin.X;
|
||||
var series = o.Series[i];
|
||||
Bars.TryAdd(i, new List<BarInfo>());
|
||||
|
||||
for (int j = 0; j < series.Data.Count; j++)
|
||||
{
|
||||
Color color = ChartStyle.GetColor(i);
|
||||
if (series.Colors.Count > 0 && j >= 0 && j < series.Colors.Count)
|
||||
color = series.Colors[j];
|
||||
|
||||
float xx = barX + x1 * (i + 1) + x2 * i + x1;
|
||||
float ww = Math.Min(x2, series.MaxWidth);
|
||||
xx = xx - ww / 2.0f;
|
||||
|
||||
if (YAxisStart >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j] - start * interval) / ((end - start) * interval)));
|
||||
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(
|
||||
barX + x1 * (i + 1) + x2 * i,
|
||||
DrawOrigin.Y - h,
|
||||
x2, h),
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
@ -104,10 +104,7 @@ namespace Sunny.UI
|
||||
float h = Math.Abs((float)(DrawSize.Height * (end * interval - series.Data[j]) / ((end - start) * interval)));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(
|
||||
barX + x1 * (i + 1) + x2 * i,
|
||||
BarOption.Grid.Top + 1,
|
||||
x2, h - 1),
|
||||
Rect = new RectangleF(xx, BarOption.Grid.Top + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
@ -134,10 +131,7 @@ namespace Sunny.UI
|
||||
float h = Math.Abs((float)(highH * series.Data[j] / highV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(
|
||||
barX + x1 * (i + 1) + x2 * i,
|
||||
DrawOrigin.Y - lowH - h,
|
||||
x2, h),
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
@ -146,10 +140,7 @@ namespace Sunny.UI
|
||||
float h = Math.Abs((float)(lowH * series.Data[j] / lowV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(
|
||||
barX + x1 * (i + 1) + x2 * i,
|
||||
DrawOrigin.Y - lowH + 1,
|
||||
x2, h - 1),
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
|
@ -170,6 +170,8 @@ namespace Sunny.UI
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int MaxWidth { get; set; } = int.MaxValue;
|
||||
|
||||
public UISeriesType Type => UISeriesType.Bar;
|
||||
|
||||
public readonly List<double> Data = new List<double>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user