- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何使用 EPPlus 以编程方式更改 Excel 饼图的默认颜色。
下面是我的代码
var pieChart = worksheet.Drawings.AddChart("piechart", eChartType.Pie3D) as ExcelPieChart;
//Set top left corner to row 1 column 2
pieChart.SetPosition(18, 0, 0, 0);
pieChart.SetSize(350, 300);
pieChart.Series.Add(ExcelRange.GetAddress(12, 2, 15, 2),ExcelRange.GetAddress(12, 1, 15, 1) );
pieChart.Legend.Position = eLegendPosition.Bottom;
pieChart.Legend.Border.Fill.Color = Color.Green;
pieChart.Legend.Border.LineStyle = eLineStyle.Solid;
pieChart.Legend.Border.Fill.Style = eFillStyle.SolidFill;
pieChart.Title.Text = "Current Status";
pieChart.DataLabel.ShowCategory = false;
pieChart.DataLabel.ShowPercent = true;
我想将默认颜色更改为一些明亮的颜色。
提出建议并阐明这一点。
最佳答案
受 Ernie 的回答启发,这里有一个扩展方法,用于设置折线图系列的颜色和厚度,以及一个用于设置饼图数据点颜色的未测试版本:
public static void SetSeriesStyle(this ExcelLineChart chart, ExcelChartSerie series, Color color, decimal? thickness = null) {
if (thickness < 0) throw new ArgumentOutOfRangeException("thickness");
var i = 0;
var found = false;
foreach (var s in chart.Series) {
if (s == series) {
found = true;
break;
}
++i;
}
if (!found) throw new InvalidOperationException("series not found.");
//Get the nodes
var nsm = chart.WorkSheet.Drawings.NameSpaceManager;
var nschart = nsm.LookupNamespace("c");
var nsa = nsm.LookupNamespace("a");
var node = chart.ChartXml.SelectSingleNode(@"c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[c:idx[@val='" + i.ToString(CultureInfo.InvariantCulture) + "']]", nsm);
var doc = chart.ChartXml;
//Add the solid fill node
var spPr = doc.CreateElement("c:spPr", nschart);
var ln = spPr.AppendChild(doc.CreateElement("a:ln", nsa));
if (thickness.HasValue) {
var w = ln.Attributes.Append(doc.CreateAttribute("w"));
w.Value = Math.Round(thickness.Value * 12700).ToString(CultureInfo.InvariantCulture);
var cap = ln.Attributes.Append(doc.CreateAttribute("cap"));
cap.Value = "rnd";
}
var solidFill = ln.AppendChild(doc.CreateElement("a:solidFill", nsa));
var srgbClr = solidFill.AppendChild(doc.CreateElement("a:srgbClr", nsa));
var valattrib = srgbClr.Attributes.Append(doc.CreateAttribute("val"));
//Set the color
valattrib.Value = color.ToHex().Substring(1);
node.AppendChild(spPr);
}
public static void SetDataPointStyle(this ExcelPieChart chart, int dataPointIndex, Color color) {
//Get the nodes
var nsm = chart.WorkSheet.Drawings.NameSpaceManager;
var nschart = nsm.LookupNamespace("c");
var nsa = nsm.LookupNamespace("a");
var node = chart.ChartXml.SelectSingleNode("c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser", nsm);
var doc = chart.ChartXml;
//Add the node
//Create the data point node
var dPt = doc.CreateElement("c:dPt", nschart);
var idx = dPt.AppendChild(doc.CreateElement("c:idx", nschart));
var valattrib = idx.Attributes.Append(doc.CreateAttribute("val"));
valattrib.Value = dataPointIndex.ToString(CultureInfo.InvariantCulture);
node.AppendChild(dPt);
//Add the solid fill node
var spPr = doc.CreateElement("c:spPr", nschart);
var solidFill = spPr.AppendChild(doc.CreateElement("a:solidFill", nsa));
var srgbClr = solidFill.AppendChild(doc.CreateElement("a:srgbClr", nsa));
valattrib = srgbClr.Attributes.Append(doc.CreateAttribute("val"));
//Set the color
valattrib.Value = color.ToHex().Substring(1);
dPt.AppendChild(spPr);
}
public static String ToHex(this Color c) {
return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}
用法:
lineChart.SetSeriesStyle(s, color: Color.FromArgb(0, 0, 0), thickness: 6m);
pieChart.SetDataPointStyle(dataPointIndex: 0, color: Color.FromArgb(0, 0, 0));
关于c# - EPPlus如何更改EXCEL中PIE图表的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25623324/
我正在使用 Xcode 4.5,部署目标为 iOS 5.1 当我编译我的应用程序时,我收到以下警告,这些方法与两个大小显着增加的特定方法有关。 ld: warning: PIE disabled. A
我想使用 lief 将可执行文件转换为共享库,我注意到它只支持 pie 可执行文件。所以我想知道是否有一种方法可以将 no-pie 可执行文件转换为 pie 可执行文件。 最佳答案 不,没有,除非在链
我的 Android 项目应该生成原生可执行文件作为构建的一部分,并支持 API 14 (Android 4.0) 的所有设备。 问题是 4.0 仅支持非 pie 可执行文件,而 Android >
我有一个全屏cordova应用程序,我曾经使用下面的css作为iPhone X的缺口, padding-top: 25px; padding-top: env(safe-area-inset-top)
我指的是这个https://ecomfe.github.io/echarts/doc/example/pie1.html#-en例子。我无法隐藏饼图中的相邻标签。我已经圈出了我希望隐藏在附加图像中的标
这是我的代码: function graphDataAllChart(graphData) { $(".dataContentAllPie").empty(); nv.addGrap
这有效: perl -pi -e 's/abc/cba/g' hellofile 但这不会: perl -pie 's/cba/abc/g' hellofile 换句话说 -pi -e 有效但 -pi
在 amcharts v4 中,PIE 切片的颜色在 10 种左右的颜色后重复。就像他们有一系列颜色,他们只使用这些颜色并在完成后重复。我希望所有切片都具有独特的颜色,而无需手动创建颜色。如果可能需要
我在我的应用程序中有一个 15 秒计时器的要求,在圆形进度条动画中将在秒数的中心包含标签 下面的代码给出了从 0.0 到 1.0f 的 labelprogress,但我想将它映射到 15 秒倒计时的平
我有一个在夜间运行后台服务的应用程序。它由 alarm clock app 触发运行. 该应用整夜将手机外部 SD 卡上的数据上传到 Dropbox。它可以在以前的 Android 版本上无缝运行,但
我正在尝试从这里自定义一个饼图: https://canvasjs.com/jquery-charts/pie-chart-index-data-label-inside/ 我使用的代码如下,经过我的
我正在尝试使用 CSS PIE 显示圆 Angular ,但它不起作用。请看my website for reference .您会看到在 IE7 和 IE8 中,顶部的小登录区域没有圆 Angula
我正致力于将我们公司的 Web 应用程序带入 21 世纪,并尝试使用一些新的 CSS3 功能,如 border-radius 和 box-shadow 以获得更现代的视觉效果。然而,我们 90% 以上
有一个简单的例子:http://fsou1.ru/files/verstka_examples/14/index2.html 我在 IE 中使用 PIE.js 附加边框半径,但是当我在悬停事件上添加“
我有一个网站 here ... 在 Chrome/FF 中查看它,您会看到带有圆 Angular 的标签。 IE8 仍然显示方 Angular 。 这是我调用 PIE 的 CSS... .class-
渲染边框的 RGBA 颜色时遇到问题。边框半径的 RGBA 颜色工作正常但不是边框颜色,它不显示任何边框颜色。 CSSPie 中是否有单独的“-pie-”标签用于在边框中使用 RGBA? 我的代码:
我用 gcc -fpie test.c 编译了一个简单的 hello world c 代码,现在使用 objdump 查看二进制文件: Disassembly of section __TEXT,__
我正在使用 CSS3 pie 并在 head 标签之前通过附加的 js 文件调用它。 出于某种原因,我的背景图片出现了。我已经尝试了标准添加 z-index 和位置相对修复,但它没有显示。任何帮助指导
这是我检测和显示性别和年龄的循环。我试图在 matplotlib 饼图上绘制它,但每次它运行循环时,它都会为每个预测打开一个不同的图表。如何实时更新同一个图表。 这里我更新完整的代码 使用 Pytho
我用的是ie8,其他版本不知道。我到处都在使用派,它通常工作正常。但是,我所有的表单输入元素都有框阴影和边框半径,并且没有边框(几乎所有样式)。在 FF/Safari/Chrome 中一切都很好,但在
我是一名优秀的程序员,十分优秀!