PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Pie Chart area labels
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4437
Page 1 of 1

Author:  rsivan [ Thu May 04, 2023 4:08 am ]
Post subject:  Pie Chart area labels

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);

Author:  Thomas Hoevel [ Thu May 04, 2023 9:13 am ]
Post subject:  Re: Pie Chart area labels

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 2809 times ]

Is that what you want?

Author:  rsivan [ Thu May 04, 2023 2:56 pm ]
Post subject:  Re: Pie Chart area labels

Thanks Thomas.
I do not get the right side square with the index. How do you produce that?

Author:  Thomas Hoevel [ Thu May 04, 2023 4:05 pm ]
Post subject:  Re: Pie Chart area labels

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"
      }
    }

Author:  rsivan [ Thu May 04, 2023 6:04 pm ]
Post subject:  Re: Pie Chart area labels

AddLegend did it!
Thanks a lot!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/