Пример #1
0
 /// <summary>
 /// Initializes the rendererInfo's xvalues. If not set by the user xvalues will be simply numbers
 /// from minimum scale + 1 to maximum scale.
 /// </summary>
 private void InitXValues(AxisRendererInfo rendererInfo)
 {
     rendererInfo.XValues = ((Chart)rendererInfo._axis._parent)._xValues;
     if (rendererInfo.XValues == null)
     {
         rendererInfo.XValues = new XValues();
         XSeries xs = rendererInfo.XValues.AddXSeries();
         for (double i = rendererInfo.MinimumScale + 1; i <= rendererInfo.MaximumScale; ++i)
         {
             xs.Add(i.ToString(rendererInfo.TickLabelsFormat));
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Initializes the rendererInfo's xvalues. If not set by the user xvalues will be simply numbers
 /// from minimum scale + 1 to maximum scale.
 /// </summary>
 private void InitXValues(AxisRendererInfo rendererInfo)
 {
     rendererInfo.XValues = ((Chart)rendererInfo.axis.parent).xValues;
     if (rendererInfo.XValues == null)
     {
         rendererInfo.XValues = new XValues();
         XSeries xs = rendererInfo.XValues.AddXSeries();
         for (double i = rendererInfo.MinimumScale + 1; i <= rendererInfo.MaximumScale; ++i)
         {
             xs.Add(i.ToString(CultureInfo.InvariantCulture));
         }
     }
 }
Пример #3
0
        private void GetData()
        {
            using (var reader = new StreamReader(@"D:\MyData\GithubRepos\Tutorials\GraphingExample\GraphingExample\TestData.csv"))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    XSeries.Add(double.Parse(values[0]));
                    YSeries.Add(double.Parse(values[1]));
                }
            }
        }
Пример #4
0
    public Chart GetPieChart(List <Group> chartGroup)
    {
        Chart chart = new Chart(ChartType.Pie2D);

        Series  series  = chart.SeriesCollection.AddSeries();
        XSeries xseries = chart.XValues.AddXSeries();

        for (int i = 0; i < chartGroup.Count; i++)
        {
            series.Add(chartGroup[i].GroupValue);
            xseries.Add(chartGroup[i].GroupName);
        }

        return(chart);
    }
Пример #5
0
        public static Chart LineChart()
        {
            // Set chart type to line
            Chart chart = new Chart(ChartType.Line);

            // Create first series with name and data
            Series series = chart.SeriesCollection.AddSeries();

            series.Name = "Series 1";
            series.Add(new double[] { 1, 12, -6, 15, 11 });

            // Create second series with name and data
            series      = chart.SeriesCollection.AddSeries();
            series.Name = "Series 2";
            series.Add(new double[] { 22, 4, 12, 8, 12 });

            // Create third series with name and data
            series      = chart.SeriesCollection.AddSeries();
            series.Name = "Series 3";
            series.Add(new double[] { 12, 17, -3, 18, 1 });

            // Set X axes
            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "X-Axis";
            //chart.XAxis.HasMajorGridlines = true;

            // Set Y axes
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.Title.Caption     = "Y-Axis";
            chart.YAxis.HasMajorGridlines = true;

            // Set plot area (chart diagram)
            chart.PlotArea.LineFormat.Color   = XColors.DarkGray;
            chart.PlotArea.LineFormat.Width   = 1;
            chart.PlotArea.LineFormat.Visible = true;

            // Set legend
            chart.Legend.Docking            = DockingType.Bottom;
            chart.Legend.LineFormat.Visible = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("A", "B", "C", "D", "E", "F");

            return(chart);
        }
Пример #6
0
        public static Chart PieChart()
        {
            Chart  chart  = new Chart(ChartType.Pie2D);
            Series series = chart.SeriesCollection.AddSeries();

            series.Add(new double[] { 1, 5, 11, -3, 20 });

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("Production", "Lab", "Licenses", "Taxes", "Insurances");
            chart.Legend.Docking = DockingType.Right;

            chart.DataLabel.Type     = DataLabelType.Percent;
            chart.DataLabel.Position = DataLabelPosition.OutsideEnd;

            return(chart);
        }
Пример #7
0
        private void Fill()
        {
            Section   section = _document.AddSection();
            Paragraph par     = _document.LastSection.AddParagraph("Цены самых продаваемых товаров", "Header");

            par.Format.Alignment = ParagraphAlignment.Center;
            section.AddParagraph().AddLineBreaks(3);
            //
            Chart chart = new Chart();

            chart.Left = 0;
            //
            chart.Width  = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(12);
            Series series = chart.SeriesCollection.AddSeries();

            series.ChartType = ChartType.Column2D;
            series.Add(furnitures.Select(f => (double)f.Price).ToArray());
            series.HasDataLabel = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(Enumerable.Range(1, furnitures.Count()).Select(n => n.ToString()).ToArray());

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            //
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

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

            _document.LastSection.Add(chart);
            par = _document.LastSection.AddParagraph();
            par.AddLineBreaks(2);
            par.AddTextLine("Легенда:");
            int i = 1;

            foreach (var f in furnitures)
            {
                par.AddTextLine(i.ToString() + " = " + "[" + f.VendorCode + "] " + f.Name);
                i++;
            }
        }
Пример #8
0
 void MapObject(XValues xValues, DocumentObjectModel.Shapes.Charts.XValues domXValues)
 {
     foreach (DocumentObjectModel.Shapes.Charts.XSeries domXSeries in domXValues)
     {
         XSeries xSeries = xValues.AddXSeries();
         DocumentObjectModel.Shapes.Charts.XSeriesElements domXSeriesElements = domXSeries.GetValue("XSeriesElements") as DocumentObjectModel.Shapes.Charts.XSeriesElements;
         foreach (DocumentObjectModel.Shapes.Charts.XValue domXValue in domXSeriesElements)
         {
             if (domXValue == null)
             {
                 xSeries.AddBlank();
             }
             else
             {
                 xSeries.Add(domXValue.GetValue("Value").ToString());
             }
         }
     }
 }
Пример #9
0
        public static void SpeciesPicturesInProject_PieChart(Document document, Project currentProject)
        {
            try {
                General_queries     projq = new General_queries(currentProject);
                List <SpeciesStats> stats = projq.AllStatsBySpecies;

                double[] speciesPictures = new double[stats.Count];
                string[] speciesNames    = new string[stats.Count];

                double speciesSum = 0;

                for (int i = 0; i < stats.Count; i++)
                {
                    speciesSum        += stats[i].SpeciesPictures;
                    speciesPictures[i] = stats[i].SpeciesPictures;
                    speciesNames[i]    = stats[i].SpeciesName;
                }

                document.LastSection.AddParagraph("Pictures in project where the species appears", "Heading2");

                Chart chart = new Chart();
                chart.Type = ChartType.Pie2D;
                chart.Left = 0;

                chart.Width  = Unit.FromCentimeter(10);
                chart.Height = Unit.FromCentimeter(8);

                Series series = chart.SeriesCollection.AddSeries();
                series.Add(speciesPictures);
                XSeries xseries = chart.XValues.AddXSeries();
                xseries.Add(speciesNames);

                chart.RightArea.AddLegend();

                chart.DataLabel.Type     = DataLabelType.Percent;
                chart.DataLabel.Position = DataLabelPosition.OutsideEnd;


                document.LastSection.Add(chart);
            } catch (Exception ex) {
                throw ex;
            }
        }
Пример #10
0
        public static void DefineCharts(Document document)
        {
            Paragraph paragraph = document.LastSection.AddParagraph("Chart Overview", "Heading1");

            paragraph.AddBookmark("Charts");

            document.LastSection.AddParagraph("Sample Chart", "Heading2");

            Chart chart = new Chart
            {
                Left   = 0,
                Width  = Unit.FromCentimeter(16),
                Height = Unit.FromCentimeter(12)
            };

            Series series = chart.SeriesCollection.AddSeries();

            series.ChartType = ChartType.Line;
            series.Add(new double[] { 41, 7, 5, 45, 13, 10, 21, 13, 18, 9 });
            // TODO: fix, no lines!

            series           = chart.SeriesCollection.AddSeries();
            series.ChartType = ChartType.Column2D;
            series.Add(new double[] { 1, 17, 45, 5, 3, 20, 11, 23, 8, 19 });
            series.HasDataLabel = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N");

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "X-Axis";

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

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

            document.LastSection.Add(chart);
        }
Пример #11
0
        public static void SpeciesTimeBehavior_BarChart(Document document, Project currentProject)
        {
            try {
                General_queries projq = new General_queries(currentProject);


                foreach (SpeciesStats spst in projq.AllStatsBySpecies)
                {
                    document.LastSection.AddParagraph(spst.SpeciesName + " Activity Patterns", "Heading2");

                    Chart chart = new Chart();
                    chart.Left = 0;

                    chart.Width  = Unit.FromCentimeter(16);
                    chart.Height = Unit.FromCentimeter(12);
                    Series series = chart.SeriesCollection.AddSeries();
                    series.ChartType = ChartType.Column2D;
                    series.Add(spst.ActivityPatern);
                    series.HasDataLabel = true;

                    XSeries xseries = chart.XValues.AddXSeries();
                    xseries.Add("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23");

                    chart.XAxis.MajorTickMark = TickMarkType.Outside;
                    chart.XAxis.Title.Caption = "Hours of day";

                    chart.YAxis.MajorTickMark     = TickMarkType.Outside;
                    chart.YAxis.HasMajorGridlines = true;
                    chart.YAxis.MajorGridlines.LineFormat.Color = Colors.DarkGray;
                    chart.YAxis.Title.Caption = "Freq";

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

                    document.LastSection.Add(chart);
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
Пример #12
0
        public static Chart PieChart()
        {
            // Set chart type to Pie2D
            Chart chart = new Chart(ChartType.Pie2D);

            // Add series data
            Series series = chart.SeriesCollection.AddSeries();

            series.Add(new double[] { 1, 5, 11, 3, 20 });

            // Add series legend
            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("Series 1", "Series 2", "Series 3", "Series 4", "Series 5");
            chart.Legend.Docking = DockingType.Right;

            // Set label display type
            chart.DataLabel.Type = DataLabelType.Percent;

            // Set label location
            chart.DataLabel.Position = DataLabelPosition.Center;

            return(chart);
        }
Пример #13
0
        public static Chart LineChart()
        {
            Chart  chart  = new Chart(ChartType.Line);
            Series series = chart.SeriesCollection.AddSeries();

            series.Name = "Series 1";
            series.Add(new double[] { 1, 5, -3, 20, 11 });

            series      = chart.SeriesCollection.AddSeries();
            series.Name = "Series 2";
            series.Add(new double[] { 22, 4, 12, 8, 12 });

            series      = chart.SeriesCollection.AddSeries();
            series.Name = "Series 3";
            series.Add(new double[] { 12, 14, -3, 18, 1 });

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "X-Axis";

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.Title.Caption     = "Y-Axis";
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color   = XColors.DarkGray;
            chart.PlotArea.LineFormat.Width   = 1;
            chart.PlotArea.LineFormat.Visible = true;

            chart.Legend.Docking            = DockingType.Bottom;
            chart.Legend.LineFormat.Visible = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("A", "B", "C", "D", "E", "F");

            return(chart);
        }
        public FileContentResult GetRelatorioPDF(int cliente, String de = null, String ate = null)
        {
            IQueryable <OSSB> queryObject = _db.OSSB;

            queryObject = from os in queryObject
                          where os.CLIENTE == cliente
                          select os;

            if (de != null)
            {
                DateTime deDate = DateTime.ParseExact(de, "dd/MM/yyyy", null);

                if (ate != null)
                {
                    DateTime ateDate = DateTime.ParseExact(ate, "dd/MM/yyyy", null);

                    queryObject = from os in queryObject
                                  where _db.OSSB_CHECK_LIST.Where(oscl => oscl.OSSB == os.ID && oscl.AGENDADO >= deDate && oscl.AGENDADO <= ateDate).Any()
                                  select os;
                }
                else
                {
                    queryObject = from os in queryObject
                                  where _db.OSSB_CHECK_LIST.Where(oscl => oscl.OSSB == os.ID && oscl.AGENDADO >= deDate).Any()
                                  select os;
                }
            }
            else
            if (ate != null)
            {
                DateTime ateDate = DateTime.ParseExact(ate, "dd/MM/yyyy", null);

                queryObject = from os in queryObject
                              where _db.OSSB_CHECK_LIST.Where(oscl => oscl.OSSB == os.ID && oscl.AGENDADO <= ateDate).Any()
                              select os;
            }

            var fs = new MemoryStream();

            PdfDocument document = new PdfDocument();
            PdfPage     page     = document.AddPage();



            XFont titleFont = new XFont("Times New Roman", 20, XFontStyle.Bold);

            XFont normalFont = new XFont("Times New Roman", 14, XFontStyle.Bold);

            ChartFrame cf = new ChartFrame()
            {
                Location = new XPoint(page.Width.Point * .05, 60),
                Size     = new XSize(page.Width.Point * .9, page.Width.Point * 0.7)
            };

            Chart chart = new Chart(ChartType.Pie2D);

            Series series = chart.SeriesCollection.AddSeries();

            var queryPreventiva = (from os in queryObject
                                   where os.TIPO == "P"
                                   group os by
                                       (os.SITUACAO == "P" || os.SITUACAO == "K" || os.SITUACAO == "F") ? 0 : 1 into g
                                   select new
            {
                TIPO = g.Key,
                QUANTIDADE = g.Count()
            }).ToDictionary(en => en.TIPO, en => en.QUANTIDADE);


            series.Add(new double[] { queryPreventiva.GetValueOrDefault(0, 0), queryPreventiva.GetValueOrDefault(1, 0) });

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add("Realizadas", "Pendentes");

            chart.DataLabel.Type = DataLabelType.Value;

            chart.HasDataLabel = true;

            chart.Legend.Docking = DockingType.Left;

            chart.DataLabel.Position = DataLabelPosition.OutsideEnd;

            cf.Add(chart);

            XGraphics gfx = XGraphics.FromPdfPage(page);

            gfx.DrawRectangle(XPens.Black, new XRect(150, 600, (page.Width.Point - 300) * 0.7, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150, 630, (page.Width.Point - 300) * 0.7, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150, 660, (page.Width.Point - 300) * 0.7, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150, 690, (page.Width.Point - 300) * 0.7, 30));



            gfx.DrawRectangle(XPens.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 600, (page.Width.Point - 300) * 0.3, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 630, (page.Width.Point - 300) * 0.3, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 660, (page.Width.Point - 300) * 0.3, 30));

            gfx.DrawRectangle(XPens.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 690, (page.Width.Point - 300) * 0.3, 30));

            gfx.DrawString("Mês", normalFont, XBrushes.Black, new XRect(150, 600, (page.Width.Point - 300) * 0.7, 30), XStringFormats.Center);
            gfx.DrawString("Previstas", normalFont, XBrushes.Black, new XRect(150, 630, (page.Width.Point - 300) * 0.7, 30), XStringFormats.Center);
            gfx.DrawString("Realizadas", normalFont, XBrushes.Black, new XRect(150, 660, (page.Width.Point - 300) * 0.7, 30), XStringFormats.Center);
            gfx.DrawString("Pendentes", normalFont, XBrushes.Black, new XRect(150, 690, (page.Width.Point - 300) * 0.7, 30), XStringFormats.Center);

            gfx.DrawString((queryPreventiva.GetValueOrDefault(0, 0) + queryPreventiva.GetValueOrDefault(1, 0)).ToString(), normalFont, XBrushes.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 630, (page.Width.Point - 300) * 0.3, 30), XStringFormats.Center);
            gfx.DrawString(queryPreventiva.GetValueOrDefault(0, 0).ToString(), normalFont, XBrushes.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 660, (page.Width.Point - 300) * 0.3, 30), XStringFormats.Center);
            gfx.DrawString((queryPreventiva.GetValueOrDefault(1, 0)).ToString(), normalFont, XBrushes.Black, new XRect(150 + (page.Width.Point - 300) * 0.7, 690, (page.Width.Point - 300) * 0.3, 30), XStringFormats.Center);



            gfx.DrawString("1. Manutenção Preventiva.", titleFont, XBrushes.Black, new XPoint(10, 25));

            cf.Draw(gfx);

            page = document.AddPage();

            gfx = XGraphics.FromPdfPage(page);

            cf = new ChartFrame()
            {
                Location = new XPoint(page.Width.Point * .05, 60),
                Size     = new XSize(page.Width.Point * .9, page.Width.Point * 0.7)
            };


            chart = new Chart(ChartType.Pie2D);

            var queryCorretiva = (from os in queryObject
                                  where os.TIPO == "C"
                                  select os)
                                 .GroupBy(os => (os.SITUACAO == "P" || os.SITUACAO == "K" || os.SITUACAO == "F") ? 0 : (os.SITUACAO == "E" ? 1 : 2))
                                 .Select(g => new { TIPO = g.Key, QUANTIDADE = g.Count() })
                                 .ToDictionary(os => os.TIPO, os => os.QUANTIDADE);

            xseries = chart.XValues.AddXSeries();

            series = chart.SeriesCollection.AddSeries();

            if (queryCorretiva.ContainsKey(0))
            {
                xseries.Add("Executando");
                series.Add(queryCorretiva[0]);
            }

            if (queryCorretiva.ContainsKey(1))
            {
                xseries.Add("Realizadas");
                series.Add(queryCorretiva[1]);
            }

            if (queryCorretiva.ContainsKey(2))
            {
                xseries.Add("Emergênciais");
                series.Add(queryCorretiva[2]);
            }



            chart.DataLabel.Type = DataLabelType.Value;

            chart.HasDataLabel = true;

            chart.Legend.Docking = DockingType.Left;

            chart.DataLabel.Position = DataLabelPosition.OutsideEnd;

            cf.Add(chart);


            cf.Draw(gfx);

            document.Save(fs, false);

            Response.AppendHeader("Content-Disposition", "inline; filename=relatorio.pdf;");

            return(new FileContentResult(fs.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf));
        }
