PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Nov 10, 2024 7:20 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Pie Chart area labels
PostPosted: Thu May 04, 2023 4:08 am 
Offline

Joined: Tue May 02, 2023 6:32 pm
Posts: 4
I created a Pie Chart with Migradoc/PdfSharp 6.0.0-preview-2.
I see the values as labels but I expected to also see the area names, which I defined as an X Axis:
Code:
            var chart = new Chart(ChartType.Pie2D);

            chart.Width = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(10);
            var series = chart.SeriesCollection.AddSeries();

            double[] vals = { 20, 30, 40 };
            series.Add(vals);
            series.HasDataLabel = true;
            series.DataLabel.Position = DataLabelPosition.OutsideEnd;
            series.DataLabel.Type = DataLabelType.Percent;

            var xSeries = chart.XValues.AddXSeries();
            string[] xVals = { "Apple", "Orange", "Pear" };
            xSeries.Add(xVals);

            document.LastSection.Add(chart);


Top
 Profile  
Reply with quote  
PostPosted: Thu May 04, 2023 9:13 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
I don't know what you expect and I cannot see what you get.
Here are pie charts created with MigraDoc:
Attachment:
MigraDoc Pie charts.png
MigraDoc Pie charts.png [ 127.16 KiB | Viewed 7080 times ]

Is that what you want?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 04, 2023 2:56 pm 
Offline

Joined: Tue May 02, 2023 6:32 pm
Posts: 4
Thanks Thomas.
I do not get the right side square with the index. How do you produce that?


Top
 Profile  
Reply with quote  
PostPosted: Thu May 04, 2023 4:05 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
This chart comes from an MDDDL sample.
The chart has properties "RightArea" and "PlotArea" and the sample shows some things that can be cone with them.

Code will look different in C#, but this MDDDL sample should point you in the right directions.
Code:
    // PIE CHART ---------------------------------------------------------------
    \chart(Pie2D)
    [
      Height = 200
      Width = 381
      LineFormat.Visible = true
      FillFormat.Color = Ivory
    ]
    {
      \plotarea
      [
        TopPadding = 10
        LeftPadding = 10
        RightPadding = 10
        BottomPadding = 10
      ]
      \rightarea [VerticalAlignment = Center]
      {
        \legend
        [
          Format.Font.Name = "Arial"
          Format.Font.Size = "10"
          LineFormat.Width = 0.25
        ]
      }
      \xaxis
      [
        LineFormat.Width = 0.25
        TickLabels.Font.Name = "Arial"
        TickLabels.Font.Size = 10
      ]
      \yaxis
      [
        LineFormat.Width = 0.25
        MajorGridlines.LineFormat.Width = 0.25
        TickLabels.Font.Name = "Arial"
        TickLabels.Font.Size = 10
        TickLAbels.Format = "#"
      ]
      \series
      [
        Name = "2000"
        LineFormat.Visible = true
        FillFormat.Color = 0xFF9999FF
      ]
      {6846, 9464, 5838, 1681}
      \xvalues
      {
        "1st Quarter", "2nd Quarter", "3rd Quarter", "4th Quarter"
      }
    }

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 04, 2023 6:04 pm 
Offline

Joined: Tue May 02, 2023 6:32 pm
Posts: 4
AddLegend did it!
Thanks a lot!


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 13 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