更新曲线
This commit is contained in:
@@ -131,7 +131,7 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
{
|
||||
var rows = new List<IReadOnlyList<object?>>
|
||||
{
|
||||
new object?[] { "时间(s)", "正压力(N)", "摩擦力(N)", "位移量(mm)", "摩擦系数" }
|
||||
new object?[] { "滑动开始后时间(s)", "垂直载荷(N)", "水平摩擦力(N)", "滑动位移(mm)", "摩擦系数" }
|
||||
};
|
||||
|
||||
foreach (var point in points)
|
||||
@@ -242,14 +242,40 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
worksheetPart.Worksheet.Append(new DocumentFormat.OpenXml.Spreadsheet.Drawing { Id = drawingRelationshipId });
|
||||
|
||||
drawingsPart.WorksheetDrawing = new Xdr.WorksheetDrawing();
|
||||
AddChartPart(
|
||||
drawingsPart,
|
||||
CreateForceAndCoefficientChartSpace(lastRow),
|
||||
2U,
|
||||
"防滑性能力与摩擦系数曲线",
|
||||
1,
|
||||
23);
|
||||
AddChartPart(
|
||||
drawingsPart,
|
||||
CreateDisplacementChartSpace(lastRow),
|
||||
3U,
|
||||
"滑动位移",
|
||||
25,
|
||||
39);
|
||||
drawingsPart.WorksheetDrawing.Save();
|
||||
worksheetPart.Worksheet.Save();
|
||||
}
|
||||
|
||||
private static void AddChartPart(
|
||||
DrawingsPart drawingsPart,
|
||||
C.ChartSpace chartSpace,
|
||||
uint drawingId,
|
||||
string name,
|
||||
int fromRow,
|
||||
int toRow)
|
||||
{
|
||||
var chartPart = drawingsPart.AddNewPart<ChartPart>();
|
||||
var chartRelationshipId = drawingsPart.GetIdOfPart(chartPart);
|
||||
chartPart.ChartSpace = CreateChartSpace(lastRow);
|
||||
chartPart.ChartSpace = chartSpace;
|
||||
chartPart.ChartSpace.Save();
|
||||
|
||||
var graphicFrame = new Xdr.GraphicFrame(
|
||||
new Xdr.NonVisualGraphicFrameProperties(
|
||||
new Xdr.NonVisualDrawingProperties { Id = 2U, Name = "防滑性能曲线图" },
|
||||
new Xdr.NonVisualDrawingProperties { Id = drawingId, Name = name },
|
||||
new Xdr.NonVisualGraphicFrameDrawingProperties()),
|
||||
new Xdr.Transform(
|
||||
new A.Offset { X = 0L, Y = 0L },
|
||||
@@ -259,52 +285,47 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
new C.ChartReference { Id = chartRelationshipId })
|
||||
{ Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" }));
|
||||
|
||||
var anchor = new Xdr.TwoCellAnchor(
|
||||
drawingsPart.WorksheetDrawing.Append(new Xdr.TwoCellAnchor(
|
||||
new Xdr.FromMarker(
|
||||
new Xdr.ColumnId("6"),
|
||||
new Xdr.ColumnOffset("0"),
|
||||
new Xdr.RowId("1"),
|
||||
new Xdr.RowId(fromRow.ToString(CultureInfo.InvariantCulture)),
|
||||
new Xdr.RowOffset("0")),
|
||||
new Xdr.ToMarker(
|
||||
new Xdr.ColumnId("15"),
|
||||
new Xdr.ColumnOffset("0"),
|
||||
new Xdr.RowId("23"),
|
||||
new Xdr.RowId(toRow.ToString(CultureInfo.InvariantCulture)),
|
||||
new Xdr.RowOffset("0")),
|
||||
graphicFrame,
|
||||
new Xdr.ClientData());
|
||||
|
||||
drawingsPart.WorksheetDrawing.Append(anchor);
|
||||
drawingsPart.WorksheetDrawing.Save();
|
||||
worksheetPart.Worksheet.Save();
|
||||
new Xdr.ClientData()));
|
||||
}
|
||||
|
||||
private static C.ChartSpace CreateChartSpace(int lastRow)
|
||||
private static C.ChartSpace CreateForceAndCoefficientChartSpace(int lastRow)
|
||||
{
|
||||
const uint xAxisId = 48650112U;
|
||||
const uint yAxisId = 48672768U;
|
||||
const uint forceAxisId = 48672768U;
|
||||
const uint coefficientAxisId = 48689152U;
|
||||
|
||||
var forceChart = new C.ScatterChart(
|
||||
new C.ScatterStyle { Val = C.ScatterStyleValues.LineMarker },
|
||||
CreateSeries(0, "正压力(N)", 2, lastRow),
|
||||
CreateSeries(1, "摩擦力(N)", 3, lastRow),
|
||||
CreateSeries(2, "位移量(mm)", 4, lastRow),
|
||||
CreateSeries(0, 2, lastRow),
|
||||
CreateSeries(1, 3, lastRow),
|
||||
new C.AxisId { Val = xAxisId },
|
||||
new C.AxisId { Val = yAxisId });
|
||||
new C.AxisId { Val = forceAxisId });
|
||||
var coefficientChart = new C.ScatterChart(
|
||||
new C.ScatterStyle { Val = C.ScatterStyleValues.LineMarker },
|
||||
CreateSeries(3, "摩擦系数", 5, lastRow),
|
||||
CreateSeries(2, 5, lastRow),
|
||||
new C.AxisId { Val = xAxisId },
|
||||
new C.AxisId { Val = coefficientAxisId });
|
||||
|
||||
var chart = new C.Chart(
|
||||
CreateTitle("防滑性能实时曲线"),
|
||||
CreateTitle("防滑性能滑动阶段曲线"),
|
||||
new C.PlotArea(
|
||||
new C.Layout(),
|
||||
forceChart,
|
||||
coefficientChart,
|
||||
CreateValueAxis(xAxisId, yAxisId, C.AxisPositionValues.Bottom, "时间(s)"),
|
||||
CreateValueAxis(yAxisId, xAxisId, C.AxisPositionValues.Left, "载荷 / 摩擦力 / 位移"),
|
||||
CreateValueAxis(xAxisId, forceAxisId, C.AxisPositionValues.Bottom, "滑动开始后时间(s)"),
|
||||
CreateValueAxis(forceAxisId, xAxisId, C.AxisPositionValues.Left, "垂直载荷 / 水平摩擦力 (N)"),
|
||||
CreateValueAxis(coefficientAxisId, xAxisId, C.AxisPositionValues.Right, "摩擦系数")),
|
||||
new C.Legend(
|
||||
new C.LegendPosition { Val = C.LegendPositionValues.Bottom },
|
||||
@@ -316,7 +337,35 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
chart);
|
||||
}
|
||||
|
||||
private static C.ScatterChartSeries CreateSeries(uint index, string title, int yColumnIndex, int lastRow)
|
||||
private static C.ChartSpace CreateDisplacementChartSpace(int lastRow)
|
||||
{
|
||||
const uint xAxisId = 48700112U;
|
||||
const uint displacementAxisId = 48722768U;
|
||||
|
||||
var displacementChart = new C.ScatterChart(
|
||||
new C.ScatterStyle { Val = C.ScatterStyleValues.LineMarker },
|
||||
CreateSeries(0, 4, lastRow),
|
||||
new C.AxisId { Val = xAxisId },
|
||||
new C.AxisId { Val = displacementAxisId });
|
||||
|
||||
var chart = new C.Chart(
|
||||
CreateTitle("滑动位移"),
|
||||
new C.PlotArea(
|
||||
new C.Layout(),
|
||||
displacementChart,
|
||||
CreateValueAxis(xAxisId, displacementAxisId, C.AxisPositionValues.Bottom, "滑动开始后时间(s)"),
|
||||
CreateValueAxis(displacementAxisId, xAxisId, C.AxisPositionValues.Left, "滑动位移 (mm)")),
|
||||
new C.Legend(
|
||||
new C.LegendPosition { Val = C.LegendPositionValues.Bottom },
|
||||
new C.Layout()),
|
||||
new C.PlotVisibleOnly { Val = true });
|
||||
|
||||
return new C.ChartSpace(
|
||||
new C.EditingLanguage { Val = "zh-CN" },
|
||||
chart);
|
||||
}
|
||||
|
||||
private static C.ScatterChartSeries CreateSeries(uint index, int yColumnIndex, int lastRow)
|
||||
{
|
||||
var sheet = EscapeSheetName(DataSheetName);
|
||||
var xFormula = $"'{sheet}'!$A$2:$A${lastRow}";
|
||||
@@ -338,12 +387,12 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
|
||||
new C.AxisId { Val = axisId },
|
||||
new C.Scaling(new C.Orientation { Val = C.OrientationValues.MinMax }),
|
||||
new C.AxisPosition { Val = position },
|
||||
new C.MajorGridlines(),
|
||||
CreateTitle(title),
|
||||
new C.NumberingFormat { FormatCode = "0.00", SourceLinked = false },
|
||||
new C.MajorGridlines(),
|
||||
new C.TickLabelPosition { Val = C.TickLabelPositionValues.NextTo },
|
||||
new C.CrossingAxis { Val = crossingAxisId },
|
||||
new C.Crosses { Val = C.CrossesValues.AutoZero },
|
||||
new C.TickLabelPosition { Val = C.TickLabelPositionValues.NextTo });
|
||||
new C.Crosses { Val = C.CrossesValues.AutoZero });
|
||||
|
||||
private static C.Title CreateTitle(string text) =>
|
||||
new(
|
||||
|
||||
Reference in New Issue
Block a user