private static Report CreateReport()
 {
     var r = new Report();
     r.AddHeader(1, "Test");
     r.AddPlot(new PlotModel { Title = "Plot 1" }, "First plot", 600, 400);
     r.AddPlot(new PlotModel { Title = "Plot 2" }, "Second plot", 600, 400);
     return r;
 }
        public void ExportToStream_ReportWithNoCaptions_CheckThatOutputFileExists()
        {
            const string FileName = "ReportWithNoPlotCaptions.pdf";
            var s = File.Create(FileName);
            var r = new Report();
            r.AddHeader(1, "Test");
            r.AddPlot(new PlotModel { Title = "Plot 1" }, null, 600, 400);
            r.AddPlot(new PlotModel { Title = "Plot 2" }, null, 600, 400);

            using (var w = new PdfReportWriter(s))
            {
                w.WriteReport(r, new ReportStyle());
            }

            Assert.IsTrue(new FileInfo(FileName).Length > 0);
        }
        /// <summary>
        /// Creates a report for the plot.
        /// </summary>
        /// <param name="plotModel">The plot model.</param>
        /// <returns>A report.</returns>
        public static Report CreateReport(this PlotModel plotModel)
        {
            var r = new Report { Culture = CultureInfo.InvariantCulture };

            r.AddHeader(1, "P L O T   R E P O R T");
            r.AddHeader(2, "=== PlotModel ===");
            r.AddPropertyTable("PlotModel", plotModel);

            r.AddHeader(2, "=== Axes ===");
            foreach (Axis a in plotModel.Axes)
            {
                r.AddPropertyTable(a.GetType().Name, a);
            }

            r.AddHeader(2, "=== Annotations ===");
            foreach (var a in plotModel.Annotations)
            {
                r.AddPropertyTable(a.GetType().Name, a);
            }

            r.AddHeader(2, "=== Series ===");
            foreach (var s in plotModel.Series)
            {
                r.AddPropertyTable(s.GetType().Name, s);
                var ds = s as DataPointSeries;
                if (ds != null)
                {
                    var fields = new List<ItemsTableField> { new ItemsTableField("X", "X"), new ItemsTableField("Y", "Y") };
                    r.AddItemsTable("Data", ds.Points, fields);
                }
            }

            #if UNIVERSAL
            var assemblyName = new AssemblyName(typeof(PlotModel).GetTypeInfo().Assembly.FullName);
            #else
            var assemblyName = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
            #endif
            r.AddParagraph(string.Format("Report generated by OxyPlot {0}", assemblyName.Version.ToString(3)));

            return r;
        }
 /// <summary>
 /// The write report.
 /// </summary>
 /// <param name="report">
 /// The report.
 /// </param>
 /// <param name="reportStyle">
 /// The style.
 /// </param>
 public void WriteReport(Report report, ReportStyle reportStyle)
 {
     this.style = reportStyle;
     this.WriteHtmlHeader(report.Title, null, CreateCss(reportStyle));
     report.Write(this);
 }
 /// <summary>
 /// The write report.
 /// </summary>
 /// <param name="report">
 /// The report.
 /// </param>
 /// <param name="reportStyle">
 /// The style.
 /// </param>
 public void WriteReport(Report report, ReportStyle reportStyle)
 {
     this.style = reportStyle;
     this.AddStyles(this.stylePart, reportStyle);
     report.Write(this);
 }
 /// <summary>
 /// The write report.
 /// </summary>
 /// <param name="report">
 /// The report.
 /// </param>
 /// <param name="reportStyle">
 /// The style.
 /// </param>
 public void WriteReport(Report report, ReportStyle reportStyle)
 {
     this.Style = reportStyle;
     report.Write(this);
 }
 /// <summary>
 /// Updates the Report property.
 /// </summary>
 /// <param name="report">
 /// The report.
 /// </param>
 protected void UpdateParent(Report report)
 {
     this.Report = report;
     foreach (var child in this.Children)
     {
         child.UpdateParent(report);
     }
 }
 /// <summary>
 /// Writes the report.
 /// </summary>
 /// <param name="report">
 /// The report.
 /// </param>
 /// <param name="reportStyle">
 /// The style.
 /// </param>
 public void WriteReport(Report report, ReportStyle reportStyle)
 {
     report.Write(this);
 }
Example #9
0
        static void ProcessReport(ImagePlot[] imageData)
        {

            String fileName = "Output.pdf";

            if(arguments.Output != null)
            {
                fileName = arguments.Output;
            }

            try
            {
                var s = File.Create(fileName);
                var r = new Report();
                r.AddHeader(1, "Output generated: "+DateTime.Now);

                int numReports = arguments.Graphs;
                int height = 0;
                switch (numReports)
                {
                    case 1:
                        height = 800;
                        break;
                    case 2:
                        height = 600;
                        break;
                    default:
                        height = 400;
                        break;
                }

                foreach(ImagePlot data in imageData)
                {
                    r.AddPlot(data.plot, null, 800, height);
                }

                //if (arguments.Raw && false)
                //{
                //    //r.AddParagraph()
                //    r.AddParagraph("this is a test");
                //}

                using (var w = new PdfReportWriter(s))
                {
                    w.WriteReport(r, new ReportStyle {});
                    if (arguments.Verbose) Console.WriteLine("Output to: " + fileName);
                }
            } 
            catch (Exception e)
            {
                Console.WriteLine("Could not output to file: " + e.Message);
            }
            
            
        }
