private void DrawGraph()
        {
            GraphPane pane = ZedGraph.GraphPane;

            pane.CurveList.Clear();
            PointPairList f1_list = new PointPairList();
            PointPairList f2_list = new PointPairList();
            double        xmin    = -50;
            double        xmax    = 50;

            for (double x = xmin; x <= xmax; x += 0.01)
            {
                f1_list.Add(x, x * x);
            }
            for (double x = 0; x <= xmax; x += 0.5)
            {
                f2_list.Add(x, x * x * x);
            }

            LineItem f1_curve = pane.AddCurve("Sinc", f1_list, Color.Blue, SymbolType.None);
            LineItem f2_curve = pane.AddCurve("Sin", f2_list, Color.Red, SymbolType.Plus);

            ZedGraph.AxisChange();
            ZedGraph.Invalidate();
        }
Beispiel #2
0
        private void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            //get a reference to the graphpane
            ZedGraph.GraphPane myPane = zgc.GraphPane;

            myPane.Title.Text = "First Graph";

            // generate some data for the graph
            double x, y1, y2;
            ZedGraph.PointPairList list1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList list2 = new ZedGraph.PointPairList();

            for( int i=0; i<36; i++)
            {
                x = (double)i+5;
                y1 = 1.5*Math.Sin((double)i*0.2);
                y2 = 1.5+(3.0*Math.Sin((double)i*0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);

            }

            ZedGraph.LineItem myCurve = myPane.AddCurve("Seth", list1, Color.Red, ZedGraph.SymbolType.Diamond);
            ZedGraph.LineItem myCurve2 = myPane.AddCurve("Obi", list2, Color.Blue, ZedGraph.SymbolType.Circle);

            zgc.AxisChange();
        }
