コード例 #1
0
        /// <summary>
        /// Draws the border around the plot area.
        /// </summary>
        internal override void Draw()
        {
            ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;

            if (cri.plotAreaRendererInfo.LineFormat != null && cri.plotAreaRendererInfo.LineFormat.Width > 0)
            {
                XGraphics          gfx = _rendererParms.Graphics;
                LineFormatRenderer lineFormatRenderer = new LineFormatRenderer(gfx, cri.plotAreaRendererInfo.LineFormat);
                lineFormatRenderer.DrawRectangle(cri.plotAreaRendererInfo.Rect);
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws the content of the column plot area.
        /// </summary>
        internal override void Draw()
        {
            ChartRendererInfo cri = (ChartRendererInfo)_rendererParms.RendererInfo;

            XRect plotAreaBox = cri.plotAreaRendererInfo.Rect;

            if (plotAreaBox.IsEmpty)
            {
                return;
            }

            XGraphics gfx = _rendererParms.Graphics;

            double xMin = cri.xAxisRendererInfo.MinimumScale;
            double xMax = cri.xAxisRendererInfo.MaximumScale;
            double yMin = cri.yAxisRendererInfo.MinimumScale;
            double yMax = cri.yAxisRendererInfo.MaximumScale;

            LineFormatRenderer lineFormatRenderer;

            // Under some circumstances it is possible that no zero base line will be drawn,
            // e. g. because of unfavourable minimum/maximum scale and/or major tick, so force to draw
            // a zero base line if necessary.
            if (cri.yAxisRendererInfo.MajorGridlinesLineFormat != null ||
                cri.yAxisRendererInfo.MinorGridlinesLineFormat != null)
            {
                if (yMin < 0 && yMax > 0)
                {
                    XPoint[] points = new XPoint[2];
                    points[0].X = xMin;
                    points[0].Y = 0;
                    points[1].X = xMax;
                    points[1].Y = 0;
                    cri.plotAreaRendererInfo._matrix.TransformPoints(points);

                    lineFormatRenderer = cri.yAxisRendererInfo.MinorGridlinesLineFormat != null
                        ? new LineFormatRenderer(gfx, cri.yAxisRendererInfo.MinorGridlinesLineFormat)
                        : new LineFormatRenderer(gfx, cri.yAxisRendererInfo.MajorGridlinesLineFormat);

                    lineFormatRenderer.DrawLine(points[0], points[1]);
                }
            }

            // Draw columns
            XGraphicsState state = gfx.Save();

            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                foreach (ColumnRendererInfo column in sri._pointRendererInfos)
                {
                    // Do not draw column if value is outside yMin/yMax range. Clipping does not make sense.
                    if (IsDataInside(yMin, yMax, column.Point._value))
                    {
                        gfx.DrawRectangle(column.FillFormat, column.Rect);
                    }
                }
            }

            // Draw borders around column.
            // A border can overlap neighbor columns, so it is important to draw borders at the end.
            foreach (SeriesRendererInfo sri in cri.seriesRendererInfos)
            {
                foreach (ColumnRendererInfo column in sri._pointRendererInfos)
                {
                    // Do not draw column if value is outside yMin/yMax range. Clipping does not make sense.
                    if (IsDataInside(yMin, yMax, column.Point._value) && column.LineFormat.Width > 0)
                    {
                        lineFormatRenderer = new LineFormatRenderer(gfx, column.LineFormat);
                        lineFormatRenderer.DrawRectangle(column.Rect);
                    }
                }
            }
            gfx.Restore(state);
        }