/// <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);
      }
    }
        /// <summary>
        /// Calculates the space used for the Y axis.
        /// </summary>
        internal override void Format()
        {
            AxisRendererInfo yari = ((ChartRendererInfo)_rendererParms.RendererInfo).yAxisRendererInfo;

            if (yari._axis != null)
            {
                XGraphics gfx = _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;
            }
        }
    /// <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;
    }
 /// <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 CombinationChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal CombinationChartRenderer(RendererParameters parms)
     : base(parms)
 { }
        /// <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);
            }
        }
    /// <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();
      }
    }
Beispiel #8
0
 /// <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 ColumnDataLabelRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnDataLabelRenderer(RendererParameters parms)
     : base(parms)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the BarPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarPlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
 /// <summary>
 /// Initializes a new instance of the ColumnLikePlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikePlotAreaRenderer(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();

            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();
            }
        }
 /// <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 PieExplodedPlotAreaRenderer class
 /// with the specified renderer parameters.
 /// </summary>
 internal PieExplodedPlotAreaRenderer(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 PiePlotAreaRenderer class
 /// with the specified renderer parameters.
 /// </summary>
 internal PieClosedPlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
Beispiel #17
0
 /// <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 XAxisRenderer class with the specified renderer parameters.
 /// </summary>
 internal XAxisRenderer(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)
 { }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the ColumnLikePlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikePlotAreaRenderer(RendererParameters parms)
     : base(parms)
 {
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the HorizontalStackedYAxisRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal HorizontalStackedYAxisRenderer(RendererParameters parms) : base(parms)
 {
 }
 /// <summary>
 /// Initializes a new instance of the BarDataLabelRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarDataLabelRenderer(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)
 {
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the BarGridlinesRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarGridlinesRenderer(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)
 {
 }
    /// <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;
      }
    }
 /// <summary>
 /// Initializes a new instance of the WallRenderer class with the specified renderer parameters.
 /// </summary>
 internal WallRenderer(RendererParameters parms)
   : base(parms)
 { }
Beispiel #28
0
    /// <summary>
    /// Draws all charts inside the ChartFrame.
    /// </summary>
    public void Draw(XGraphics gfx)
    {
      // Draw frame of ChartFrame. First shadow frame.
      int dx = 5;
      int dy = 5;
      gfx.DrawRoundedRectangle(XBrushes.Gainsboro,
                               this.location.X + dx, this.location.Y + dy,
                               this.size.Width, this.size.Height, 20, 20);

      XRect chartRect = new XRect(this.location.X, this.location.Y, this.size.Width, this.size.Height);
      XLinearGradientBrush brush = new XLinearGradientBrush(chartRect, XColor.FromArgb(0xFFD0DEEF), XColors.White,
                                                            XLinearGradientMode.Vertical);
      XPen penBorder = new XPen(XColors.SteelBlue, 2.5);
      gfx.DrawRoundedRectangle(penBorder, brush,
                               this.location.X, this.location.Y, this.size.Width, this.size.Height,
                               15, 15);

      XGraphicsState state = gfx.Save();
      gfx.TranslateTransform(this.location.X, this.location.Y);

      // Calculate rectangle for all charts. Y-Position will be moved for each chart.
      int charts = this.chartList.Count;
      uint dxChart = 20;
      uint dyChart = 20;
      uint dyBetweenCharts = 30;
      XRect rect = new XRect(dxChart, dyChart,
        this.size.Width - 2 * dxChart,
        (this.size.Height - (charts - 1) * dyBetweenCharts - 2 * dyChart) / charts);

      // draw each chart in list
      foreach (Chart chart in this.chartList)
      {
        RendererParameters parms = new RendererParameters(gfx, rect);
        parms.DrawingItem = chart;

        ChartRenderer renderer = GetChartRenderer(chart, parms);
        renderer.Init();
        renderer.Format();
        renderer.Draw();

        rect.Y += rect.Height + dyBetweenCharts;
      }
      gfx.Restore(state);

//      // Calculate rectangle for all charts. Y-Position will be moved for each chart.
//      int charts = this.chartList.Count;
//      uint dxChart = 0;
//      uint dyChart = 0;
//      uint dyBetweenCharts = 0;
//      XRect rect = new XRect(dxChart, dyChart,
//        this.size.Width - 2 * dxChart,
//        (this.size.Height - (charts - 1) * dyBetweenCharts - 2 * dyChart) / charts);
//
//      // draw each chart in list
//      foreach (Chart chart in this.chartList)
//      {
//        RendererParameters parms = new RendererParameters(gfx, rect);
//        parms.DrawingItem = chart;
//
//        ChartRenderer renderer = GetChartRenderer(chart, parms);
//        renderer.Init();
//        renderer.Format();
//        renderer.Draw();
//
//        rect.Y += rect.Height + dyBetweenCharts;
//      }
    }
 /// <summary>
 /// Initializes a new instance of the BarChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarChartRenderer(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 LegendRenderer class with the specified renderer parameters.
 /// </summary>
 internal LegendRenderer(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)
 {
 }
Beispiel #33
0
 /// <summary>
 /// Initializes a new instance of the Renderer class with the specified renderer parameters.
 /// </summary>
 internal Renderer(RendererParameters rendererParms)
 {
     this.rendererParms = rendererParms;
 }
 /// <summary>
 /// Initializes a new instance of the ColumnLikeLegendRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnLikeLegendRenderer(RendererParameters parms)
   : base(parms)
 {
 }
Beispiel #35
0
 /// <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 BarDataLabelRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarDataLabelRenderer(RendererParameters parms)
     : base(parms)
 {
 }
Beispiel #37
0
 /// <summary>
 /// Initializes a new instance of the ColumnChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnChartRenderer(RendererParameters parms)
     : base(parms)
 {
 }
        /// <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();

            parms.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>
 /// Initializes a new instance of the BarChartRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarChartRenderer(RendererParameters parms)
     : base(parms)
 {
 }
    /// <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 = 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(gfx);
      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();
      }
    }
