Ejemplo n.º 1
0
        /// <summary>
        /// Creates a report for the plot.
        /// </summary>
        /// <returns>
        /// A report.
        /// </returns>
        public Report CreateReport()
        {
            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", this);

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

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

            r.AddHeader(2, "=== Series ===");
            foreach (var s in this.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 !PCL
            var assemblyName = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
            r.AddParagraph(string.Format("Report generated by OxyPlot {0}", assemblyName.Version.ToString(3)));
#endif

            return(r);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
        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);
        }
Ejemplo n.º 5
0
        internal static void CreateNotReceiptReport(Database.Database db, DateTime reportAsOf)
        {
            if (db is null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            Report rpt = new Report("PendingReceipt");

            ExpenseOrder[] allorders  = db.GetOrders();
            var            orderables = db.GetOrderables();
            // Get list of orders that have at least one item that has not been received
            //var orders = allorders.Where(currentOrder => currentOrder.orderedItems.Any(currentOrderedItem => currentOrderedItem.Value.HasBeenReceived())).ToArray();
            var orders = allorders.Where(currentOrder => currentOrder.orderedItems.Any(currentOrderedItem => currentOrderedItem.Value.HasBeenReceived()));
            int totalNumberOfMissingItems = 0;

            orders.ToList().ForEach(x => x.orderedItems.ToList().ForEach(y =>
            {
                if (!y.Value.HasBeenReceived())
                {
                    totalNumberOfMissingItems++;
                }
            }));

            rpt.AddHeader("Introduction");
            rpt.AddBlank();
            rpt.AddLine($"This file describes the pending status of pharmacy expense items.  This file is accurate as of {reportAsOf.ToShortDateString()}.  There are {orders.Count(x=>x.orderedItems.Any(x=>!x.Value.HasBeenReceived()))} orders with pending items.  There are {totalNumberOfMissingItems} items that are pending.  These items are critical to the operation of the pharmacy.");
            rpt.AddBlank();
            rpt.AddHeader("Orders with Pending Items");
            rpt.AddLine("The following orders have pending items.");
            List <string> data = new List <string>();

            orders.ToList().ForEach(x =>
            {
                data.Add(x.OrderDate.ToShortDateString());
                data.Add(x.orderedItems.Count(y => !y.Value.HasBeenReceived()).ToString());
            });
            rpt.AddBlank();
            rpt.AddTable(new string[] { "Order Date", "Number of Pending Items" }, data.ToArray());
            rpt.AddBlank();
            rpt.AddHeader("Number of Pending Items per Wic");
            rpt.AddLine("The following are the number of items for each wic that are pending");
            rpt.AddBlank();
            data = new List <string>();
            Dictionary <int, int> wicToPendingItemCountMap = new Dictionary <int, int>();

            orders.ToList().ForEach(currentOrder => currentOrder.orderedItems.ToList().ForEach(currentItem =>
            {
                if (!currentItem.Value.HasBeenReceived())
                {
                    if (wicToPendingItemCountMap.ContainsKey(currentItem.Key.Wic))
                    {
                        wicToPendingItemCountMap[currentItem.Key.Wic] += currentItem.Value.orderedAmount;
                    }
                    else
                    {
                        wicToPendingItemCountMap.Add(currentItem.Key.Wic, currentItem.Value.orderedAmount);
                    }
                }
            }));
            foreach (KeyValuePair <int, int> item in wicToPendingItemCountMap)
            {
                Console.Write($"{item.Key}, {orderables.First(x=>x.Wic == item.Key).ItemName}, {item.Value}");
            }
            rpt.AddTable(new string[] { "Wic", "Item Name", "Number of Pending Items" }, data.ToArray());
            rpt.SaveReport();
        }