Пример #15
0
        // define the charting page for the resistance values
        static void DefineResistanceChart(Document document)
        {
            Paragraph paragraph = document.LastSection.AddParagraph("Battery Resistance Chart", "Heading1");

            //paragraph.AddBookmark("ResistanceChart");

            paragraph = document.LastSection.AddParagraph("Cell Resistances", "Heading2");
            paragraph.Format.OutlineLevel = OutlineLevel.BodyText;

            Chart chart = new Chart();

            chart.Left = 0;

            chart.Width  = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(12);

            Series series = chart.SeriesCollection.AddSeries();

            series.ChartType = ChartType.Column2D;

            // create an array of all the battery cell voltages and cell numbers to use as values
            List <double> resistanceValuesList = new List <double>();
            List <string> cellXlabels          = new List <string>();

            // depending on the number of cells, need to suss out a gap say every 10%
            int xSpacing = (int)(currentResult.cellReadingsList.Count * 0.1);

            if (xSpacing < 1)
            {
                xSpacing = 1;
            }

            foreach (CellReading reading in currentResult.cellReadingsList)
            {
                //add the resistance values to the table series
                resistanceValuesList.Add(reading.resistance);
                // add the corresponding x labelling to the series, but try and space them out if theres alot

                if (reading.cellNumber % xSpacing == 0)
                {
                    cellXlabels.Add(reading.cellNumber.ToString());
                    //Console.WriteLine(reading.cellNumber.ToString());
                }
                else
                {
                    cellXlabels.Add("");
                }
            }

            // now add the voltage data to the chart series
            series.Add(resistanceValuesList.ToArray());
            series.HasDataLabel = false;

            // now to color the bar graph for the resistance values depending on the current test thresholds
            var elements = series.Elements.Cast <Point>().ToArray();
            // since each of the elements will be the same index as the readings, loop through and color accordingly
            int counterIndex = 0;

            foreach (CellReading reading in currentResult.cellReadingsList)
            {
                if (currentResult.lowResistance_threshold == currentResult.highResistance_threshold)
                {
                    elements[counterIndex].FillFormat.Color = Colors.Blue;
                }
                else if (reading.resistance > currentResult.highResistance_threshold)
                {
                    elements[counterIndex].FillFormat.Color = Colors.Red;
                }
                else if (reading.resistance < currentResult.lowResistance_threshold)
                {
                    elements[counterIndex].FillFormat.Color = Colors.Yellow;
                }
                else
                {
                    elements[counterIndex].FillFormat.Color = Colors.Blue;
                }
                counterIndex++;
            }

            // create the xlabel series and add the cell numbers
            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(cellXlabels.ToArray());

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "Cell Numbers";

            // y values min and max
            double yMin, yMax;

            yMin = currentResult.GetMinResistanceValueAsDouble();
            yMax = currentResult.GetMaxResistanceValueAsDouble();

            chart.YAxis.MajorTickMark = TickMarkType.Outside;
            chart.YAxis.MajorTick     = (yMax - yMin) * 0.1;
            //chart.YAxis.TickLabels.Format = "0";
            chart.YAxis.HasMajorGridlines = true;

            // now to set up the Y axis scales, need to get the min and max floats and put a small tollerance either side
            // just so that the min and max values arent slap bang on the axis lines

            double chartYAxisPadding = (yMax - yMin) * 0.1; // just 10 percent padding for min and max charting values

            chart.YAxis.MinimumScale = currentResult.GetMinResistanceValueAsDouble() - chartYAxisPadding;
            chart.YAxis.MaximumScale = currentResult.GetMaxResistanceValueAsDouble() + chartYAxisPadding;

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

            document.LastSection.Add(chart);
        }
        private Chart GenerateOneEquityChart(List <VMDynamics> lstVMDyn, DateTime dtBegin, DateTime dtEnd)
        {
            Chart chart = new Chart();

            chart.XAxis.MajorTick = 10;
            chart.Left            = 0;

            chart.Width  = Unit.FromCentimeter(19);
            chart.Height = Unit.FromCentimeter(8);
            Series series = chart.SeriesCollection.AddSeries();

            series.ChartType = ChartType.Line;

            series.HasDataLabel = true;



            XSeries       xseries = chart.XValues.AddXSeries();
            List <string> lstDt   = new List <string>();

            //   DateTime dtBegin =   ((DateTime) _reportData.DataStockExchResultsTable["DtBegin"]);
            //DateTime dtBegin = new DateTime(2016, 9, 22, 10, 0, 0);

            // DateTime dtEnd = new DateTime(2016, 9, 22, 18, 45, 0);



            CVMDynDataTraceGenerator vmproc = new CVMDynDataTraceGenerator(_reportData.ListVMDynamics);


            List <string> lstOutX;
            List <double> lstOutY;

            vmproc.GetVMTrendList(dtBegin, dtEnd, 10, 0, out lstOutX, out lstOutY);



            series.Add(lstOutY.ToArray());


            xseries.Add(lstOutX.ToArray());
            //int[] arr = new string[] { "10:00", 5, 10, 15, 21 };

            //    xseries.Add(arr);

            //xseries.Add(new string[] {  new DateTime(2016, 9, 1,0,0,0).ToString("HH:mm") ,  new DateTime(2016, 9, 1, 0,10,0).ToString("HH:mm")  });

            //

            chart.XAxis.MajorTickMark                  = TickMarkType.Outside;
            chart.XAxis.HasMajorGridlines              = true;
            chart.XAxis.HasMinorGridlines              = true;
            chart.SeriesCollection[0].MarkerSize       = 2;
            chart.SeriesCollection[0].LineFormat.Width = 1.0;

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMinorGridlines = true;
            chart.YAxis.HasMajorGridlines = true;

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

            return(chart);
        }
