コード例 #1
0
        /// <summary>
        /// Calculates the space used for the Y axis.
        /// </summary>
        internal override void Format()
        {
            AxisRendererInfo yari = ((ChartRendererInfo)this.rendererParms.RendererInfo).yAxisRendererInfo;

            if (yari.axis != null)
            {
                XGraphics gfx = this.rendererParms.Graphics;

                XSize size = new XSize(0, 0);

                // height of all ticklabels
                double yMin       = yari.MinimumScale;
                double yMax       = yari.MaximumScale;
                double yMajorTick = yari.MajorTick;
                double lineHeight = Double.MinValue;
                XSize  labelSize  = new XSize(0, 0);
                for (double y = yMin; y <= yMax; y += yMajorTick)
                {
                    string str = y.ToString(yari.TickLabelsFormat);
                    labelSize   = gfx.MeasureString(str, yari.TickLabelsFont);
                    size.Width += labelSize.Width;
                    size.Height = Math.Max(labelSize.Height, size.Height);
                    lineHeight  = Math.Max(lineHeight, labelSize.Width);
                }

                // add space for tickmarks
                size.Height += yari.MajorTickMarkWidth * 1.5;

                // Measure axis title
                XSize titleSize = new XSize(0, 0);
                if (yari.axisTitleRendererInfo != null)
                {
                    RendererParameters parms = new RendererParameters();
                    parms.Graphics     = gfx;
                    parms.RendererInfo = yari;
                    AxisTitleRenderer atr = new AxisTitleRenderer(parms);
                    atr.Format();
                    titleSize.Height = yari.axisTitleRendererInfo.Height;
                    titleSize.Width  = yari.axisTitleRendererInfo.Width;
                }

                yari.Height = size.Height + titleSize.Height;
                yari.Width  = Math.Max(size.Width, titleSize.Width);

                yari.InnerRect = yari.Rect;
                yari.LabelSize = labelSize;
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the ColumnLikeGridlinesRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikeGridlinesRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the AxisTitleRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal AxisTitleRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the BarClusteredLegendRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarClusteredLegendRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the VerticalXAxisRenderer class with the specified renderer parameters.
 /// </summary>
 internal VerticalXAxisRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the HorizontalXAxisRenderer class with the specified renderer parameters.
 /// </summary>
 internal HorizontalXAxisRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the BarChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarChartRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #8
0
ファイル: Renderer.cs プロジェクト: gvamsilatha/CorePDFSample
 /// <summary>
 /// Initializes a new instance of the Renderer class with the specified renderer parameters.
 /// </summary>
 internal Renderer(RendererParameters rendererParms)
 {
     this.rendererParms = rendererParms;
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the PieLegendRenderer class with the specified renderer
 /// parameters.
 /// </summary>
 internal PieLegendRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #10
0
        /// <summary>
        /// Draws the vertical Y axis.
        /// </summary>
        internal override void Draw()
        {
            AxisRendererInfo yari = ((ChartRendererInfo)this.rendererParms.RendererInfo).yAxisRendererInfo;

            double yMin       = yari.MinimumScale;
            double yMax       = yari.MaximumScale;
            double yMajorTick = yari.MajorTick;
            double yMinorTick = yari.MinorTick;

            XMatrix matrix = new XMatrix(); //XMatrix.Identity;

            matrix.TranslatePrepend(-yMin, -yari.Y);
            matrix.Scale(yari.InnerRect.Width / (yMax - yMin), 1, XMatrixOrder.Append);
            matrix.Translate(yari.X, yari.Y, XMatrixOrder.Append);

            // Draw axis.
            // First draw tick marks, second draw axis.
            double majorTickMarkStart = 0, majorTickMarkEnd = 0,
                   minorTickMarkStart = 0, minorTickMarkEnd = 0;

            GetTickMarkPos(yari, ref majorTickMarkStart, ref majorTickMarkEnd, ref minorTickMarkStart, ref minorTickMarkEnd);

            XGraphics          gfx                = this.rendererParms.Graphics;
            LineFormatRenderer lineFormatRenderer = new LineFormatRenderer(gfx, yari.LineFormat);

            XPoint[] points = new XPoint[2];
            if (yari.MinorTickMark != TickMarkType.None)
            {
                for (double y = yMin + yMinorTick; y < yMax; y += yMinorTick)
                {
                    points[0].X = y;
                    points[0].Y = minorTickMarkStart;
                    points[1].X = y;
                    points[1].Y = minorTickMarkEnd;
                    matrix.TransformPoints(points);
                    lineFormatRenderer.DrawLine(points[0], points[1]);
                }
            }

            XStringFormat xsf = new XStringFormat();

            xsf.LineAlignment = XLineAlignment.Near;
            int countTickLabels = (int)((yMax - yMin) / yMajorTick) + 1;

            for (int i = 0; i < countTickLabels; ++i)
            {
                double y   = yMin + yMajorTick * i;
                string str = y.ToString(yari.TickLabelsFormat);

                XSize labelSize = gfx.MeasureString(str, yari.TickLabelsFont);
                if (yari.MajorTickMark != TickMarkType.None)
                {
                    labelSize.Height += 1.5f * yari.MajorTickMarkWidth;
                    points[0].X       = y;
                    points[0].Y       = majorTickMarkStart;
                    points[1].X       = y;
                    points[1].Y       = majorTickMarkEnd;
                    matrix.TransformPoints(points);
                    lineFormatRenderer.DrawLine(points[0], points[1]);
                }

                XPoint[] layoutText = new XPoint[1];
                layoutText[0].X = y;
                layoutText[0].Y = yari.Y + 1.5 * yari.MajorTickMarkWidth;
                matrix.TransformPoints(layoutText);
                layoutText[0].X -= labelSize.Width / 2; // Center text vertically.
                gfx.DrawString(str, yari.TickLabelsFont, yari.TickLabelsBrush, layoutText[0], xsf);
            }

            if (yari.LineFormat != null)
            {
                points[0].X = yMin;
                points[0].Y = yari.Y;
                points[1].X = yMax;
                points[1].Y = yari.Y;
                matrix.TransformPoints(points);
                if (yari.MajorTickMark != TickMarkType.None)
                {
                    // yMax is at the upper side of the axis
                    points[0].X -= yari.LineFormat.Width / 2;
                    points[1].X += yari.LineFormat.Width / 2;
                }
                lineFormatRenderer.DrawLine(points[0], points[1]);
            }

            // Draw axis title
            if (yari.axisTitleRendererInfo != null)
            {
                RendererParameters parms = new RendererParameters();
                parms.Graphics     = gfx;
                parms.RendererInfo = yari;
                XRect rcTitle = yari.Rect;
                rcTitle.Height = yari.axisTitleRendererInfo.Height;
                rcTitle.Y     += yari.Rect.Height - rcTitle.Height;
                yari.axisTitleRendererInfo.Rect = rcTitle;
                AxisTitleRenderer atr = new AxisTitleRenderer(parms);
                atr.Draw();
            }
        }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the LegendEntryRenderer class with the specified renderer
 /// parameters.
 /// </summary>
 internal LegendEntryRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #12
0
        /// <summary>
        /// Layouts and calculates the space used by the legend.
        /// </summary>
        internal override void Format()
        {
            ChartRendererInfo  cri = (ChartRendererInfo)this.rendererParms.RendererInfo;
            LegendRendererInfo lri = cri.legendRendererInfo;

            if (lri == null)
            {
                return;
            }

            RendererParameters parms = new RendererParameters();

            parms.Graphics = this.rendererParms.Graphics;

            bool  verticalLegend    = (lri.legend.docking == DockingType.Left || lri.legend.docking == DockingType.Right);
            XSize maxMarkerArea     = new XSize();
            LegendEntryRenderer ler = new LegendEntryRenderer(parms);

            foreach (LegendEntryRendererInfo leri in lri.Entries)
            {
                parms.RendererInfo = leri;
                ler.Format();

                maxMarkerArea.Width  = Math.Max(leri.MarkerArea.Width, maxMarkerArea.Width);
                maxMarkerArea.Height = Math.Max(leri.MarkerArea.Height, maxMarkerArea.Height);

                if (verticalLegend)
                {
                    lri.Width   = Math.Max(lri.Width, leri.Width);
                    lri.Height += leri.Height;
                }
                else
                {
                    lri.Width += leri.Width;
                    lri.Height = Math.Max(lri.Height, leri.Height);
                }
            }

            // Add padding to left, right, top and bottom
            int paddingFactor = 1;

            if (lri.BorderPen != null)
            {
                paddingFactor = 2;
            }
            lri.Width  += (LegendRenderer.LeftPadding + LegendRenderer.RightPadding) * paddingFactor;
            lri.Height += (LegendRenderer.TopPadding + LegendRenderer.BottomPadding) * paddingFactor;
            if (verticalLegend)
            {
                lri.Height += LegendRenderer.EntrySpacing * (lri.Entries.Length - 1);
            }
            else
            {
                lri.Width += LegendRenderer.EntrySpacing * (lri.Entries.Length - 1);
            }

            foreach (LegendEntryRendererInfo leri in lri.Entries)
            {
                leri.MarkerArea = maxMarkerArea;
            }
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the PlotAreaBorderRenderer class with the specified
 /// renderer parameters.
 /// </summary>
 internal PlotAreaBorderRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the BarClusteredPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarClusteredPlotAreaRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #15
0
        /// <summary>
        /// Draws the vertical Y axis.
        /// </summary>
        internal override void Draw()
        {
            AxisRendererInfo yari = ((ChartRendererInfo)this.rendererParms.RendererInfo).yAxisRendererInfo;

            double yMin       = yari.MinimumScale;
            double yMax       = yari.MaximumScale;
            double yMajorTick = yari.MajorTick;
            double yMinorTick = yari.MinorTick;

            XMatrix matrix = new XMatrix();  //XMatrix.Identity;

            matrix.TranslatePrepend(-yari.InnerRect.X, yMax);
            matrix.Scale(1, yari.InnerRect.Height / (yMax - yMin), XMatrixOrder.Append);
            matrix.ScalePrepend(1, -1); // mirror horizontal
            matrix.Translate(yari.InnerRect.X, yari.InnerRect.Y, XMatrixOrder.Append);

            // Draw axis.
            // First draw tick marks, second draw axis.
            double majorTickMarkStart = 0, majorTickMarkEnd = 0,
                   minorTickMarkStart = 0, minorTickMarkEnd = 0;

            GetTickMarkPos(yari, ref majorTickMarkStart, ref majorTickMarkEnd, ref minorTickMarkStart, ref minorTickMarkEnd);

            XGraphics          gfx                     = this.rendererParms.Graphics;
            LineFormatRenderer lineFormatRenderer      = new LineFormatRenderer(gfx, yari.LineFormat);
            LineFormatRenderer minorTickMarkLineFormat = new LineFormatRenderer(gfx, yari.MinorTickMarkLineFormat);
            LineFormatRenderer majorTickMarkLineFormat = new LineFormatRenderer(gfx, yari.MajorTickMarkLineFormat);

            XPoint[] points = new XPoint[2];

            // Draw minor tick marks.
            if (yari.MinorTickMark != TickMarkType.None)
            {
                for (double y = yMin + yMinorTick; y < yMax; y += yMinorTick)
                {
                    points[0].X = minorTickMarkStart;
                    points[0].Y = y;
                    points[1].X = minorTickMarkEnd;
                    points[1].Y = y;
                    matrix.TransformPoints(points);
                    minorTickMarkLineFormat.DrawLine(points[0], points[1]);
                }
            }

            double lineSpace = yari.TickLabelsFont.GetHeight();
            int    cellSpace = yari.TickLabelsFont.FontFamily.GetLineSpacing(yari.TickLabelsFont.Style);
            double xHeight   = yari.TickLabelsFont.Metrics.XHeight;

            XSize labelSize = new XSize(0, 0);

            labelSize.Height = lineSpace * xHeight / cellSpace;

            int countTickLabels = (int)((yMax - yMin) / yMajorTick) + 1;

            for (int i = 0; i < countTickLabels; ++i)
            {
                double y   = yMin + yMajorTick * i;
                string str = y.ToString(yari.TickLabelsFormat);

                labelSize.Width = gfx.MeasureString(str, yari.TickLabelsFont).Width;

                // Draw major tick marks.
                if (yari.MajorTickMark != TickMarkType.None)
                {
                    labelSize.Width += yari.MajorTickMarkWidth * 1.5;
                    points[0].X      = majorTickMarkStart;
                    points[0].Y      = y;
                    points[1].X      = majorTickMarkEnd;
                    points[1].Y      = y;
                    matrix.TransformPoints(points);
                    majorTickMarkLineFormat.DrawLine(points[0], points[1]);
                }
                else
                {
                    labelSize.Width += SpaceBetweenLabelAndTickmark;
                }

                // Draw label text.
                XPoint[] layoutText = new XPoint[1];
                layoutText[0].X = yari.InnerRect.X + yari.InnerRect.Width - labelSize.Width;
                layoutText[0].Y = y;
                matrix.TransformPoints(layoutText);
                layoutText[0].Y += labelSize.Height / 2; // Center text vertically.
                gfx.DrawString(str, yari.TickLabelsFont, yari.TickLabelsBrush, layoutText[0]);
            }

            // Draw axis.
            if (yari.LineFormat != null && yari.LineFormat.Width > 0)
            {
                points[0].X = yari.InnerRect.X + yari.InnerRect.Width;
                points[0].Y = yMin;
                points[1].X = yari.InnerRect.X + yari.InnerRect.Width;
                points[1].Y = yMax;
                matrix.TransformPoints(points);
                if (yari.MajorTickMark != TickMarkType.None)
                {
                    // yMax is at the upper side of the axis
                    points[1].Y -= yari.LineFormat.Width / 2;
                    points[0].Y += yari.LineFormat.Width / 2;
                }
                lineFormatRenderer.DrawLine(points[0], points[1]);
            }

            // Draw axis title
            if (yari.axisTitleRendererInfo != null && yari.axisTitleRendererInfo.AxisTitleText != "")
            {
                RendererParameters parms = new RendererParameters();
                parms.Graphics     = gfx;
                parms.RendererInfo = yari;
                double width = yari.axisTitleRendererInfo.Width;
                yari.axisTitleRendererInfo.Rect  = yari.InnerRect;
                yari.axisTitleRendererInfo.Width = width;
                AxisTitleRenderer atr = new AxisTitleRenderer(parms);
                atr.Draw();
            }
        }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the ColumnLikePlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikePlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the YAxisRenderer class with the specified renderer parameters.
 /// </summary>
 internal YAxisRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the WallRenderer class with the specified renderer parameters.
 /// </summary>
 internal WallRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the ColumnLikeLegendRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikeLegendRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the ColumnDataLabelRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnDataLabelRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the PieExplodedPlotAreaRenderer class
 /// with the specified renderer parameters.
 /// </summary>
 internal PieExplodedPlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the GridlinesRenderer class with the specified renderer parameters.
 /// </summary>
 internal GridlinesRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new instance of the BarDataLabelRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarDataLabelRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the LinePlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal LinePlotAreaRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the ColumnLikeChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikeChartRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #26
0
        /// <summary>
        /// Draws the legend.
        /// </summary>
        internal override void Draw()
        {
            ChartRendererInfo  cri = (ChartRendererInfo)this.rendererParms.RendererInfo;
            LegendRendererInfo lri = cri.legendRendererInfo;

            if (lri == null)
            {
                return;
            }

            XGraphics          gfx   = this.rendererParms.Graphics;
            RendererParameters parms = new RendererParameters();

            parms.Graphics = gfx;

            LegendEntryRenderer ler = new LegendEntryRenderer(parms);

            bool verticalLegend = (lri.legend.docking == DockingType.Left || lri.legend.docking == DockingType.Right);
            int  paddingFactor  = 1;

            if (lri.BorderPen != null)
            {
                paddingFactor = 2;
            }
            XRect legendRect = lri.Rect;

            legendRect.X += LegendRenderer.LeftPadding * paddingFactor;
            if (verticalLegend)
            {
                legendRect.Y = legendRect.Bottom - LegendRenderer.BottomPadding * paddingFactor;
            }
            else
            {
                legendRect.Y += LegendRenderer.TopPadding * paddingFactor;
            }

            foreach (LegendEntryRendererInfo leri in cri.legendRendererInfo.Entries)
            {
                if (verticalLegend)
                {
                    legendRect.Y -= leri.Height;
                }

                XRect entryRect = legendRect;
                entryRect.Width  = leri.Width;
                entryRect.Height = leri.Height;

                leri.Rect          = entryRect;
                parms.RendererInfo = leri;
                ler.Draw();

                if (verticalLegend)
                {
                    legendRect.Y -= LegendRenderer.EntrySpacing;
                }
                else
                {
                    legendRect.X += entryRect.Width + LegendRenderer.EntrySpacing;
                }
            }

            // Draw border around legend
            if (lri.BorderPen != null)
            {
                XRect borderRect = lri.Rect;
                borderRect.X      += LegendRenderer.LeftPadding;
                borderRect.Y      += LegendRenderer.TopPadding;
                borderRect.Width  -= LegendRenderer.LeftPadding + LegendRenderer.RightPadding;
                borderRect.Height -= LegendRenderer.TopPadding + LegendRenderer.BottomPadding;
                gfx.DrawRectangle(lri.BorderPen, borderRect);
            }
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the PiePlotAreaRenderer class
 /// with the specified renderer parameters.
 /// </summary>
 internal PieClosedPlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
コード例 #28
0
 /// <summary>
 /// Initializes a new instance of the ColumnStackedPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnStackedPlotAreaRenderer(RendererParameters parms) : base(parms)
 {
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the CombinationChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal CombinationChartRenderer(RendererParameters parms) : base(parms)
 {
 }