Beispiel #41
0
 /// <summary>
 /// Initializes a new instance of the ColumnStackedPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnStackedPlotAreaRenderer(RendererParameters parms) : base(parms)
 {
 }
 /// <summary>
 /// Initializes a new instance of the ColumnClusteredPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal ColumnClusteredPlotAreaRenderer(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 BarPlotAreaRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarPlotAreaRenderer(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(-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);

            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();
            }
        }
 /// <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 BarGridlinesRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal BarGridlinesRenderer(RendererParameters parms) : base(parms)
 {
 }
Beispiel #48
0
 /// <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 PlotAreaBorderRenderer class with the specified
 /// renderer parameters.
 /// </summary>
 internal PlotAreaBorderRenderer(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)
 {
 }
 /// <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 HorizontalYAxisRenderer class with the
 /// specified renderer parameters.
 /// </summary>
 internal HorizontalYAxisRenderer(RendererParameters parms) : base(parms)
 {
 }
 /// <summary>
 /// Initializes a new instance of the VerticalXAxisRenderer class with the specified renderer parameters.
 /// </summary>
 internal VerticalXAxisRenderer(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 WallRenderer class with the specified renderer parameters.
 /// </summary>
 internal WallRenderer(RendererParameters parms)
     : base(parms)
 {
 }
Beispiel #56
0
 /// <summary>
 /// Initializes a new instance of the Renderer class with the specified renderer parameters.
 /// </summary>
 internal Renderer(RendererParameters rendererParms)
 {
   this.rendererParms = rendererParms;
 }
Beispiel #57
-2
    /// <summary>
    /// Returns the chart renderer appropriate for the chart.
    /// </summary>
    private ChartRenderer GetChartRenderer(Chart chart, RendererParameters parms)
    {
      ChartType chartType = chart.Type;
      bool useCombinationRenderer = false;
      foreach (Series series in chart.seriesCollection)
      {
        if (series.chartType != chartType)
        {
          useCombinationRenderer = true;
          break;
        }
      }

      if (useCombinationRenderer)
        return new CombinationChartRenderer(parms);

      switch (chartType)
      {
        case ChartType.Line:
          return new LineChartRenderer(parms);

        case ChartType.Column2D:
        case ChartType.ColumnStacked2D:
          return new ColumnChartRenderer(parms);

        case ChartType.Bar2D:
        case ChartType.BarStacked2D:
          return new BarChartRenderer(parms);

        case ChartType.Area2D:
          return new AreaChartRenderer(parms);

        case ChartType.Pie2D:
        case ChartType.PieExploded2D:
          return new PieChartRenderer(parms);
      }

      return null;
    }