Beispiel #3
0
        private void zeggraph_init()
        {
            Panel                        = ZedGraph.GraphPane;
            counter                      = 0;
            Panel.Title.Text             = "电机实时曲线";
            Panel.Chart.Border.IsVisible = true;
            Panel.Legend.IsVisible       = false;
            Panel.CurveList.Clear();

            LineItem curve_moto_speed = Panel.AddCurve("电机", list_moto_speed, Color.Red, SymbolType.None);

            ZedGraph.Invalidate();
            curve_moto_speed.Line.Width  = 2F;
            curve_moto_speed.Symbol.Fill = new Fill(Color.White, Color.Blue, Color.White);
            curve_moto_speed.Symbol.Size = 5;

            Panel.XAxis.Title.Text          = "个数";
            Panel.XAxis.Scale.FontSpec.Size = 10;
            Panel.XAxis.Scale.Max           = 1000;
            Panel.XAxis.Scale.Min           = 0;
            Panel.XAxis.Scale.MajorStep     = Panel.XAxis.Scale.Max / 10;
            Panel.XAxis.Scale.MinorStep     = Panel.XAxis.Scale.MajorStep / 10;
            Panel.XAxis.MajorGrid.IsVisible = true;

            Panel.YAxis.Title.Text          = "转速";
            Panel.YAxis.Scale.FontSpec.Size = 10;
            Panel.YAxis.Scale.Max           = 1500;
            Panel.YAxis.Scale.Min           = -10;
            Panel.YAxis.Scale.MajorStep     = 200;
            Panel.YAxis.Scale.MinorStep     = 40;
            Panel.YAxis.MajorGrid.IsVisible = true;
            Panel.Chart.Fill = new Fill(Color.White, Color.SlateBlue, 23.0F);

            ZedGraph.AxisChange();
        }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="myGraphControl"></param>
        /// <param name="coor_x"></param>
        /// <param name="coor_y"></param>
        /// <param name="title"></param>
        /// <param name="Xtitle"></param>
        /// <param name="Ytitle"></param>
        public void MyDrawPic1(ZedGraph.ZedGraphControl myGraphControl, double[] coor_x, double[] coor_y, string title, string Xtitle, string Ytitle)
        {
            GraphPane myPane = myGraphControl.GraphPane;
            myPane.Legend.IsVisible = false;
               // myPane.CurveList.Clear();
            //myPane.Title.Text = title;
            //myPane.XAxis.Title.Text = Xtitle;
            //myPane.YAxis.Title.Text = Ytitle;
            PointPairList list = new PointPairList();
            int N = coor_x.Length;
            for (int i = 0; i < N; i++)
            {
                double x = coor_x[i];
                double y = coor_y[i];
                list.Add(x, y);//��������
            }
            LineItem myCurve = myPane.AddCurve(title,list, Color.Black, SymbolType.None);
            myCurve.Symbol.Fill = new Fill(Color.White);
            myCurve.Line.Width = 2;
            //myCurve.IsX2Axis = false;
            //myCurve.IsY2Axis = false;

            myPane.XAxis.MajorGrid.IsVisible = false;
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Black;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Black;
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            myPane.YAxis.MajorGrid.IsZeroLine = false;
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.Min = -30;
            myPane.YAxis.Scale.Max = 30;
            myPane.Y2Axis.IsVisible = false;
            myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Black;
            myPane.Y2Axis.Title.FontSpec.FontColor = Color.Black;
            myPane.Y2Axis.MajorTic.IsOpposite = false;
            myPane.Y2Axis.MinorTic.IsOpposite = false;
            myPane.Y2Axis.MajorGrid.IsVisible = false;
            myPane.Y2Axis.Scale.Align = AlignP.Inside;

            myPane.Chart.Fill = new Fill(Color.White, Color.White, 45.0f);
            myGraphControl.IsShowPointValues = true;
            myGraphControl.PointValueEvent += new ZedGraph.ZedGraphControl.PointValueHandler(MyPointValueHandler);
            myGraphControl.ZoomEvent += new ZedGraph.ZedGraphControl.ZoomEventHandler(MyZoomEvent);
            myGraphControl.AxisChange();

            myGraphControl.RestoreScale(myPane);
            myGraphControl.Invalidate();
        }
        private void chartLinePoints(List <T> data, bool xlog, bool ylog)
        {
            if (data.Count == 0)
            {
                return;
            }
            pane.CurveList.Clear();
            pane.XAxis.Title   = data[0].Xname;
            pane.YAxis.Title   = data[0].Yname;
            pane.XAxis.MinAuto = true;
            pane.YAxis.MinAuto = true;

            if (xlog)
            {
                pane.XAxis.Type = AxisType.Log;
            }
            else
            {
                pane.XAxis.Type = AxisType.Linear;
            }
            if (ylog)
            {
                pane.YAxis.Type = AxisType.Log;
            }
            else
            {
                pane.YAxis.Type = AxisType.Linear;
            }

            PointPairList list = new PointPairList();

            foreach (var item in data)
            {
                list.Add(item.X, item.Y);
            }

            var curve = pane.AddCurve(BaseDataTable.Name, list, Color.Blue, SymbolType.Square);

            curve.Line.IsVisible    = true;
            curve.Symbol.Fill.Type  = FillType.Solid;
            curve.Symbol.Size       = 3.0f;
            curve.Symbol.Fill.Color = Color.Blue;

            ZedGraph.AxisChange();
            ZedGraph.Invalidate();
        }
        private void chartBars(List <T> data, bool xlog, bool ylog)
        {
            if (data.Count == 0)
            {
                return;
            }
            pane.CurveList.Clear();
            pane.XAxis.Title   = data[0].Xname;
            pane.YAxis.Title   = data[0].Yname;
            pane.XAxis.MinAuto = true;
            pane.YAxis.MinAuto = true;

            if (xlog)
            {
                pane.XAxis.Type = AxisType.Log;
            }
            else
            {
                pane.XAxis.Type = AxisType.Linear;
            }
            if (ylog)
            {
                pane.YAxis.Type = AxisType.Log;
            }
            else
            {
                pane.YAxis.Type = AxisType.Linear;
            }

            double[] XValues = new double[data.Count];
            double[] YValues = new double[data.Count];

            for (int i = 0; i < data.Count; i++)
            {
                XValues[i] = data[i].X;
                YValues[i] = data[i].Y;
            }

            pane.AddBar(BaseDataTable.Name, XValues, YValues, Color.Blue);

            pane.MinBarGap     = 0.0f;
            pane.MinClusterGap = 2.5f;

            ZedGraph.AxisChange();
            ZedGraph.Invalidate();
        }
        private void ItemOnClick(object sender, EventArgs eventArgs)
        {
            var pane = ZedGraph.GraphPane;
            var item = (ToolStripMenuItem)sender;

            if (pane.CurveList.Any(crv => crv.Label.Text == item.Text))
            {
                pane.CurveList.Remove(pane.CurveList.Single(crv => crv.Label.Text == item.Text));
                pane.YAxisList.Remove(pane.YAxisList.Single(ax => ax.Title.Text == item.Text));

                AssignYAxes(pane);
            }
            else
            {
                var dataNameTag = (PlottableDataEnum)item.Tag;
                AddTrace(pane, dataNameTag);
            }

            ZedGraph.AxisChange();
            ZedGraph.Invalidate();
        }
        private void OnLoad(object sender, EventArgs e)
        {
            OnLoadInternal(sender, e);

            // OPTIONAL: Show tooltips when the mouse hovers over a point
            ZedGraph.IsShowPointValues = true;
            ZedGraph.PointValueEvent  += PointValueHandler;

            // OPTIONAL: Add a custom context menu item
            ZedGraph.ContextMenuBuilder += OnContextMenuBuilder;

            // OPTIONAL: Handle the Zoom Event
            ZedGraph.ZoomEvent += OnZoomEvent;

            // Tell ZedGraph to calculate the axis ranges
            // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets
            // up the proper scrolling parameters
            ZedGraph.AxisChange();

            // Make sure the Graph gets redrawn
            ZedGraph.Invalidate();
        }