Пример #17
0
        private static void DefineCharts(Document document, string person, Dictionary <string, string[]> groups, DataHandler datahandler)
        {
            List <double[]> list  = new List <double[]>();
            List <String>   names = new List <string>();
            YearInfo        year  = datahandler.GetYear(datahandler.FirstAvailableYear);

            /***** Calculate series data ******/

            foreach (KeyValuePair <string, string[]> pair in groups)
            {
                String[] kgms        = pair.Value;
                double[] percentages = new double[12];
                names.Add(pair.Key);
                for (int i = 0; i < 12; i++)
                {
                    if (year[i] != null)
                    {
                        Salesman sm = year[i].GetSalesman(person);
                        if (sm != null)
                        {
                            percentages[i] = sm.PercentOfTotal(kgms);
                        }
                        else
                        {
                            percentages[i] = 0;
                        }
                    }
                    else
                    {
                        percentages[i] = 0;
                    }
                }
                list.Add(percentages);
            }

            double[] oms = new double[12];
            for (int i = 0; i < 12; i++)
            {
                if (year[i] != null)
                {
                    Salesman sm = year[i].GetSalesman(person);
                    if (sm != null)
                    {
                        oms[i] = sm.Omsaetning;
                    }
                    else
                    {
                        oms[i] = 0;
                    }
                }
                else
                {
                    oms[i] = 0;
                }
            }

            double[] ind = new double[12];
            for (int i = 0; i < 12; i++)
            {
                if (year[i] != null)
                {
                    Salesman sm = year[i].GetSalesman(person);
                    if (sm != null)
                    {
                        ind[i] = sm.Indtjening;
                    }
                    else
                    {
                        ind[i] = 0;
                    }
                }
                else
                {
                    ind[i] = 0;
                }
            }

            /***** Create chart for omsætning/indtjening series ******/

            MigraDoc.DocumentObjectModel.Paragraph paragraph = document.LastSection.AddParagraph("Sælger Diagram", "Heading1");
            Chart chart = new Chart();

            chart.Left   = 0;
            chart.Width  = Unit.FromCentimeter(22);
            chart.Height = Unit.FromCentimeter(15);

            MigraDoc.DocumentObjectModel.Shapes.Charts.Series series = chart.SeriesCollection.AddSeries();
            series.ChartType        = ChartType.Line;
            series.LineFormat.Width = 10;
            series.Add(oms);
            series.SetNull();
            series.Name = "Omsætning";

            series                  = chart.SeriesCollection.AddSeries();
            series.ChartType        = ChartType.Line;
            series.LineFormat.Width = 10;
            series.Add(ind);
            series.SetNull();
            series.Name = "Indtjening";

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(new string[] { "Maj", "Juni", "Juli", "Aug", "Sep", "Okt", "Nov", "Dec", "Jan", "Feb", "Marts", "April" });
            chart.XAxis.MajorTickMark = TickMarkType.Inside;
            chart.XAxis.Title.Caption = "MÅNEDER";

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            chart.PlotArea.LineFormat.Width = 1;
            chart.LeftArea.AddLegend();
            document.LastSection.Add(chart);

            /***** Create chart for KGM series ******/

            paragraph    = document.LastSection.AddParagraph("Sælger Diagram", "Heading1");
            chart        = new Chart();
            chart.Left   = 0;
            chart.Width  = Unit.FromCentimeter(22);
            chart.Height = Unit.FromCentimeter(15);

            for (int i = 0; i < list.Count; i++)
            {
                series                  = chart.SeriesCollection.AddSeries();
                series.ChartType        = ChartType.Line;
                series.LineFormat.Width = 10;
                series.Add(list[i]);
                series.SetNull();
                series.Name = names[i];
            }

            xseries = chart.XValues.AddXSeries();
            xseries.Add(new string[] { "Maj", "Juni", "Juli", "Aug", "Sep", "Okt", "Nov", "Dec", "Jan", "Feb", "Marts", "April" });
            chart.XAxis.MajorTickMark = TickMarkType.Inside;
            chart.XAxis.Title.Caption = "MÅNEDER";

            chart.YAxis.TickLabels.Format = "#0%";
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            chart.PlotArea.LineFormat.Width = 1;
            chart.LeftArea.AddLegend();
            document.LastSection.Add(chart);
        }
