Esempio n. 1
0
        public static MeteoGtzYear ToRelativeData(this MeteoGtzYear meteoGtzSumYears)
        {
            var relVorJahr = Utils.GetProzentual(meteoGtzSumYears.Period1, meteoGtzSumYears.Period2);
            var relVorVorJahr = Utils.GetProzentual(meteoGtzSumYears.Period1, meteoGtzSumYears.Period3);
            var relLgtz = Utils.GetProzentual(meteoGtzSumYears.Period1, meteoGtzSumYears.Lgtz);

            var result = new MeteoGtzYear
            {
                //IsHeizperiode = isHeizperiode,
                //Period1 = 100,
                Period2 = relVorJahr,
                Period3 = relVorVorJahr,
                Lgtz = relLgtz
            };
            return result;
        }
Esempio n. 2
0
        public async Task<MeteoGtzYear> GetGtzYearsSum(
            CalculateRequest calculateRequest,
            bool isHeizperiode,
            IntervalType intervalType = IntervalType.M36)
        {
            var source = await this.GetGtzByPeriods(calculateRequest, intervalType);
            source = isHeizperiode ? source.Where(p => p.Monat.IsHeizMonat()) : source;

            var meteoGtzPeriods = source.ToList();

            if (meteoGtzPeriods.Count == 0)
            {
                return null;
            }

            var result = new MeteoGtzYear
            {
                //IsHeizperiode = isHeizperiode,
                Period1 = meteoGtzPeriods.Sum(p => p.Period1),
                Period2 = meteoGtzPeriods.Sum(p => p.Period2),
                Period3 = meteoGtzPeriods.Sum(p => p.Period3),
                Lgtz = meteoGtzPeriods.Sum(p => p.Lgtz)
            };
            return result;
        }