Example #10
0
 /// <summary>
 /// Writes the specified report.
 /// </summary>
 /// <param name="report">The report.</param>
 /// <param name="reportStyle">The report style.</param>
 public void WriteReport(Report report, ReportStyle reportStyle)
 {
     this.style = reportStyle;
     DefineStyles(this.Document, reportStyle);
     report.Write(this);
 }
Example #11
0
        private Report CreateReport(string fileName)
        {
            string ext = Path.GetExtension(fileName);
            ext = ext.ToLower();

            var r = new Report();
            r.Title = "Oxyplot example report";

            var main = new ReportSection();

            r.AddHeader(1, "Example report from OxyPlot");

            // r.AddHeader(2, "Content");
            // r.AddTableOfContents(main);
            r.Add(main);

            main.AddHeader(2, "Introduction");
            main.AddParagraph("The content in this file was generated by OxyPlot.");
            main.AddParagraph("See http://oxyplot.codeplex.com for more information.");

            var dir = Path.GetDirectoryName(fileName);
            var name = Path.GetFileNameWithoutExtension(fileName);

            string fileNameWithoutExtension = Path.Combine(dir, name);

            main.AddHeader(2, "Plot");
            main.AddParagraph("This plot was rendered to a file and included in the report as a plot.");
            main.AddPlot(this.Model, "Plot", 800, 500);

            main.AddHeader(2, "Drawing");
            main.AddParagraph("Not yet implemented.");

            /*            switch (ext)
                        {
                            case ".html":
                                {
                                    main.AddHeader(2, "Plot (svg)");
                                    main.AddParagraph("This plot was rendered to a .svg file and included in the report.");
                                    main.AddPlot(Model, "SVG plot", 800, 500);

                                    //main.AddHeader(2, "Drawing (vector)");
                                    //main.AddParagraph("This plot was rendered to SVG and included in the report as a drawing.");
                                    //var svg = Model.ToSvg(800, 500);
                                    //main.AddDrawing(svg, "SVG plot as a drawing.");
                                    break;
                                }
                            case ".pdf":
                            case ".tex":
                                {
                                    main.AddHeader(2, "Plot (vector)");
                                    main.AddParagraph("This plot was rendered to a .pdf file and included in the report.");
                                    main.AddPlot(Model, "PDF plot", 800, 500);
                                    //var pdfPlotFileName = fileNameWithoutExtension + "_plot.pdf";
                                    //PdfExporter.Export(Model, pdfPlotFileName, 800, 500);
                                    //main.AddParagraph("This plot was rendered to PDF and embedded in the report.");
                                    //main.AddImage(pdfPlotFileName, "PDF plot");
                                    break;
                                }
                            case ".docx":
                                {
                                    main.AddHeader(2, "Plot");
                                    main.AddParagraph("This plot was rendered to a .png file and included in the report.");
                                    main.AddPlot(Model, "Plot", 800, 500);
                                }
                                break;
                        }*/
            main.AddHeader(2, "Image");
            main.AddParagraph("The plot is rendered to a .png file and included in the report as an image. Zoom in to see the difference.");

            string pngPlotFileName = fileNameWithoutExtension + "_Plot2.png";
            PngExporter.Export(this.Model, pngPlotFileName, 800, 500, OxyColors.Automatic);
            main.AddImage(pngPlotFileName, "Plot as image");

            main.AddHeader(2, "Data");
            int i = 1;
            foreach (OxyPlot.Series.DataPointSeries s in this.Model.Series)
            {
                main.AddHeader(3, "Data series " + (i++));
                var pt = main.AddPropertyTable("Properties of the " + s.GetType().Name, new[] { s });
                pt.Fields[0].Width = 50;
                pt.Fields[1].Width = 100;

                var fields = new List<ItemsTableField>
                    {
                        new ItemsTableField("X", "X") { Width = 60, StringFormat = "0.00" },
                        new ItemsTableField("Y", "Y") { Width = 60, StringFormat = "0.00" }
                    };
                main.Add(new ItemsTable { Caption = "Data", Fields = fields, Items = s.Points });
            }

            // main.AddHeader(3, "Equations");
            // main.AddEquation(@"E = m \cdot c^2");
            // main.AddEquation(@"\oint \vec{B} \cdot d\vec{S} = 0");
            return r;
        }