Beispiel #9
0
        //
        //Below are functions which have been outsourced for clarity in main code (above)
        //
        public void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            zgc.MasterPane.PaneList.Clear();

            AverageChunkSize1 = Convert.ToInt32(Math.Round(Convert.ToDouble(AvChunkBox1.Value) * 10.0  / TimebinFactor));
            AverageChunkSize2 = Convert.ToInt32(Math.Round(Convert.ToDouble(AvChunkBox2.Value) * 10.0  / TimebinFactor));
            XScaleValue1 = Convert.ToInt16(XScale1.Value);
            XScaleValue2 = Convert.ToInt16(XScale2.Value);

            GraphPane myPane1 = new GraphPane();
            GraphPane myPane2 = new GraphPane();

            zgc.MasterPane.Add(myPane1);
            zgc.MasterPane.Add(myPane2);

            zgc.MasterPane.PaneList[0].Legend.IsVisible = false;
            zgc.MasterPane.PaneList[1].Legend.IsVisible = false;

            myPane1.Chart.Fill = new Fill(Color.Black);
            myPane2.Chart.Fill = new Fill(Color.Black);
            myPane1.Title.Text = "myPane1";
            myPane2.Title.Text = "myPane2";

            LineItem ThresholdLine1 = zgc.MasterPane.PaneList[0].AddCurve("Threshold1", ThresholdList1, Color.DarkOliveGreen, SymbolType.None);
            ThresholdLine1.Line.Width = 2.0F;
            LineItem ThresholdLine2 = zgc.MasterPane.PaneList[1].AddCurve("Threshold2", ThresholdList2, Color.DarkGoldenrod, SymbolType.None);
            ThresholdLine2.Line.Width = 2.0F;

            SetBarProperties(1, Color.White, 1.0F, Color.Red, 10.0F);
            SetBarProperties(2, Color.White, 1.0F, Color.Red, 10.0F);

            // Layout the GraphPanes using a default Pane Layout
            using (Graphics g = this.CreateGraphics())
            {
                zgc.MasterPane.SetLayout(g, PaneLayout.SingleRow);
            }

            //Function to set axes of graph panes.
            zgc.AxisChange();
            SetXAxis1();
            SetXAxis2();
            if (AutoScale.Checked == false)
            {
                SetYAxis1();
                SetYAxis2();
                ThresholdScrollBar1.Maximum = YMax1;
                ThresholdScrollBar2.Maximum = YMax2;
                ThresholdScrollBar1.Minimum = YMin1;
                ThresholdScrollBar2.Minimum = YMin2;
            }
            ThresholdScrollBar1.Value = ThresholdScrollBar1.Maximum;
            ThresholdScrollBar2.Value = ThresholdScrollBar2.Maximum;
            zgc.AxisChange();

            Console.WriteLine("Create Graph");
        }
 public void CreateChart(ZedGraph.ZedGraphControl zgc, ref CW_PeakRegs[] IR)
 {
     EventHandler method = null;
     try
     {
         zgc.GraphPane = this.myPane;
         zgc.GraphPane.CurveList.Clear();
         zgc.GraphPane.GraphObjList.Clear();
         this.RedLimit = (double) this.RedNumericUpDown.Value;
         this.BlueLimit = (double) this.BlueNumericUpDown.Value;
         this.GreenLimit = (double) this.GreenNumericUpDown.Value;
         this.myPane.Title.Text = "CW Interference Detection";
         this.myPane.YAxis.Title.Text = "Power dB/Hz";
         this.myPane.XAxis.Title.Text = "Frequency (from L1 center)";
         this.myPane.BarSettings.Type = ZedGraph.BarType.Overlay;
         int num = 0;
         int num2 = 0;
         int num3 = 0;
         for (int i = 0; i < 8; i++)
         {
             if (IR[i].magD >= this.GreenLimit)
             {
                 if (IR[i].magD >= this.RedLimit)
                 {
                     num++;
                 }
                 if ((IR[i].magD >= this.BlueLimit) && (IR[i].magD < this.RedLimit))
                 {
                     num2++;
                 }
                 if (IR[i].magD < this.BlueLimit)
                 {
                     num3++;
                 }
             }
         }
         double[] x = new double[num];
         double[] y = new double[num];
         double[] numArray3 = new double[num3];
         double[] numArray4 = new double[num3];
         double[] numArray5 = new double[num2];
         double[] numArray6 = new double[num2];
         int index = -1;
         int num6 = -1;
         int num7 = -1;
         for (int j = 0; j < 8; j++)
         {
             try
             {
                 if (IR[j].magD >= this.GreenLimit)
                 {
                     if ((num > 0) && (IR[j].magD >= this.RedLimit))
                     {
                         index++;
                         x[index] = IR[j].freqD;
                         y[index] = IR[j].magD;
                     }
                     if (((num2 > 0) && (IR[j].magD >= this.BlueLimit)) && (IR[j].magD < this.RedLimit))
                     {
                         num6++;
                         numArray5[num6] = IR[j].freqD;
                         numArray6[num6] = IR[j].magD;
                     }
                     if ((num3 > 0) && (IR[j].magD < this.BlueLimit))
                     {
                         num7++;
                         numArray3[num7] = IR[j].freqD;
                         numArray4[num7] = IR[j].magD;
                     }
                 }
             }
             catch (IndexOutOfRangeException exception)
             {
                 string str = exception.ToString();
                 string msg = "### Interference Report GUI handler error -- " + str;
                 this.comm.WriteApp(msg);
             }
         }
         if (num > 0)
         {
             string label = string.Format(">{0:F1}", this.RedLimit);
             this.myPane.AddBar(label, x, y, Color.Red);
         }
         if (num2 > 0)
         {
             string str4 = string.Format(">{0:F1}", this.BlueLimit);
             this.myPane.AddBar(str4, numArray5, numArray6, Color.Blue);
         }
         if (num3 > 0)
         {
             string str5 = string.Format("<{0:F1}", this.GreenLimit);
             this.myPane.AddBar(str5, numArray3, numArray4, Color.Green);
         }
         AddlabelToBars(this.myPane, x, y);
         AddlabelToBars(this.myPane, numArray5, numArray6);
         AddlabelToBars(this.myPane, numArray3, numArray4);
         this.myPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45f);
         this.myPane.YAxis.Scale.MaxAuto = false;
         this.myPane.YAxis.Scale.MinAuto = false;
         this.myPane.XAxis.Scale.MaxAuto = false;
         this.myPane.XAxis.Scale.MinAuto = false;
         this.myPane.YAxis.Scale.Max = 100.0;
         this.myPane.YAxis.Scale.Min = 0.0;
         this.myPane.XAxis.Scale.Min = 1.57E+15;
         this.myPane.XAxis.Scale.Max = 1.58E+15;
         this.myPane.BarSettings.ClusterScaleWidthAuto = false;
         this.myPane.BarSettings.ClusterScaleWidth = 1000000000000;
         zgc.AxisChange();
         this.myPane.Fill = new ZedGraph.Fill(Color.WhiteSmoke);
         if (method == null)
         {
             method = delegate {
                 zgc.Refresh();
                 zgc.Update();
             };
         }
         base.Invoke(method);
         zgc.Size = new Size(base.ClientRectangle.Width - 0x19, base.ClientRectangle.Height - 90);
     }
     catch (Exception exception2)
     {
         string str6 = exception2.ToString();
         string str7 = "### Interference Report GUI handler error -- " + str6;
         this.comm.WriteApp(str7);
     }
 }
		//Настройки графика
		void setup_graph(ZedGraph.ZedGraphControl graph)
		{
			var pane = graph.GraphPane;
			pane.YAxis.Title.Text = "y";
			pane.X2Axis.Title.Text = "x";

			//Настраиваем пересечение осей
			pane.XAxis.Cross = 0.0;
			pane.YAxis.Cross = 0.0;
			pane.XAxis.Scale.IsSkipFirstLabel = true;
			pane.XAxis.Scale.IsSkipLastLabel = true;
			pane.XAxis.Scale.IsSkipCrossLabel = true;
			pane.YAxis.Scale.IsSkipFirstLabel = true;
			pane.YAxis.Scale.IsSkipLastLabel = true;
			pane.YAxis.Scale.IsSkipCrossLabel = true;

			//Убираем засечки сверху и снизу
			pane.XAxis.MinorTic.IsOpposite = false;
			pane.XAxis.MajorTic.IsOpposite = false;
			pane.YAxis.MinorTic.IsOpposite = false;
			pane.YAxis.MajorTic.IsOpposite = false;

			graph.AxisChange();
			graph.Invalidate();
		}
