Beispiel #1
0
        private void resolveRangeX()
        {
            double maxValue = 0;
            double minValue = 0;

            for (int i = 0; i < series.Count; i++)
            {
                ScatterSerie data = series[i] as ScatterSerie;

                double[] tmp = new double[data.X.Length];
                Array.Copy(data.X, 0, tmp, 0, data.X.Length);

                if (tmp.Length > 0)
                {
                    Array.Sort(tmp);
                    maxValue = Math.Max(maxValue, tmp[tmp.Length - 1]);
                    minValue = Math.Min(minValue, tmp[0]);
                }
            }


            if (maxValue == 0 && minValue == 0)
            {
                maxValue = 100;
                minValue = 0;
            }
            else if (maxValue != 0 && minValue == 0)
            {
                int theBase = (int)Math.Ceiling(Math.Log10(maxValue));
                mMaxX = (float)Math.Pow(10, theBase);

                if (maxValue <= mMaxX / 2)
                {
                    mMaxX = mMaxX / 2;
                }
            }
            else
            {
                int theBase = (int)Math.Max(Math.Ceiling(Math.Log10(Math.Abs(maxValue))), Math.Ceiling(Math.Log10(Math.Abs(minValue))));
                mMaxX = (float)Math.Pow(10, theBase);
                mMinX = (float)Math.Pow(10, theBase) * Math.Sign(minValue);

                if (maxValue <= mMaxX / 2)
                {
                    mMaxX = mMaxX / 2;
                }
                if (minValue >= mMinX / 2)
                {
                    mMinX = mMinX / 2;
                }
            }
        }
Beispiel #2
0
        private void drawLegend(Graphics g)
        {
            g.DrawRectangle(new Pen(Color.Black, 1), mLegendArea);

            for (int i = 0; i < series.Count; i++)
            {
                ScatterSerie data = series[i] as ScatterSerie;

                SizeF sf   = g.MeasureString(data.Name, labelFont);
                int   yPos = (int)(mLegendArea.Y + 8 + i * sf.Height);
                //g.FillRectangle(new SolidBrush(data.Color), mLegendArea.X-rBounds.X + 8, yPos-3 , 6, 6);

                Pen pen = new Pen(data.Color);
                if (data.DashStyle == DashStyle.Dash)
                {
                    pen.DashPattern = new float[] { 4, 2 }
                }
                ;
                else if (data.DashStyle == DashStyle.Dot)
                {
                    pen.DashPattern = new float[] { 1, 3 }
                }
                ;
                else if (data.DashStyle == DashStyle.DashDot)
                {
                    pen.DashPattern = new float[] { 5, 2, 2, 2 }
                }
                ;
                else if (data.DashStyle == DashStyle.DashDotDot)
                {
                    pen.DashPattern = new float[] { 4, 2, 1, 2, 1, 2 }
                }
                ;
                else
                {
                    pen.DashStyle = data.DashStyle;
                }

                g.DrawLine(pen, new Point(mLegendArea.X + 4, yPos), new Point(mLegendArea.X + 20, yPos));
                g.DrawString(data.Name, labelFont, new SolidBrush(Color.Black), mLegendArea.X + 22, yPos - sf.Height / 2);
            }
        }
Beispiel #3
0
        private void drawLines(Graphics g)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            for (int i = 0; i < series.Count; i++)
            {
                ScatterSerie data = series[i] as ScatterSerie;

                PointF[] points = new PointF[data.X.Length];

                for (int j = 0; j < data.X.Length; j++)
                {
                    points[j] = new PointF(this.calculateXPosition((float)data.X[j]), this.calculateYPosition((float)data.Y[j]));
                }

                Array.Sort(points, new PointComparer());

                if (points.Length > 1)
                {
                    Pen pen = new Pen(data.Color);
                    if (data.DashStyle == DashStyle.Dash)
                    {
                        pen.DashPattern = new float[] { 4, 4 }
                    }
                    ;
                    else if (data.DashStyle == DashStyle.Dot)
                    {
                        pen.DashPattern = new float[] { 2, 4 }
                    }
                    ;
                    else if (data.DashStyle == DashStyle.DashDot)
                    {
                        pen.DashPattern = new float[] { 4, 3, 1, 3 }
                    }
                    ;
                    else if (data.DashStyle == DashStyle.DashDotDot)
                    {
                        pen.DashPattern = new float[] { 4, 3, 1, 3, 1, 3 }
                    }
                    ;
                    else
                    {
                        pen.DashStyle = data.DashStyle;
                    }

                    g.DrawLines(pen, points);
                }



                if (showMarkers)
                {
                    Brush markerBrush = new SolidBrush(data.Color);
                    for (int k = 0; k < points.Length; k++)
                    {
                        g.FillEllipse(markerBrush, points[k].X - 2, points[k].Y - 2, 5, 5);
                    }
                    markerBrush.Dispose();
                }
            }

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
        }