예제 #1
0
        private void DrawMarker(DrawGrid gr, Graphics g, PointF p)
        {
            float x;
            float y;

            x = p.X;
            y = p.Y;

            if (gr.XAxisType == AxisType.LOG)
            {
                x = (float)Math.Log10(x);
            }
            if (gr.YAxisType == AxisType.LOG)
            {
                y = (float)Math.Log10(y);
            }

            x = gr.GraphTransform.TranslateX(x);
            y = gr.GraphTransform.TranslateY(y);

            if (!(double.IsNaN(x) || double.IsInfinity(x) || double.IsInfinity(y) || double.IsNaN(y)))
            {
                g.DrawLine(Pens.Black, x - 2, y, x + 2, y);
                g.DrawLine(Pens.Black, x, y - 2, x, y + 2);
            }
        }
예제 #2
0
        public DecorateMarkers(DrawGrid gr, ChartData cd) : base(gr)
        {
            xmarkers = cd.Xmarkers;
            ymarkers = cd.Ymarkers;
            points   = new ArrayList();

            foreach (PointF[] pf in gr.RealPoints)
            {
                for (int i = 0; i < pf.Length; i++)
                {
                    for (int j = 0; j < xmarkers.Length; j++)
                    {
                        if (pf[i].X == xmarkers[j])
                        {
                            points.Add(pf[i]);
                        }
                    }

                    for (int j = 0; j < ymarkers.Length; j++)
                    {
                        if (pf[i].Y == ymarkers[j])
                        {
                            points.Add(pf[i]);
                        }
                    }
                }
            }
        }
예제 #3
0
        protected override void OnPostPaint(ChControl cc, Graphics g)
        {
            DrawGrid gr = cc as DrawGrid;

            if (gr != null)
            {
                foreach (PointF p in points)
                {
                    DrawMarker(gr, g, p);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Initialize the graph component, only called explicitly when the graph changes
        /// </summary>
        void InitializeComponents(Graphics g)
        {
            if (cds.Length == 0)
            {
                return;
            }

            gr = new DrawGrid(cds);
            colorTheme.Reset();
            legend = new DrawLegend();
            DrawPlot dp;

            for (int i = 0; i < cds.Length; i++)
            {
                ChartData cd = cds[i];

                if (cd.Y.Length == 0 || cd.X.Length == 0)
                {
                    continue;
                }

                //Choose chart
                switch (cd.ChartType)
                {
                case ChartType.Curve:
                    dp = new ChartTypes.Curve(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Stem:
                    dp = new ChartTypes.Stem(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Fast:
                    dp = new ChartTypes.FastCurve(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Histogram:
                    dp = new ChartTypes.Histogram(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Points:
                    dp = new ChartTypes.Points(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Cross:
                    dp = new ChartTypes.Cross(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.Step:
                    dp = new ChartTypes.Step(cd.X, cd.Y, cd.TitlesY);
                    break;

                case ChartType.CurveWide:
                    dp = new ChartTypes.CurveWide(cd.X, cd.Y, cd.TitlesY);
                    break;

                default:
                    dp = new ChartTypes.Curve(cd.X, cd.Y, cd.TitlesY);
                    break;
                }


                //Set colors
                Color[] plotcolors = new Color[cd.Y.Length];
                for (int j = 0; j < cd.Y.Length; j++)
                {
                    if (cd.Z != null && cd.Z.Length > j)
                    {
                        //int index = (int)Math.Floor(cd.Z[j] % cols.Length);
                        //if (index > 0 && index < cols.Length)
                        //    plotcolors[j] = cols[index];
                        //plotcolors[j] = Color.FromArgb((int)cd.Z[j] * 25, 66, 99);
                    }
                    else
                    {
                        plotcolors[j] = colorTheme.Next();
                    }
                    //    }
                }
                dp.Colors = plotcolors;

                //Set legend
                for (int j = 0; j < cd.Y.Length; j++)
                {
                    if (cd.TitlesY != null)
                    {
                        if (cd.TitlesY.Length > j)
                        {
                            legend.Add(dp.Colors[j], cd.TitlesY[j]);
                        }
                    }
                }

                gr.Add(dp);
            }
            //Add axis labels
            lg = new DrawGridAxis(gr);
            lg.NumberOfDecimals = numbdecimals;

            //Add text
            l = new DrawText(lg, cds[0]);
            l.SetLegend(legend);
            l.ShowTitle  = ShowTitle;
            l.ShowLegend = ShowLegend;
            l.Location   = new System.Drawing.Point(0, 0);
            l.Size       = this.Size;


            //Set ForeColors
            gr.GridColor     = this.ForeColor;
            lg.ForeColor     = this.ForeColor;
            legend.ForeColor = this.ForeColor;
            l.ForeColor      = this.ForeColor;

            //Initialize Controls
            l.Init(g);
        }
예제 #5
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="gr">DrawGrid control to decorate</param>
 public DrawGridAxis(DrawGrid gr)
 {
     this.gr = gr;
     this.Children.Add(gr);
     gr.Parent = this;
 }
예제 #6
0
 public int Add(DrawGrid gr)
 {
     gr.Parent = this;
     return(this.Children.Add(gr));
 }