Beispiel #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="myGraphControl"></param>
        /// <param name="X1"></param>
        /// <param name="Y1"></param>
        /// <param name="X2"></param>
        /// <param name="Y2"></param>
        /// <param name="title"></param>
        /// <param name="Xtitle"></param>
        /// <param name="Ytitle"></param>
        public void MyDrawPic2(ZedGraph.ZedGraphControl myGraphControl, double[] X1, double[] Y1, double[] X2, double[] Y2, 
            string title, string Xtitle, string Ytitle)
        {
            GraphPane myPane = myGraphControl.GraphPane;
            myPane.Legend.IsVisible = false;
            myPane.CurveList.Clear();
            myPane.Title.Text = title;
            myPane.XAxis.Title.Text = Xtitle;
            myPane.YAxis.Title.Text = Ytitle;

            PointPairList listr1 = new PointPairList();
            PointPairList listr2 = new PointPairList();
            PointPairList listr3 = new PointPairList();
            for (int i = 0; i < X1.Length; i++)
            {
                listr1.Add(Convert.ToDouble(X1[i].ToString("f6")), Convert.ToDouble(Y1[i].ToString("f6")));
            }
            for (int i = 0; i < X2.Length; i++)
            {
                listr2.Add(Convert.ToDouble(X2[i].ToString("f6")), Convert.ToDouble(Y2[i].ToString("f6")));
            }

            //add rack curve
            LineItem myCurveR1 = myPane.AddCurve("title", listr1, Color.Blue, SymbolType.None);
            LineItem myCurveR2 = myPane.AddCurve("title", listr2, Color.Blue, SymbolType.None);
            LineItem myCurveR3 = myPane.AddCurve("title", listr3, Color.Blue, SymbolType.None);
            myCurveR1.Line.Width = 2;
            myCurveR2.Line.Width = 2;
            myCurveR3.Line.Width = 2;
            myCurveR1.Symbol.Fill = new Fill(Color.White);
            myCurveR2.Symbol.Fill = new Fill(Color.White);
            myCurveR3.Symbol.Fill = new Fill(Color.White);
            myCurveR1.IsY2Axis = true;
            myCurveR2.IsY2Axis = true;
            myCurveR3.IsY2Axis = true;
            myPane.XAxis.MajorGrid.IsVisible = true;

            myPane.YAxis.Scale.FontSpec.FontColor = Color.Black;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Black;
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            myPane.YAxis.MajorGrid.IsZeroLine = false;
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.Min = -30;
            myPane.YAxis.Scale.Max = 30;

            myPane.Y2Axis.IsVisible = true;
            myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Black;
            myPane.Y2Axis.Title.FontSpec.FontColor = Color.Black;
            myPane.Y2Axis.MajorTic.IsOpposite = false;
            myPane.Y2Axis.MinorTic.IsOpposite = false;
            myPane.Y2Axis.MajorGrid.IsVisible = true;
            myPane.Y2Axis.Scale.Align = AlignP.Inside;
            myPane.Chart.Fill = new Fill(Color.White, Color.White, 45.0f);
            myGraphControl.IsShowPointValues = true;
            myGraphControl.PointValueEvent += new ZedGraph.ZedGraphControl.PointValueHandler(MyPointValueHandler);

            myGraphControl.ZoomEvent += new ZedGraph.ZedGraphControl.ZoomEventHandler(MyZoomEvent);

            myGraphControl.AxisChange();
            myGraphControl.RestoreScale(myPane);
            myGraphControl.Invalidate();
            Application.DoEvents();
            Thread.Sleep(10);//��ͣ0.05��
        }
