如何设置条形图/条形图系列的颜色?
How to set the color of a barchart / barchartseries?
有谁知道如何使用 openXml 在 C# 中设置条形图/条形图系列的颜色?
到目前为止我有这个:
foreach (var solidFill in barChartSeries.ChartShapeProperties.Descendants<SolidFill>().ToList())
{
solidFill.SchemeColor = ???
}
知道我自己怎样才能找到这样的东西。文档实在是太少了
你应该可以这样做
x.Descendants<SolidFill>().First().SchemeColor = new SchemeColor(){ Val = SchemeColorValues.Accent2 };
或者那个
x.Descendants<SolidFill>().First().RgbColorModelHex = new RgbColorModelHex() { Val = "FF0000" };
在@wp78de 的帮助下我找到了解决方案:
当您从代码创建新图表时,您必须在构造函数调用中添加所有子图表:
new BarChartSeries(
new ChartShapeProperties(
new DocumentFormat.OpenXml.Drawing.SolidFill(
new DocumentFormat.OpenXml.Drawing.RgbColorModelHex() { Val = "FFA9FF" }
)
)
);
有谁知道如何使用 openXml 在 C# 中设置条形图/条形图系列的颜色?
到目前为止我有这个:
foreach (var solidFill in barChartSeries.ChartShapeProperties.Descendants<SolidFill>().ToList())
{
solidFill.SchemeColor = ???
}
知道我自己怎样才能找到这样的东西。文档实在是太少了
你应该可以这样做
x.Descendants<SolidFill>().First().SchemeColor = new SchemeColor(){ Val = SchemeColorValues.Accent2 };
或者那个
x.Descendants<SolidFill>().First().RgbColorModelHex = new RgbColorModelHex() { Val = "FF0000" };
在@wp78de 的帮助下我找到了解决方案:
当您从代码创建新图表时,您必须在构造函数调用中添加所有子图表:
new BarChartSeries(
new ChartShapeProperties(
new DocumentFormat.OpenXml.Drawing.SolidFill(
new DocumentFormat.OpenXml.Drawing.RgbColorModelHex() { Val = "FFA9FF" }
)
)
);