Изменения на паре

This commit is contained in:
bekodeg 2024-11-04 13:04:34 +04:00
parent 2d50eff660
commit cea8e833e8
6 changed files with 55 additions and 14 deletions

View File

@ -38,7 +38,7 @@ namespace Cop.Borovkov.Var3.Components
foreach (var data in histogramInfo.Values)
{
if (string.IsNullOrEmpty(data.Name) || data.Values == null || data.Values.Count() == 0)
if (string.IsNullOrEmpty(data.Name) || data.Points == null || data.Points.Count() == 0)
throw new ArgumentException($"Набор данных для серии '{data.Name}' некорректен.");
}
@ -58,7 +58,7 @@ namespace Cop.Borovkov.Var3.Components
DataSet = histogramInfo.Values.Select(l => new PdfHistogramData()
{
DisplayName = l.Name,
Value = l.Values
Value = l.Points.Select(p => (p.Name, p.Value))
}).ToList()
});

View File

@ -0,0 +1,18 @@
namespace Cop.Borovkov.Var3.Models
{
/// <summary>
/// Точка
/// </summary>
public record ChartPoint
{
/// <summary>
/// Имя
/// </summary>
public required string Name { get; init; } = string.Empty;
/// <summary>
/// Значение
/// </summary>
public required double Value { get; init; }
}
}

View File

@ -10,6 +10,6 @@
/// <summary>
/// Значения
/// </summary>
public required IEnumerable<double> Values { get; init; }
public required IEnumerable<ChartPoint> Points { get; init; }
}
}

View File

@ -15,7 +15,7 @@ namespace PIHelperSh.PdfCreator.Models.PieChartModel
/// <summary>
/// Значение варианта(по ним строят диаграмму)
/// </summary>
public IEnumerable<double> Value { get; set; }
public IEnumerable<(string Name, double Value)> Value { get; set; }
/// <summary>
/// Цвет области на диаграме. При null будет использоватсся выдача цветов по умолчанию)
@ -33,7 +33,7 @@ namespace PIHelperSh.PdfCreator.Models.PieChartModel
/// </summary>
/// <param name="displayName"></param>
/// <param name="value"></param>
public PdfHistogramData(string displayName, IEnumerable<double> value)
public PdfHistogramData(string displayName, IEnumerable<(string, double)> value)
{
DisplayName = displayName;
Value = value;

View File

@ -434,7 +434,9 @@ namespace PIHelperSh.PdfCreator
row.Height = item.height;
for (int i = 0; i < maper.Count; i++)
ConfigurateCell(row.Cells[0], maper[0](item.value)?.ToString()!, header.RecordHorizontalAlignment, header.HeaderStyle);
for (int i = 1; i < maper.Count; i++)
{
ConfigurateCell(row.Cells[i], maper[i](item.value)?.ToString()!, header.RecordHorizontalAlignment, header.RecordStyle);
}
@ -520,14 +522,17 @@ namespace PIHelperSh.PdfCreator
ConfiguratePieChart(chart, pieHistogram);
XSeries xseries = chart.XValues.AddXSeries();
foreach (var val in pieHistogram.DataSet.First().Value.Select(v => v.Name))
xseries.Add(val);
foreach (var item in pieHistogram.DataSet)
{
Series series = chart.SeriesCollection.AddSeries();
series.Name = item.DisplayName;
series.Add(item.Value.ToArray());
xseries.Add(item.DisplayName);
series.Add(item.Value.Select(v => v.Value).ToArray());
if (item.Color.HasValue)
{
series.FillFormat.Color = new Color((uint)item.Color.Value.ToArgb());

View File

@ -48,7 +48,7 @@ namespace TestCustomComponents.Forms
{
customPdfTableWithGrouping1.SaveToPdf<TestModel>(new()
{
FilePath = @"E:\test\test.pdf",
FilePath = @"C:\test\test.pdf",
Title = "Текст заголовка",
Columns = [
new() {
@ -114,17 +114,35 @@ namespace TestCustomComponents.Forms
{
customPdfHistogram1.SaveToPdf(new()
{
FilePath = @"E:\test\test.pdf",
FilePath = @"C:\test\test.pdf",
DocumentTitle = "Текст заголовка",
HistogramTitle = "Заголовок диограммы",
Values = [
new(){
Name = "Линия1",
Values = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89],
Points = [
new() { Name = "f3", Value = 2 },
new() { Name = "f4", Value = 3 },
new() { Name = "f5", Value = 5 },
new() { Name = "f6", Value = 8 },
new() { Name = "f7", Value = 13 },
new() { Name = "f8", Value = 21 },
new() { Name = "f9", Value = 34 },
new() { Name = "f10", Value = 55 },
new() { Name = "f11", Value = 89 },
],
},
new(){
Name = "Линия1",
Values = [1, 100, 10, 80, 30, 60, 50],
Name = "Линия2",
Points = [
new() { Name = "r1", Value = 1 },
new() { Name = "r2", Value = 100 },
new() { Name = "r3", Value = 10 },
new() { Name = "r4", Value = 80 },
new() { Name = "r5", Value = 30 },
new() { Name = "r6", Value = 60 },
new() { Name = "r7", Value = 50 },
],
}
],
});