Beispiel #13
0
        public void initialDateAxis(ZedGraph.ZedGraphControl zedChart)
        {
            if(this.m_dtLine1==null&&this.m_dtLine2==null)
            {
                return;
            }

            GraphPane myPane = zedChart.GraphPane;

            // Set the titles and axis labels
            myPane.Title = this.m_strTitle;
            //myPane.

            myPane.XAxis.Title =this.m_xAxisTitle;

            myPane.YAxis.Title = this.m_yAxisTitle;

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();

            for ( int i=0; i<this.m_dtLine1.Rows.Count; i++ )
            {

                DateTime dt=Convert.ToDateTime(this.m_dtLine1.Rows[i]["x"].ToString());

                double x = (double) new XDate( dt.Year,dt.Month, dt.Day);

                double y = Convert.ToDouble(this.m_dtLine1.Rows[i]["y"].ToString());

                list.Add( x, y );
            }

            PointPairList list1=new PointPairList();

            for ( int i=0; i<this.m_dtLine2.Rows.Count; i++ )
            {

                DateTime dt=Convert.ToDateTime(this.m_dtLine2.Rows[i]["x"].ToString());

                double x = (double) new XDate(dt.Year,dt.Month,dt.Day,dt.Hour,dt.Minute,dt.Second);

                double y = Convert.ToDouble(this.m_dtLine2.Rows[i]["y"].ToString());

                list1.Add( x, y );

            }

            int iCount=0;
            string[] strXLabels;

            if(this.m_dtLine2.Rows.Count>this.m_dtLine1.Rows.Count)
            {
                iCount=this.m_dtLine2.Rows.Count;
                strXLabels=new string[iCount];
                for(int i=0;i<iCount;i++)
                {
                    DateTime dt=Convert.ToDateTime(this.m_dtLine2.Rows[i]["x"].ToString());

                    if(this.m_strState!="Day")
                        strXLabels[i]=String.Format("{0}-{1}-{2}",dt.Year.ToString(),dt.Month.ToString(),dt.Day.ToString());
                    else
                        strXLabels[i]=String.Format("{0}-{1}-{2} {3}:{4}:{5}",dt.Year.ToString(),dt.Month.ToString(),dt.Day.ToString(),dt.Hour.ToString(),dt.Minute.ToString(),dt.Second.ToString());
                }
            }
            else
            {
                iCount=this.m_dtLine1.Rows.Count;
                strXLabels=new string[iCount];
                for(int i=0;i<iCount;i++)
                {
                    DateTime dt=Convert.ToDateTime(this.m_dtLine1.Rows[i]["x"].ToString());

                    if(this.m_strState!="Day")
                        strXLabels[i]=String.Format("{0}-{1}-{2}",dt.Year.ToString(),dt.Month.ToString(),dt.Day.ToString());
                    else
                        strXLabels[i]=String.Format("{0}-{1}-{2} {3}:{4}:{5}",dt.Year.ToString(),dt.Month.ToString(),dt.Day.ToString(),dt.Hour.ToString(),dt.Minute.ToString(),dt.Second.ToString());

                }
            }

            myPane.CurveList.Clear();

            // Generate a red curve with diamond
            // symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve( this.m_strLine1Name,
                list, Color.Black , SymbolType.Circle );

            //			myCurve = myPane.AddCurve( this.m_strLine2Name,
            //				list1, Color.Green , SymbolType.Default );

                myPane.XAxis.Type = AxisType.Text;
                myPane.XAxis.TextLabels=strXLabels;

            myPane.XAxis.ScaleFontSpec.Size=10;
            myPane.YAxis.ScaleFontSpec.Size=10;
            myCurve.Symbol.Fill = new Fill( Color.White);
            myCurve.Symbol.Size = 4;

            zedChart.AxisChange();
            zedChart.Invalidate();
        }