Esempio n. 3
0
        public static UltraChart GetChart(MeteoGtzYear meteoGtzYear, int width, int height, bool pdf = false)
        {
            isPdf = pdf;

            var relativeDataForChart = meteoGtzYear.ToRelativeDataForChart();
            var datasource = relativeDataForChart.ToDataTable();

            var chart = new UltraChartEx();
            chart.ExtraData = meteoGtzYear;
            AddAnnotation(chart, meteoGtzYear, pdf);

            chart.FillSceneGraph += ChartOnFillSceneGraph;
            //.ID = "ChartVergleichJahr"
            chart.DeploymentScenario = deploymentScenario;
            chart.Width = width;
            chart.Height = height;
            chart.Border.Thickness = 0;
            

            var colorModel = chart.ColorModel;
            colorModel.ModelStyle = ColorModels.CustomLinear;
            //.AlphaLevel = 150
            colorModel.CustomPalette = Constants.YearsChartColors;

            var gradientEffect = new GradientEffect
            {
                Coloring = GradientColoringStyle.Darken
            };
            chart.Effects.Add(gradientEffect);


            chart.ChartType = ChartType.ColumnChart;
            chart.ImagePipePageName = Constants.ImagePipePageName;

            var data = chart.Data;
            data.SetColumnLabels(new string[] {
		        "Aktuelles Jahr",
		        "Vorjahr",
                "Vorvorjahr"
	        });
            

            data.UseRowLabelsColumn = true;
            data.ZeroAligned = true;

            var cta = new ChartTextAppearance();
            cta.ItemFormatString = "<DATA_VALUE:#0.00>";
            cta.Visible = false;
            cta.ChartTextFont = new Font("Arial", 5, FontStyle.Regular, GraphicsUnit.Point);
            cta.Column = -2;
            cta.Row = -2;
            cta.VerticalAlign = StringAlignment.Far;
            cta.HorizontalAlign = StringAlignment.Center;

            var columnChart = chart.ColumnChart;
            columnChart.ChartText.Add(cta);
            columnChart.ColumnSpacing = 4;
            columnChart.SeriesSpacing = 1;


            var legend = chart.Legend;
            legend.Visible = false;            

            var margins = legend.Margins;
            margins.Bottom = 1;
            margins.Top = 1;
            margins.Left = 50;
            margins.Right = 1;

            ////'*** Implementierungs IRenderLabel für die Labels-Formatierung 
            //Hashtable labelHash = new Hashtable();
            //labelHash.Add("MY_LABEL", new MyLabelRenderer());
            //chart.LabelHash = labelHash;
            //chart.Axis.X.Labels.ItemFormat = AxisItemLabelFormat.Custom;
            //chart.Axis.X.Labels.ItemFormatString = "<MY_LABEL>";
            ////'*** END Implementierungs IRenderLabel-Interface für die Labels-Formatierung

            var axisX = chart.Axis.X;
            axisX.Extent = 15;
            //axisX.LineColor = Color.Green;
            axisX.LineThickness = 1;
            axisX.TickmarkStyle = AxisTickStyle.Smart;
            axisX.TickmarkInterval = 1;
            //axisX.Labels.Visible = false;
            axisX.Labels.ItemFormatString = "<ITEM_LABEL>";
            axisX.Labels.Orientation = TextOrientation.Horizontal;
            axisX.Labels.HorizontalAlign = StringAlignment.Near;
            axisX.Labels.VerticalAlign = StringAlignment.Center;
            axisX.Labels.Font = new Font("Verdana", 8, FontStyle.Regular, GraphicsUnit.Point);
            axisX.Labels.FontColor = Color.Black;

            
            axisX.Labels.SeriesLabels.Visible = false;
           
            axisX.MajorGridLines.Visible = false;
            axisX.MinorGridLines.Visible = false;
            axisX.Margin.Near.Value = MarginX;
            axisX.Margin.Far.Value = MarginX;

            var axisY = chart.Axis.Y;
            axisY.Extent = 65;
            axisY.LineThickness = 1;
            axisY.TickmarkInterval =2;
            axisY.TickmarkStyle = AxisTickStyle.Percentage;            
            axisY.Labels.Visible = false;
            axisY.MajorGridLines.Visible = false;
            axisY.MinorGridLines.Visible = false;   
            axisY.LineEndCapStyle = LineCapStyle.ArrowAnchor;
            axisY.RangeType = AxisRangeType.Custom;
            axisY.RangeMax = 130;
          

            var titleLeft = chart.TitleLeft;
            titleLeft.Visible = true;
            titleLeft.Extent = 15;
            titleLeft.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point);
            titleLeft.HorizontalAlign = StringAlignment.Center;
            titleLeft.VerticalAlign = StringAlignment.Center;
            //titleLeft.Text = "Temperatur";
            var titleLeftmargins = titleLeft.Margins;
            titleLeftmargins.Bottom = 1;
            titleLeftmargins.Top = 1;
            titleLeftmargins.Left = 1;
            titleLeftmargins.Right = 1;

            var titleTop = chart.TitleTop;
            titleTop.Extent = 25;
            titleTop.Font = new Font("Verdana", 9, FontStyle.Regular, GraphicsUnit.Point);
            titleTop.Text = " ";

            var titleTopMargins = titleTop.Margins;
            titleTopMargins.Bottom = 15;
            titleTopMargins.Top = 0;
            titleTopMargins.Left = 25;
            titleTopMargins.Right = 0;

            var titleBottom = chart.TitleBottom;
            titleBottom.Text = "";
            titleBottom.Extent = 33;
            titleBottom.Font = new Font("Microsoft Sans Serif", 9.75f, FontStyle.Bold, GraphicsUnit.Point);
            titleBottom.HorizontalAlign = StringAlignment.Center;
            var titleBottomMargins = titleBottom.Margins;
            titleBottomMargins.Bottom = 1;
            titleBottomMargins.Top = 1;
            titleBottomMargins.Left = 1;
            titleBottomMargins.Right = 1;

            var tooltips = chart.Tooltips;
            tooltips.FormatString = "<DATA_VALUE:#0.00>%";

            data.DataSource = datasource;
            data.DataBind();
            try
            {
                data.IncludeColumn("LGTZ", false);
            }
            catch (Exception exception)
            {

            }

            return chart;
        }
