/// <summary>
        /// Initializes all necessary data to draw all series for a column chart.
        /// </summary>
        internal void InitSeries()
        {
            ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;

            int seriesIndex = 0;

            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                sri.LineFormat = Converter.ToXPen(sri._series._lineFormat, XColors.Black, DefaultSeriesLineWidth);
                sri.FillFormat = Converter.ToXBrush(sri._series._fillFormat, ColumnColors.Item(seriesIndex++));

                sri._pointRendererInfos = new ColumnRendererInfo[sri._series._seriesElements.Count];
                for (int pointIdx = 0; pointIdx < sri._pointRendererInfos.Length; ++pointIdx)
                {
                    PointRendererInfo pri   = new ColumnRendererInfo();
                    Point             point = sri._series._seriesElements[pointIdx];
                    pri.Point = point;
                    if (point != null)
                    {
                        pri.LineFormat = sri.LineFormat;
                        pri.FillFormat = sri.FillFormat;
                        if (point._lineFormat != null && !point._lineFormat._color.IsEmpty)
                        {
                            pri.LineFormat = Converter.ToXPen(point._lineFormat, sri.LineFormat);
                        }
                        if (point._fillFormat != null && !point._fillFormat._color.IsEmpty)
                        {
                            pri.FillFormat = new XSolidBrush(point._fillFormat._color);
                        }
                    }
                    sri._pointRendererInfos[pointIdx] = pri;
                }
            }
        }
        /// <summary>
        /// Determines the sum of the smallest and the largest stacked column
        /// from all series of the chart.
        /// </summary>
        protected override void CalcYAxis(out double yMin, out double yMax)
        {
            yMin = double.MaxValue;
            yMax = double.MinValue;

            ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;

            int maxPoints = 0;

            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                maxPoints = Math.Max(maxPoints, sri._series._seriesElements.Count);
            }

            for (int pointIdx = 0; pointIdx < maxPoints; ++pointIdx)
            {
                double valueSumPos = 0, valueSumNeg = 0;
                foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
                {
                    if (sri._pointRendererInfos.Length <= pointIdx)
                    {
                        break;
                    }

                    ColumnRendererInfo column = (ColumnRendererInfo)sri._pointRendererInfos[pointIdx];
                    if (column.Point != null && !double.IsNaN(column.Point._value))
                    {
                        if (column.Point._value < 0)
                        {
                            valueSumNeg += column.Point._value;
                        }
                        else
                        {
                            valueSumPos += column.Point._value;
                        }
                    }
                }
                yMin = Math.Min(valueSumNeg, yMin);
                yMax = Math.Max(valueSumPos, yMax);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Calculates the position, width and height of each bar of all series.
        /// </summary>
        protected override void CalcBars()
        {
            ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;

            if (cri.seriesRendererInfos.Length == 0)
            {
                return;
            }

            double xMax       = cri.xAxisRendererInfo.MaximumScale;
            double xMajorTick = cri.xAxisRendererInfo.MajorTick;

            int maxPoints = 0;

            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                maxPoints = Math.Max(maxPoints, sri._series._seriesElements.Count);
            }

            // Space used by one bar.
            double x           = xMax - xMajorTick / 2;
            double columnWidth = xMajorTick * 0.75 / 2;

            XPoint[] points = new XPoint[2];
            for (int pointIdx = 0; pointIdx < maxPoints; ++pointIdx)
            {
                double yMin = 0, yMax = 0, y0 = 0, y1 = 0;
                double x0 = x - columnWidth;
                double x1 = x + columnWidth;

                foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
                {
                    if (sri._pointRendererInfos.Length <= pointIdx)
                    {
                        break;
                    }

                    ColumnRendererInfo column = (ColumnRendererInfo)sri._pointRendererInfos[pointIdx];
                    if (column.Point != null && !double.IsNaN(column.Point._value))
                    {
                        double y = column.Point._value;
                        if (y < 0)
                        {
                            y0    = yMin + y;
                            y1    = yMin;
                            yMin += y;
                        }
                        else
                        {
                            y0    = yMax;
                            y1    = yMax + y;
                            yMax += y;
                        }

                        points[0].Y = x0; // oben links
                        points[0].X = y0;
                        points[1].Y = x1; // unten rechts
                        points[1].X = y1;

                        cri.plotAreaRendererInfo._matrix.TransformPoints(points);

                        column.Rect = new XRect(points[0].X,
                                                points[0].Y,
                                                points[1].X - points[0].X,
                                                points[1].Y - points[0].Y);
                    }
                }
                x--; // Next stacked column.
            }
        }