Beispiel #14
0
        public void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            zgc.MasterPane.PaneList.Clear();

            time1 = 0;
            time2 = 0;
            GraphPane myPane1 = new GraphPane();
            //GraphPane myPane2 = new GraphPane();
            zgc.MasterPane.Add(myPane1);
            //    zgc.MasterPane.Add(myPane2);

            myPane1.Title.Text = "myPane1" ;
            //myPane2.Title.Text = "myPane2";
            zgc.GraphPane.TitleGap = 0f;
            zgc.GraphPane.XAxis.Scale.LabelGap = 0f;
            zgc.GraphPane.YAxisList[0].Scale.LabelGap = 0f;

            //FilteredPointList Flist = new FilteredPointList(x,y);
            //FilterList = Flist;
            //Flist.SetBounds(x[j] - 10000, x[j], 500);
            //Make a new curve
             BarItem curve = myPane1.AddBar("Average Counts", list1, Color.Black/*, SymbolType.None*/);
            // TextureBrush joebrush = new TextureBrush(Joe);
            curve.Bar.Fill = new Fill(Color.Black);
             //curve.Line.IsVisible = false;
            //zgc.IsAntiAlias = true;

            // LineItem curve2 = myPane2.AddCurve("Counts (Avg ten)", list2, Color.Black, SymbolType.None);
             //TextureBrush grahambrush = new TextureBrush(graham);
               //  curve2.Line.Fill = new Fill(Color.Black);
               //  curve2.Line.Width = 3.0F;

            myPane1.Margin.All = 0;
            myPane1.Legend.IsVisible = false;
            myPane1.Title.IsVisible = false;
            myPane1.XAxis.IsVisible = false;

            //myPane1.XAxis.Draw(this.CreateGraphics(), myPane1, 1, 2000F);
            //Font XAxisFont = new Font("Arial", 6, GraphicsUnit.Pixel);
            //this.Font = f1;
            //myPane1.XAxis.Scale.FontSpec.Family = XAxisFont;
               /* myPane1.XAxis.Scale.FontSpec.Size = 10;
            Console.WriteLine("Width is {0}", myPane1.XAxis.Scale.FontSpec.GetWidth(this.CreateGraphics(),Convert.ToString(123),1);
            myPane1.XAxis.MinorTic.Size = 0;
            myPane1.XAxis.MajorTic.Size = 7;

            myPane1.YAxis.Scale.FontSpec.Size = 10;
            myPane1.YAxis.MinorTic.Size = 0;
            myPane1.YAxis.MajorTic.Size = 7;
            */

               // myPane1.YAxis.IsVisible = false;
            //Timer fort the X axis, defined later
            timer1.Interval = 10; //10 - buffer size increases due to build up but levels out at about 112 bytes.
            timer1.Enabled = true;
            timer1.Start();

            //Function to set axes of graphpanes.
            SetXAxis1();
            SetXAxis2();
            if (AutoScale.Checked == false)
            {
                SetYAxis();
            }

            // Layout the GraphPanes using a default Pane Layout
            using (Graphics g = this.CreateGraphics())
            {
                zgc.MasterPane.SetLayout(g, PaneLayout.SingleRow);
            }

            zgc.AxisChange();
            /*Save begging time for reference
            tickStart = Environment.TickCount;*/
            myPane1.XAxis.IsVisible = true;
            Console.WriteLine("Create Graph");
        }
    private void OnRenderGraph(ZedGraph.Web.ZedGraphWeb z, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        // Get the GraphPane so we can work with it

        GraphPane myPane = masterPane[0];

        // Set the title and axis labels

        myPane.Title.Text = "";
        myPane.YAxis.Title.Text = "User";
        myPane.XAxis.Title.Text = "Productivity %";

        //	Get productivity for team users.

        DateTime DateStart = this.cc2DateSelector.StartDate();
        DateTime DateEnd = this.cc2DateSelector.EndDate();

        myPane.Title.Text = string.Format("{0} - {1}", ClassTimeAndDate.DateToString(DateStart), ClassTimeAndDate.DateToString(DateEnd));

        ClassReport oRep = new ClassReport();
        DataSet oDs = oRep.GetTeamProductivity(Convert.ToInt32(this.DdlTeams.SelectedValue), Convert.ToInt32(this.DdlUsers.SelectedValue), DateStart, DateEnd);
        Int32 RowNo = 0;

        string[] labels = new string[oDs.Tables[0].Rows.Count];
        double[] values = new double[oDs.Tables[0].Rows.Count];

        for (RowNo = 0; RowNo < oDs.Tables[0].Rows.Count; RowNo++)
        {
            labels[RowNo] = oDs.Tables[0].Rows[RowNo]["UserName"].ToString();
            values[RowNo] = Convert.ToDouble(oDs.Tables[0].Rows[RowNo]["Productivity"].ToString());
        }

        myPane.YAxis.Scale.TextLabels = labels;
        myPane.YAxis.Type = AxisType.Text;

        myPane.XAxis.Scale.Min = 0;
        myPane.XAxis.Scale.Max = 120.0;
        myPane.XAxis.MajorTic.Size = 10.0F;
        myPane.XAxis.MajorTic.IsInside = false;
        myPane.XAxis.MajorGrid.IsVisible = true;
        myPane.XAxis.MinorTic.Size = 5.0F;
        myPane.XAxis.MinorTic.IsInside = false;

        //	Legend.

        BarItem myCurve = myPane.AddBar("Productivity", values, null, Color.Red);

        //	Chart background.

        myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);

        myPane.BarSettings.Base = BarBase.Y;

        masterPane.AxisChange(g);
        BarItem.CreateBarLabels(myPane, false, "f0");

        Page.Title = TXT_PAGETITLE;
        this.LblPageTitle.Text = TXT_PAGETITLE;
    }
