PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
Formatting a black and white pie chart https://forum.pdfsharp.net/viewtopic.php?f=2&t=2359 |
Page 1 of 1 |
Author: | Kevin [ Mon Mar 11, 2013 3:27 pm ] | ||
Post subject: | Formatting a black and white pie chart | ||
Using MigraDoc, I need to add pie charts to a PDF that is required to use only grayscale colors. I have a couple questions about formatting them: 1) How do I change the colors that the chart uses for its slices? Again, I can only use shades of gray, so the current colors don't work for me, but I don't want all of the slices to be the same color either. 2) Is there some way to put the X-series labels next to or on the pie chart slices instead of in a legend? Since all of my slices will be gray, a legend that identifies each of the slices by color won't be very useful. I attached an image of roughly what I want to do in MigraDoc.
|
Author: | Noconi [ Wed Nov 20, 2013 8:12 pm ] |
Post subject: | Re: Formatting a black and white pie chart |
I was just trying to control the color output of the pie wedges and could find how. Eventually I went to the PDFSharp source code and found PdfSharp.Charting.Renderers.Colors.cs. In there was an array of colors under shown below. I changed the hex strings to the colors (Green,Red,Blue...) I wanted and re-compiled the dll's. Not a perfect solution, but it worked for me. Code: internal sealed class PieColors
{ /// <summary> /// Gets the color for pie charts from the specified index. /// </summary> public static XColor Item(int index) { return XColor.FromArgb((int)sectorColors[index]); } /// <summary> /// Colors for pie charts taken from Excel. /// </summary> static uint[] sectorColors = new uint[] { 0xFF00FF00, 0xFFFF0000, 0xFF0000FF, 0xFFCCFFFF, 0xFF660066, 0xFFFF8080, 0xFF0066CC, 0xFFCCCCFF, 0xFF000080, 0xFFFF00FF, 0xFFFFFF00, 0xFF00FFFF, 0xFF800080, 0xFF800000, 0xFF008080, 0xFF0000FF, 0xFF00CCFF, 0xFFCCFFFF, 0xFFCCFFCC, 0xFFFFFF99, 0xFF99CCFF, 0xFFFF99CC, 0xFFCC99FF, 0xFFFFCC99, 0xFF3366FF, 0xFF33CCCC, 0xFF99CC00, 0xFFFFCC00, 0xFFFF9900, 0xFFFF6600, 0xFF666699, 0xFF969696, 0xFF003366, 0xFF339966, 0xFF003300, 0xFF333300, 0xFF993300, 0xFF993366, 0xFF333399, 0xFF333333, 0xFF000000, 0xFFFFFFFF, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, 0xFF800000, 0xFF008000, 0xFF000080, 0xFF808000, 0xFF800080, 0xFF008080, 0xFFC0C0C0, 0xFF808080 }; } |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |