PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 17, 2021 1:19 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: XY scatter chart
PostPosted: Mon Nov 26, 2012 9:20 pm 
Offline

Joined: Mon Nov 26, 2012 9:15 pm
Posts: 1
Is there a way to create an XY scatter plot using MigraDoc/PDFsharp? As far as I can tell, the x-axis must contain an array of Strings. Alternatively, is there a way to add a chart from ZedGraph or some other package?

Thanks in advance for any help.


Top
 Profile  
Reply with quote  
 Post subject: Re: XY scatter chart
PostPosted: Tue Nov 27, 2012 9:49 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3048
Location: Cologne, Germany
cptZap wrote:
Alternatively, is there a way to add a chart from ZedGraph or some other package?
If the chart is a PDF or an image (e.g. PNG), you can add it to PDF files created with PDFsharp or MigraDoc.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: XY scatter chart
PostPosted: Mon Jun 15, 2015 4:08 am 
Offline

Joined: Mon Jun 15, 2015 3:12 am
Posts: 1
In case anyone else is looking for a quick way to add XY Plotting I've attached some patch files for version 1.32 here.
Its an unofficial quick fix but it might be all you need.
In MigraDoc and PDFSharp I've implemented a 'PointX' class and added support for it Series and Series Element.
In PDFSharp I've modified some renderers to recognize these and draw them.

In the patch files I've added a method Series.Add( double x, double y )
Here is a pseudocode example below of how to use it.
Assuming you have some an array of point structures having properties x and y
Thanks PDFSharp Team for sharing this codebase.
Good luck.

Code:
            Chart chart = new Chart();
            chart.Left = 0;
            chart.Width = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(12);
           
            chart.XAxis.MinimumScale = 0;
            chart.XAxis.MaximumScale = YOUR_MAX_X;
            chart.XAxis.MajorTickMark = TickMarkType.None;
            chart.XAxis.Title.Caption = "X_AXIS";
            chart.XAxis.MajorTick = 100; // your interval
         
            chart.YAxis.MajorTickMark = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color = Colors.DarkGray;
            chart.PlotArea.LineFormat.Width = 1;

         
            Series series = chart.SeriesCollection.AddSeries();
            series.ChartType = ChartType.Line;
            series.MarkerStyle = MarkerStyle.None;
            foreach( MyDataPoint pt in  MyPoints)
            {
                    series.Add(pt.X, pt.Y );
            }


            document.LastSection.Add(chart);


Attachments:
File comment: Patch files for Series.Add(x,y)
PDFSharp_XYPlot.zip [23.01 KiB]
Downloaded 365 times
Top
 Profile  
Reply with quote  
 Post subject: Re: XY scatter chart
PostPosted: Thu Feb 04, 2016 2:46 am 
Offline

Joined: Thu Feb 04, 2016 2:43 am
Posts: 1
How can I patch the files? I also need to use scatter chart


Top
 Profile  
Reply with quote  
 Post subject: Re: XY scatter chart
PostPosted: Sun Feb 07, 2016 4:30 pm 
Offline

Joined: Sun Feb 07, 2016 4:26 pm
Posts: 1
You have to download the attached zip file. Update the source with files from the zip. Recompile the library.


Top
 Profile  
Reply with quote  
 Post subject: Re: XY scatter chart
PostPosted: Thu Jul 08, 2021 12:21 am 
Offline

Joined: Thu Jul 08, 2021 12:14 am
Posts: 1
Hi, I realize this is a really old post, but I'm trying to get scatter charts to work.

I've downloaded 1.50 Beta 5 and applied the zip changes. Had to make a few modifications, as the base code has changed.

It runs, but when I try to create a scatter chart, all I get in the PDF output is:
Quote:
{"message":"Field '_lineFormat' defined on type 'MigraDoc.DocumentObjectModel.Shapes.Charts.Point' is not a field on the target object which is of type 'MigraDoc.DocumentObjectModel.Shapes.Charts.PointX'."}


I can't find where this is coming from the code. Anyone know what this means and/or how to resolve?

Thanks.


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 19 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