Beispiel #16
0
        public void DrawGraph(int z, int n, double a, double b)
        {
            ZedGraph.PointPairList F  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList F1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList F2 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList S2 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e  = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList e2 = new ZedGraph.PointPairList();

            double h = (b - a) / n;

            for (int i = 0; i < n + 1; i++)
            {
                if (i % 4 == 0 && i != 0 && i != n)
                {
                    continue;
                }
                double x0  = a + i * h;
                double FF  = Function(x0, z);
                double SS  = Spline(z, n, a, b, x0);
                double FF1 = Function1(x0, z);
                double SS1 = Spline1(z, n, a, b, x0);
                double FF2 = Function2(x0, z);
                double SS2 = Spline2(z, n, a, b, x0);
                double E   = FF - SS;
                double E1  = FF1 - SS1;
                double E2  = FF2 - SS2;

                F.Add(x0, FF);
                S.Add(x0, SS);
                F1.Add(x0, FF1);
                S1.Add(x0, SS1);
                F2.Add(x0, FF2);
                S2.Add(x0, SS2);
                e.Add(x0, E);
                e1.Add(x0, E1);
                e2.Add(x0, E2);
            }

            ZedGraph.GraphPane.CurveList.Clear();

            if (comboBox1.SelectedIndex == 0)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F(x)", F, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S(x)", S, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F(x)-S(x)", e, Color.Red, SymbolType.None);
            }
            if (comboBox1.SelectedIndex == 1)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F'(x)", F1, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S'(x)", S1, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F'(x)-S'(x)", e1, Color.Red, SymbolType.None);
            }
            if (comboBox1.SelectedIndex == 2)
            {
                LineItem Curve  = ZedGraph.GraphPane.AddCurve("F''(x)", F2, Color.Green, SymbolType.None);
                LineItem SCurve = ZedGraph.GraphPane.AddCurve("S''(x)", S2, Color.Blue, SymbolType.None);
                LineItem ECurve = ZedGraph.GraphPane.AddCurve("F''(x)-S''(x)", e2, Color.Red, SymbolType.None);
            }


            ZedGraph.AxisChange();

            ZedGraph.Invalidate();
        }
        private void OnRenderUserChart(ZedGraph.Web.ZedGraphWeb z, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
        {
            GraphPane graphPane = masterPane[0];
            graphPane.Title.Text = Resource.MemberGraphTitle;
            graphPane.XAxis.Title.Text = Resource.MemberGraphXAxisLabel;
            graphPane.YAxis.Title.Text = Resource.MemberGraphYAxisLabel;

            PointPairList pointList = new PointPairList();

            using (IDataReader reader = SiteUser.GetUserCountByYearMonth(siteSettings.SiteId))
            {
                while (reader.Read())
                {
                    double x = new XDate(Convert.ToInt32(reader["Y"]), Convert.ToInt32(reader["M"]), 1);
                    double y = Convert.ToDouble(reader["Users"]);
                    pointList.Add(x, y);
                }
            }

            LineItem myCurve2 = graphPane.AddCurve(Resource.MemberGraphYAxisLabel, pointList, Color.Blue, SymbolType.Circle);
            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Green, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            graphPane.XAxis.Type = AxisType.Date;
            graphPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Beispiel #18
0
        public void initialDateAxis(ZedGraph.ZedGraphControl zedChart)
        {
            try
            {
                if(this.m_dtLine1==null&&this.m_dtLine2==null)
                {
                    return;
                }

                GraphPane myPane = zedChart.GraphPane;

                // Set the titles and axis labels
                myPane.Title = this.m_strTitle;
                //myPane.

                myPane.XAxis.Title =this.m_xAxisTitle;

                myPane.YAxis.Title = this.m_yAxisTitle;

                double[] dDatas=new double[this.m_dtLine1.Rows.Count];
                for(int i=0;i<this.m_dtLine1.Rows.Count;i++)
                {
                    dDatas[i]=double.Parse(m_dtLine1.Rows[i]["y"].ToString().Trim());
                }
                string[] strLabels=new string[this.m_dtLine1.Rows.Count];
                for(int i=0;i<this.m_dtLine1.Rows.Count;i++)
                {
                    if(this.isO(i))
                            {
                        strLabels[i]=m_dtLine1.Rows[i]["x"].ToString().Trim();
                            }

                }
                myPane.CurveList.Clear();
                LineItem myCurve = myPane.AddCurve(this.m_strLine1Name,
                    null, dDatas, Color.Black, SymbolType.Circle);
                myPane.XAxis.Type = AxisType.Text;
                // Set the XAxis labels
                myPane.XAxis.TextLabels = strLabels;
                //myPane.XAxis.ScaleFontSpec.Angle = 40;
                myPane.XAxis.ScaleFontSpec.Size=10;
                myPane.YAxis.ScaleFontSpec.Size=10;
                myCurve.Symbol.Size = 4;
                zedChart.AxisChange();
                zedChart.Invalidate();

            }
            catch(Exception ex)
            {
                cSaveErr.CSaveErr.msgboxErr(ex.ToString());
            }
        }
Beispiel #19
0
 private void OnRenderGraph(System.Drawing.Graphics g, ZedGraph.MasterPane mPane)
 {
     //mPane[0] = new GraphPane();
     mPane.AxisChange(g);
 }