Esempio n. 4
0
    /// <summary>
    /// Initializes all necessary data to draw all series for a column chart.
    /// </summary>
    internal void InitSeries()
    {
      ChartRendererInfo cri = (ChartRendererInfo)this.rendererParms.RendererInfo;

      int seriesIndex = 0;
      foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
      {
        sri.LineFormat = Converter.ToXPen(sri.series.lineFormat, XColors.Black, ChartRenderer.DefaultSeriesLineWidth);
        sri.FillFormat = Converter.ToXBrush(sri.series.fillFormat, ColumnColors.Item(seriesIndex++));

        sri.pointRendererInfos = new ColumnRendererInfo[sri.series.seriesElements.Count];
        for (int pointIdx = 0; pointIdx < sri.pointRendererInfos.Length; ++pointIdx)
        {
          PointRendererInfo pri = new ColumnRendererInfo();
          Point point = sri.series.seriesElements[pointIdx];
          pri.point = point;
          if (point != null)
          {
            pri.LineFormat = sri.LineFormat;
            pri.FillFormat = sri.FillFormat;
            if (point.lineFormat != null && !point.lineFormat.color.IsEmpty)
              pri.LineFormat = Converter.ToXPen(point.lineFormat, sri.LineFormat);
            if (point.fillFormat != null && !point.fillFormat.color.IsEmpty)
              pri.FillFormat = new XSolidBrush(point.fillFormat.color);
          }
          sri.pointRendererInfos[pointIdx] = pri;
        }
      }
    }
Esempio n. 5
0
        /// <summary>
        /// Calculates the position, width and height of each column of all series.
        /// </summary>
        protected override void CalcColumns()
        {
            ChartRendererInfo cri = (ChartRendererInfo)this.rendererParms.RendererInfo;

            if (cri.seriesRendererInfos.Length == 0)
            {
                return;
            }

            double xMin       = cri.xAxisRendererInfo.MinimumScale;
            double xMajorTick = cri.xAxisRendererInfo.MajorTick;

            int maxPoints = 0;

            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                maxPoints = Math.Max(maxPoints, sri.series.seriesElements.Count);
            }

            double x = xMin + xMajorTick / 2;

            // Space used by one column.
            double columnWidth = xMajorTick * 0.75 / 2;

            XPoint[] points = new XPoint[2];
            for (int pointIdx = 0; pointIdx < maxPoints; ++pointIdx)
            {
                // Set x to first clustered column for each series.
                double yMin = 0, yMax = 0, y0 = 0, y1 = 0;
                double x0 = x - columnWidth;
                double x1 = x + columnWidth;

                foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
                {
                    if (sri.pointRendererInfos.Length <= pointIdx)
                    {
                        break;
                    }

                    ColumnRendererInfo column = (ColumnRendererInfo)sri.pointRendererInfos[pointIdx];
                    if (column.point != null && !double.IsNaN(column.point.value))
                    {
                        double y = column.point.value;
                        if (y < 0)
                        {
                            y0    = yMin + y;
                            y1    = yMin;
                            yMin += y;
                        }
                        else
                        {
                            y0    = yMax;
                            y1    = yMax + y;
                            yMax += y;
                        }

                        points[0].X = x0; // upper left
                        points[0].Y = y1;
                        points[1].X = x1; // lower right
                        points[1].Y = y0;

                        cri.plotAreaRendererInfo.matrix.TransformPoints(points);

                        column.Rect = new XRect(points[0].X,
                                                points[0].Y,
                                                points[1].X - points[0].X,
                                                points[1].Y - points[0].Y);
                    }
                }
                x++; // Next stacked column.
            }
        }