PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Sat Sep 20, 2025 11:05 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Mar 11, 2013 3:27 pm 
Offline

Joined: Fri Mar 01, 2013 9:17 pm
Posts: 4
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.


Attachments:
black and white pie chart.png
black and white pie chart.png [ 4.97 KiB | Viewed 5922 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 20, 2013 8:12 pm 
Offline

Joined: Thu Jul 12, 2012 9:33 pm
Posts: 1
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
    };
  }


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 204 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group