Browse Source

* UIBarChart:可设置柱状图最小宽度

pull/95/head
Sunny 5 years ago
parent
commit
169be3c9e3
  1. BIN
      Bin/SunnyUI.dll
  2. BIN
      Bin/SunnyUI.pdb
  3. BIN
      SunnyUI.Demo/Bin/SunnyUI.Demo.exe
  4. BIN
      SunnyUI.Demo/Bin/SunnyUI.dll
  5. 25
      SunnyUI/Charts/UIBarChart.cs
  6. 2
      SunnyUI/Charts/UIBarChartOption.cs

BIN
Bin/SunnyUI.dll

BIN
Bin/SunnyUI.pdb

BIN
SunnyUI.Demo/Bin/SunnyUI.Demo.exe

BIN
SunnyUI.Demo/Bin/SunnyUI.dll

25
SunnyUI/Charts/UIBarChart.cs

@ -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
});
}

2
SunnyUI/Charts/UIBarChartOption.cs

@ -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…
Cancel
Save