Пример #18
-1
        public PdfSharp.Charting.Chart LineChart()
        {
            List <Activity> filteredProfitExpenses;

            if (SelectedType.Equals(Constants.PROFIT))
            {
                if (!SelectedCategory.Equals(Constants.ALL_DATA))
                {
                    List <Activity> profits = profitActivities.Where(p => p.category.Equals(SelectedCategory)).ToList();
                    filteredProfitExpenses = filterPeriod(profits);
                }
                else
                {
                    filteredProfitExpenses = filterPeriod(profitActivities);
                }
            }
            else if (SelectedType.Equals(Constants.EXPENSE))
            {
                if (!SelectedCategory.Equals(Constants.ALL_DATA))
                {
                    List <Activity> expenses = expenseActivities.Where(p => p.category.Equals(SelectedCategory)).ToList();
                    filteredProfitExpenses = filterPeriod(expenses);
                }
                else
                {
                    filteredProfitExpenses = filterPeriod(expenseActivities);
                }
            }
            else
            {
                filteredProfitExpenses = filterPeriod(profitExpenses);
            }

            PdfSharp.Charting.Chart chart = new PdfSharp.Charting.Chart(ChartType.Line);
            Series series;

            if (filteredProfitExpenses.Find(o => o.type.Equals(Constants.PROFIT)) != null)
            {
                series      = chart.SeriesCollection.AddSeries();
                series.Name = "Profit";
                series.Add(filteredProfitExpenses
                           .Where(o => o.type.Equals(Constants.PROFIT)).ToList()
                           .ConvertAll(o => o.amount).ToArray());
            }

            if (filteredProfitExpenses.Find(o => o.type.Equals(Constants.EXPENSE)) != null)
            {
                series      = chart.SeriesCollection.AddSeries();
                series.Name = "Expense";
                series.Add(filteredProfitExpenses
                           .Where(o => o.type.Equals(Constants.EXPENSE)).ToList()
                           .ConvertAll(o => o.amount).ToArray());
            }

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.XAxis.Title.Caption = "Date";

            chart.YAxis.MajorTickMark     = TickMarkType.Outside;
            chart.YAxis.Title.Caption     = "Amount";
            chart.YAxis.HasMajorGridlines = true;

            chart.PlotArea.LineFormat.Color   = XColors.DarkGray;
            chart.PlotArea.LineFormat.Width   = 1;
            chart.PlotArea.LineFormat.Visible = true;

            chart.Legend.Docking            = DockingType.Bottom;
            chart.Legend.LineFormat.Visible = true;

            XSeries xseries = chart.XValues.AddXSeries();

            xseries.Add(filteredProfitExpenses.ConvertAll(o => o.dateTime.ToShortDateString()).ToArray());

            return(chart);
        }