Esempio n. 4
0
        public void AddJahresbetrachtung( MeteoGtzYear meteoGtzYear)
        {

            this.CreateHeading("1. Jahresbetrachtung der heizwirksamen Temperatur des aktuellen Jahres im Vergleich zu den Vorjahren und Langzeitmittel²");

            // Add grid 
            IGrid grid = this.currentBand.AddGrid();

            IText text;
            Style textStyle = new Style(this.pdfFonts[PdfFont.DefaultNormalReg], Brushes.Black);
            Style headerStyle = new Style(this.pdfFonts[PdfFont.DefaultNormalBold], Brushes.Black);


            // Grid pattern for borders around block
            var gridPattern = new GridPattern
            {
                Borders = new Borders(new Pen(Colors.Black)),
                Paddings =
                {
                    All = 10
                }
            };
            gridPattern.Apply(grid);

            var column = grid.AddColumn();
            var gridRow = grid.AddRow();
            var gridCell = gridRow.AddCell();


            GridCellPattern cellPattern = new GridCellPattern
            {
                Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle),
                Paddings =
                {
                    Left = 10,
                    Bottom = 0
                }
            };

            //cellPattern.Apply(gridCell);
            //text = gridCell.AddText();
            //text.Style.Font = pdfFonts[PdfFont.DefaultNormalReg];
            //text.AddContent("Alle Angaben sind immer konkret bezogen auf die getroffene Auswahl hinsichtlich Abrech-nungszeitraum (Stichtag) " + "und die ausgewählte Region. Basis sind dabei immer die Tages-mitteltemperaturen. Betrachtet werden immer " + "ganzjährige Abrechnungszeiträume.");
            //text.AddLineBreak();
            //text.AddLineBreak();

            //Add Chart
            gridRow = grid.AddRow();
            gridCell = gridRow.AddCell();

            ICanvas canvas = gridCell.AddCanvas();
            canvas.Width = new FixedWidth(440);
            canvas.Height = new FixedHeight(190);
            using (System.Drawing.Graphics g = canvas.CreateGraphics())
            {
                UltraChart myChart = JahresbetrachtungChart.GetChart(meteoGtzYear, 440, 190, true);
                //myChart.ColumnChart.ChartText(0).Visible = True
                myChart.Legend.Visible = false;
                myChart.RenderPdfFriendlyGraphics(g);
            }
                
            gridRow = grid.AddRow();
            gridCell = gridRow.AddCell();
            cellPattern.Apply(gridCell);

            text = gridCell.AddText();
            text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg];
            //text.Paddings.Top = 5;

            var relativeData = meteoGtzYear.ToRelativeData();

            double vorjahrBedarf = relativeData.Period2;
            double lgtzBedarf = relativeData.Lgtz;
            var vorjahrBedarfText = string.Format(
                        @"In der gewählten Region war es im gleichen Zeitraum des Vorjahres {0}% {1} als im betrachteten Zeiraum des aktuellen Jahres.
Entsprechend ist im aktuellen Jahr im Vergleich zum Vorjahreszeitraum mit einem Heiz{2}bedarf zu rechnen.",
                Math.Abs(Math.Round(vorjahrBedarf, 2)), (vorjahrBedarf > 0 ? "wärmer" : "kälter"), (vorjahrBedarf > 0 ? "mehr" : "minder"));
            var lgtzBedarfText = string.Format("In der gewählten Region ist das Langzeitmittel {0}% {1} als das aktuelle Jahr.", Math.Abs(Math.Round(lgtzBedarf, 2)), (lgtzBedarf > 0 ? "wärmer" : "kälter"));

            //text.AddLineBreak();
            text.AddContent(vorjahrBedarfText);
            text.AddLineBreak();
            text.AddLineBreak();
            text.AddContent(lgtzBedarfText);
            
        }
Esempio n. 5
0
        private static void AddAnnotation(UltraChart chart, MeteoGtzYear meteoGtzYear, bool pdf)
        {
            var relativeData = meteoGtzYear.ToRelativeData();

            var textStyle = new LabelStyle
            {
                Font = new Font("Verdana", pdf ? 6.5f : 8.5f, FontStyle.Italic, GraphicsUnit.Point),
                FontColor = Constants.YearsChartColors[1],
                HorizontalAlign = StringAlignment.Center,
                FontSizeBestFit = false,
                ClipText = true,
                Orientation = TextOrientation.Horizontal,
                WrapText = false,
                Flip = true,
                VerticalAlign = StringAlignment.Center,
                Dy = 0
            };
            var ann = new TextAnnatation
            {
                Width = pdf ? 80 : -1,
                Location = new Location
                {
                    Type = LocationType.RowColumn,
                    Row = 0,
                    Column = 1
                },
                Text = GetAnnotationText(relativeData.Period2, "war um"),
                TextStyle = textStyle
            };
            chart.Annotations.Add(ann);

            ann = new TextAnnatation
            {
                Width = pdf ? 80 : -1,
                Location = new Location
                {
                    Type = LocationType.RowColumn,
                    Row = 0,
                    Column = 2,
                    ValueY = meteoGtzYear.Period2
                },
                Text = GetAnnotationText(relativeData.Period3, "war um"),
                TextStyle = textStyle
            };
            chart.Annotations.Add(ann);
        }