/// <summary> /// Layouts and calculates the space used by the legend. /// </summary> internal override void Format() { ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo; LegendRendererInfo lri = cri.legendRendererInfo; if (lri == null) { return; } RendererParameters parms = new RendererParameters { Graphics = _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; } }
/// <summary> /// Draws the vertical Y axis. /// </summary> internal override void Draw() { AxisRendererInfo yari = ((ChartRendererInfo)_rendererParms.RendererInfo).yAxisRendererInfo; double yMin = yari.MinimumScale; double yMax = yari.MaximumScale; double yMajorTick = yari.MajorTick; double yMinorTick = yari.MinorTick; XMatrix matrix = new XMatrix(); 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 = _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(); // old: yari.TickLabelsFont.GetHeight(gfx); int cellSpace = yari.TickLabelsFont.FontFamily.GetLineSpacing(yari.TickLabelsFont.Style); double xHeight = yari.TickLabelsFont.Metrics.XHeight; XSize labelSize = new XSize(0, 0) { 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 { Graphics = gfx, RendererInfo = yari }; double width = yari._axisTitleRendererInfo.Width; yari._axisTitleRendererInfo.Rect = yari.InnerRect; yari._axisTitleRendererInfo.Width = width; AxisTitleRenderer atr = new AxisTitleRenderer(parms); atr.Draw(); } }
/// <summary> /// Initializes a new instance of the ColumnStackedPlotAreaRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnStackedPlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Draws the legend. /// </summary> internal override void Draw() { ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo; LegendRendererInfo lri = cri.legendRendererInfo; if (lri == null) { return; } XGraphics gfx = _rendererParms.Graphics; RendererParameters parms = new RendererParameters { 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 += LeftPadding * paddingFactor; if (verticalLegend) { legendRect.Y = legendRect.Bottom - BottomPadding * paddingFactor; } else { legendRect.Y += 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 -= EntrySpacing; } else { legendRect.X += entryRect.Width + EntrySpacing; } } // Draw border around legend if (lri.BorderPen != null) { XRect borderRect = lri.Rect; borderRect.X += LeftPadding; borderRect.Y += TopPadding; borderRect.Width -= LeftPadding + RightPadding; borderRect.Height -= TopPadding + BottomPadding; gfx.DrawRectangle(lri.BorderPen, borderRect); } }
/// <summary> /// Initializes a new instance of the LinePlotAreaRenderer class with the /// specified renderer parameters. /// </summary> internal LinePlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the PieDataLabelRenderer class with the /// specified renderer parameters. /// </summary> internal PieDataLabelRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the YAxisRenderer class with the specified renderer parameters. /// </summary> internal YAxisRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the AxisTitleRenderer class with the /// specified renderer parameters. /// </summary> internal AxisTitleRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the BarGridlinesRenderer class with the /// specified renderer parameters. /// </summary> internal BarGridlinesRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Draws the vertical Y axis. /// </summary> internal override void Draw() { AxisRendererInfo yari = ((ChartRendererInfo)_rendererParms.RendererInfo).yAxisRendererInfo; double yMin = yari.MinimumScale; double yMax = yari.MaximumScale; double yMajorTick = yari.MajorTick; double yMinorTick = yari.MinorTick; XMatrix matrix = new XMatrix(); 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 = _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 { 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 { Graphics = gfx, 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(); } }
/// <summary> /// Initializes a new instance of the ColumnLikePlotAreaRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnLikePlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the LegendEntryRenderer class with the specified renderer /// parameters. /// </summary> internal LegendEntryRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the ColumnDataLabelRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnDataLabelRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the PlotAreaBorderRenderer class with the specified /// renderer parameters. /// </summary> internal PlotAreaBorderRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the PiePlotAreaRenderer class /// with the specified renderer parameters. /// </summary> internal PieClosedPlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the ColumnLikeLegendRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnLikeLegendRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the WallRenderer class with the specified renderer parameters. /// </summary> internal WallRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the PieExplodedPlotAreaRenderer class /// with the specified renderer parameters. /// </summary> internal PieExplodedPlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the BarClusteredPlotAreaRenderer class with the /// specified renderer parameters. /// </summary> internal BarClusteredPlotAreaRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the VerticalYAxisRenderer class with the /// specified renderer parameters. /// </summary> internal VerticalStackedYAxisRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the ColumnLikeChartRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnLikeChartRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the PieLegendRenderer class with the specified renderer /// parameters. /// </summary> internal PieLegendRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the HorizontalXAxisRenderer class with the specified renderer parameters. /// </summary> internal HorizontalXAxisRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the BarClusteredLegendRenderer class with the /// specified renderer parameters. /// </summary> internal BarClusteredLegendRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the CombinationChartRenderer class with the /// specified renderer parameters. /// </summary> internal CombinationChartRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the ChartRenderer class with the specified renderer parameters. /// </summary> internal ChartRenderer(RendererParameters parms) : base(parms) { }
/// <summary> /// Initializes a new instance of the ColumnLikeGridlinesRenderer class with the /// specified renderer parameters. /// </summary> internal ColumnLikeGridlinesRenderer(RendererParameters parms) : base(parms) { }