Beispiel #1
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();
        }
        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);
        }
        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();
        }
        public InterfaceManager(ZedGraph.ZedGraphControl zgc, ListBox listBox, ComboBox comboBox)
        {
            zedGraphControl = zgc;
            zedGraphPane = zgc.GraphPane;
            bariersListBox = listBox;
            surfaceTypeComboBox = comboBox;

            _R = 20;
            _hMax = 200;
            _antennaH = 20;
            _lambda = 2.5;

            zedGraphControl.IsShowContextMenu = false;
            ZedGraph.Line.Default.IsSmooth = true;
            ZedGraph.Line.Default.SmoothTension = 0.3F;
            ZedGraph.GraphPane.Default.NearestTol = 10;
            zedGraphControl.EditButtons = MouseButtons.Left;
            zedGraphPane.Title.Text = "Профиль интервала РРЛ";
            zedGraphPane.XAxis.Title.Text = "Расстояние";
            zedGraphPane.YAxis.Title.Text = "Высота";

            FinalState finalState = new FinalState(this);
            InputBarier inputBarierState = new InputBarier(null, this);
            InputProfilePoints inputProfilePoints =  new InputProfilePoints(inputBarierState, this);
            currentState = new InputIntervalParameters(inputProfilePoints, this);
        }
Beispiel #5
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();
        }
 public void ConnectToGraph(ZedGraph.GraphPane objPane)
 {
     for (int nInd1 = 0; nInd1 < MAX_MARKERS; nInd1++)
     {
         for (int nInd2 = 0; nInd2 < (int)RFExplorerSignalType.TOTAL_ITEMS; nInd2++)
         {
             objPane.GraphObjList.Add(m_arrMarkers[nInd1][nInd2]);
         }
     }
 }
Beispiel #7
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 #8
0
        public static bool paintChartAvg(string strFrom,string strTo,string strWellNo,string strCDataType,ZedGraph.ZedGraphControl zedChart)
        {
            try
            {
                DataTable dtAvg=new DataTable();

                if(BengZhan.comReport.CReports.getDtAvgReport(strWellNo,strFrom,strTo,ref dtAvg)==false)
                {
                    return false;
                }

                clearDt(ref dtAvg);

                if(dtAvg==null)
                {
                    return false;
                }

                string strDataType="";
                if(getEDataType(strCDataType,ref strDataType)==false)
                {
                    return false;
                }

                DataTable dtChart=new DataTable();
                dtChart.Columns.Add("x");
                dtChart.Columns.Add("y");

                for(int i=0;i<dtAvg.Rows.Count;i++)
                {
                    DataRow dr=dtChart.NewRow();
                    dr["x"]=dtAvg.Rows[i]["time"].ToString().Trim();
                    dr["y"]=dtAvg.Rows[i][strDataType].ToString().Trim();
                    dtChart.Rows.Add(dr);
                }

                string strSql=String.Format("select wellName from tbWell where wellNo='{0}'",strWellNo);
                string strWellName=BengZhan.CDBConnection.ExecuteScalar(strSql);

                string strTitle=String.Format("��ͳ��ֵͼ��  ���վ:{0}  ʱ�䷶Χ{1}��{2}",strWellName,strFrom,strTo);

                return paintChart(dtChart,strCDataType,"����","month",strTitle,zedChart);

            }
            catch(Exception ex)
            {
                cSaveErr.CSaveErr.msgboxErr(ex.ToString());
                return false;
            }
        }
        public static List<clsInterval> calcGaps(ref List<object> vals, ref ZedGraph.PointPairList list)
        {
            List<clsInterval> gaps = new List<clsInterval>();
            for (int i = 0; i < vals.Count; i++)
            {
                try
                {
                    gaps.AddRange(gapbyval(Convert.ToDouble(vals[i]), ref list));
                }
                catch (Exception ex) { }

            }
            return gaps;
        }
        public ReflectogramViewer(ZedGraph.PointPairList reflectogram, DateTime date, double temperature)
        {
            InitializeComponent();

            ALayout.SetReflectogramZedgraphStyle(refl_graph);

            ZedGraph.LineItem myCurve = refl_graph.GraphPane.AddCurve(date.ToString("dd.MM.yy HH:mm:ss.ff") + " - T=" + Math.Round(temperature, 1).ToString() + " °C",
                       reflectogram, SystemColors.HotTrack, ZedGraph.SymbolType.None);

            myCurve.Line.IsSmooth = false;

            refl_graph.AxisChange();
            // Make sure the Graph gets redrawn
            refl_graph.Invalidate();
        }
Beispiel #11
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();
        }
Beispiel #12
0
        //����ͼ��
        public static bool paintChartDetail(string strFrom,string strTo,string strWellNo,string strCDataType,ZedGraph.ZedGraphControl zedChart)
        {
            try
            {
                DataTable dtDetail=new DataTable();

                if(BengZhan.comReport.CChart.getDtDetailReport(strWellNo,strFrom,strTo,ref dtDetail)==false)
                {
                    return false;
                }

                if(dtDetail==null)
                {
                    return false;
                }

                string strDataType="";
                if(getEDataType(strCDataType,ref strDataType)==false)
                {
                    return false;
                }

                DataTable dtChart=new DataTable();
                dtChart.Columns.Add("x");
                dtChart.Columns.Add("y");

                for(int i=0;i<dtDetail.Rows.Count;i++)
                {
                    DataRow dr=dtChart.NewRow();
                    dr["x"]=dtDetail.Rows[i]["time"].ToString().Trim();
                    dr["y"]=dtDetail.Rows[i][strDataType].ToString().Trim();
                    dtChart.Rows.Add(dr);
                }

                string strSql=String.Format("select depName from tbWell where wellNo='{0}'",strWellNo);
                string strDepName=BengZhan.CDBConnection.ExecuteScalar(strSql);

                string strTitle=String.Format("��ϸ��ͼ��  ��λ:{0}  ʱ�䷶Χ{1}��{2}",strDepName,strFrom,strTo);

                return paintChart(dtChart,strCDataType,"ʱ��","Day",strTitle,zedChart);

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
        }
 //private List<clsInterval> gaps;
 //private List<double> uniqueVals;
 //public clsRemoveDataGaps(List<double> vals, ref ZedGraph.PointPairList)
 //{
 //    uniqueVals = vals;
 //}
 public static void missingValues( ref ZedGraph.PointPairList list)
 {
     for (int i = 1; i < list.Count; i++)
     {
         double curDate = list[i].X;
         double prevDate = list[i - 1].X;
         //if currdate - prevdate is greater than 1 day
         double diff = curDate - prevDate;
         if (diff > 3)
         {
             //insert two values between the two points with NaN as the value
             list.Insert(i, prevDate + 1, double.NaN);
             list.Insert(i + 1, curDate - 1, double.NaN);
             i = i + 2;
         }
     }
 }
        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();
        }
Beispiel #17
0
 public static double[] GetDatafromPointPairList(ZedGraph.PointPairList data)
 {
     try
     {
         if (data != null)
         {
             List<double> result = new List<double>();
             for (int i = 0; i < data.Count; i++)
             {
                 result.Add(data[i].Y);
             }
             return result.ToArray();
         }
         else
             return null;
     }
     catch (Exception ex)
     {
         FileWorker.WriteEventFile(DateTime.Now, "AStatistic", "GetDatafromPointPairList", ex.Message);
         return null;
     }
 }
Beispiel #18
0
        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 #19
0
        private void show_data()
        {
            moto_speed_label.Text   = moto_speed.ToString();
            moto_current_label.Text = moto_current.ToString();
            moto_power_label.Text   = moto_power.ToString();

            press_gauge.Value     = Math.Round(pressure, 2);
            label_press_data.Text = Math.Round(pressure, 2).ToString();

            //stm32 接受数据绘制
            flow_gauge.Value      = flow;
            label_float_data.Text = flow.ToString();

            thermometer.Value       = temperature;
            tempertature_label.Text = temperature.ToString();

            //画图
            GraphPane MyPane1 = ZedGraph.GraphPane;

            counter++;
            list_moto_speed.Add(counter, pressure);
            moto_current_meter.Value = moto_current;
            moto_press_meter.Value   = moto_power;
            if (counter > (MyPane1.XAxis.Scale.Max - MyPane1.XAxis.Scale.Min))
            {
                MyPane1.XAxis.Scale.Min = counter - (MyPane1.XAxis.Scale.Max - MyPane1.XAxis.Scale.Min);
                MyPane1.XAxis.Scale.Max = counter;
            }
            ZedGraph.BeginInvoke(
                new MethodInvoker(
                    delegate
            {
                this.ZedGraph.AxisChange();
                this.ZedGraph.Refresh();
                this.ZedGraph.IsShowPointValues = false;
            }
                    )
                );
        }
Beispiel #20
0
 public static double StaticDeviation(ZedGraph.PointPairList pointPair)
 {
     try
     {
         double[] data = GetDatafromPointPairList(pointPair);
         if (data != null)
         {
             double sum = 0.0;
             double average = data.Average();
             foreach (double point in data)
             {
                 sum += Math.Pow(point - average, 2);
             }
             return Math.Sqrt(sum / data.Length);
         }
         else
             return -1.0;
     }
     catch (Exception ex)
     {
         FileWorker.WriteEventFile(DateTime.Now, "AStatistic", "StaticDeviation", ex.Message);
         return -1.0;
     }
 }
        internal void AddReflectogram(ZedGraph.PointPairList reflectogram, DateTime date, double temperature)
        {
            if (refl_graph.GraphPane.CurveList.Count > 10)
            {
                refl_graph.GraphPane.CurveList.Clear();
            }
            ZedGraph.LineItem myCurve;
            if (refl_graph.GraphPane.CurveList.Count == 0)
            {
                myCurve = refl_graph.GraphPane.AddCurve(date.ToString("dd.MM.yy HH:mm:ss.ff") + " - T=" + Math.Round(temperature, 1).ToString() + " °C",
                       reflectogram, SystemColors.HotTrack, ZedGraph.SymbolType.None);
            }
            else
            {
                myCurve = refl_graph.GraphPane.AddCurve(date.ToString("dd.MM.yy HH:mm:ss.ff") + " - T=" + Math.Round(temperature, 1).ToString() + " °C",
                           reflectogram, reflcolors[refl_graph.GraphPane.CurveList.Count - 1], ZedGraph.SymbolType.None);
            }

            myCurve.Line.IsSmooth = false;

            refl_graph.AxisChange();
            // Make sure the Graph gets redrawn
            refl_graph.Invalidate();
        }
Beispiel #22
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 #23
0
 private void MyZoomEvent(ZedGraph.ZedGraphControl control, ZoomState oldState,
             ZoomState newState)
 {
 }
Beispiel #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="control"></param>
        /// <param name="pane"></param>
        /// <param name="curve"></param>
        /// <param name="iPt"></param>
        /// <returns></returns>
        private string MyPointValueHandler(ZedGraph.ZedGraphControl control, GraphPane pane, CurveItem curve, int iPt)
        {
            PointPair pt = curve[iPt];

            return curve.Label.Text + "   ��������" + pt.X.ToString("f4") + " �������� " + pt.Y.ToString("f4") + " (mm)";
        }
Beispiel #25
0
        /// <summary>
        /// 
        /// </summary>
        public void Draw(ZedGraph.GraphPane pane, object dataSource)
        {
            if (this.GraphPaneConfig == null)
            {
                return;
            }

            if (this.DataSource == null)
            {
                return;
            }

            this.GraphPaneConfig.ConfigGraphPane(pane);
            foreach (CurveConfigBase cfg in this.GraphPaneConfig.CurveConfigBaseCollection)
            {
                CurveDataCollection cds = cfg.Create(dataSource);
                foreach (CurveData cd in cds)
                {
                    switch (this.GraphPaneConfig.CurItemType)
                    {
                        case CurveItemType.Line:
                            if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Date)
                            {
                                ZedGraph.LineItem curve = pane.AddCurve(cd.Name, cd.PointList, cd.Color);
                                curve.Symbol.Fill = new ZedGraph.Fill(Color.White);
                            }
                            else if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Text)
                            {
                                LineItem curve = pane.AddCurve(cd.Name, null, cd.YValues, cd.Color);
                                pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                                curve.Symbol.Fill = new Fill(Color.White);
                            }
                            break;

                        case CurveItemType.Bar:
                            pane.AddBar(cd.Name, null, cd.YValues, cd.Color);
                            pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                            break;

                        case CurveItemType.Pie:
                            pane.AddPieSlices(cd.YValues, cd.XAxisLabels);
                            break;
                    }
                }
            }
        }
Beispiel #26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="webObject"></param>
 /// <param name="g"></param>
 /// <param name="pane"></param>
 void _zedGraphWeb_RenderGraph(
     ZedGraph.Web.ZedGraphWeb webObject,
     System.Drawing.Graphics g,
     ZedGraph.MasterPane pane)
 {
     // TODO:
     //
     //pane[
     this.Draw(pane[0], this.DataSource);
 }
        private static List<clsInterval> gapbyval(double value, ref ZedGraph.PointPairList list)
        {
            List<clsInterval> gaps = new List<clsInterval>();
            int i = 0;
            clsInterval tmp = new clsInterval();
            foreach (ZedGraph.PointPair pt in list)
            {
                i++;
                if (pt.Y == value)
                {
                    if (tmp.Start <0)
                        tmp.Start = i;

                }
                else
                {

                    //set end date to previous if there is a currently active pair list
                    if (tmp.Start > 0)
                    {
                        tmp.End = i - 1;

                        // check to see if the time period is greater than 24 hrs
                        //double diff = list[tmp.End].X - list[tmp.Start].X;
                        if (list[tmp.End].X - list[tmp.Start].X > 1)
                            gaps.Add(tmp);
                            //reset tmp
                            tmp = new clsInterval();
                    }

                }
                //if (list[i - 1].X - list[i].X > 1)
                //    tmp.Start = i;
                //    tmp.End = i - 1;
                //    gaps.Add(tmp);
                //    tmp = new clsInterval();

            }
            return gaps;
        }
        public Interval(double R, double minH, double maxH, double lambda, ZedGraph.GraphPane graphPane, 
            string stationType, string subRange, int waveNumber)
        {
            this.R = R;
            this.minH = minH;
            this.maxH = maxH;
            this.lambda = lambda;
            this.antennaH = antennaH;
            this.graphPane = graphPane;
            this.stationType = stationType;
            this.subRange = subRange;
            this.waveNumber = waveNumber;

            bariers = new List<Barier>();

            PointPair begin = new PointPair(0, (minH + maxH) / 2.0);
            PointPair end = new PointPair(R, (minH + maxH) / 2.0);

            lineOfSight = new LineItem("Линия прямой видимости", new PointPairList(), Color.Blue, SymbolType.None);
            lineOfSight.AddPoint(begin.X, begin.Y + antennaH);
            lineOfSight.AddPoint(end.X, end.Y + antennaH);

            PointPairList points = new PointPairList();
            double x = 0;
            double stepX = R / 500;
            while (x <= R)
            {
                points.Add(x, getEarthCurveH(x));
                x += stepX;
            }
            earthCurve = new ZedGraph.LineItem("Дуга кривизны земной поверхности", points, Color.Green, SymbolType.None);

            graphPane.CurveList.Clear();
            profile = new Profile(begin, end, this);
            bariers = new List<Barier>();

            H0 = new PointPairList();
            x = 0;
            double step = 0.01;
            while (x <= R)
            {
                H0.Add(x, getH0(x));
                x += step;
            }
        }
Beispiel #29
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");
        }
Beispiel #30
0
	//private bool CreateStatisticTable(StatisticInfo[] infos, int statisticTypeIndex, object[] statistic)
	//{
	//    string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };

	//    TableHeaderRow headerRow = new TableHeaderRow();
	//    TableHeaderCell headerCell = new TableHeaderCell();
	//    headerCell.Text = StatisticTypeNames[statisticTypeIndex];
	//    headerRow.Cells.Add(headerCell);

	//    headerCell = new TableHeaderCell();
	//    headerCell.Text = StringDef.Count;
	//    headerRow.Cells.Add(headerCell);

	//    TableStatistic.Rows.Add(headerRow);

	//    for (int i = 0; i < infos.Length; i++)
	//    {
	//        StatisticInfo info = infos[i];
	//        TableRow row = new TableRow();

	//        TableCell cell = new TableCell();
	//        for (int j = 0; j < statistic.Length; j++)
	//        {
	//            if (statistic[j].Id == info.Type)
	//            {
	//                cell.Text = statistic[j].Name;
	//                row.Cells.Add(cell);
	//                break;
	//            }
	//        }

	//        cell = new TableCell();
	//        cell.Text = info.Count.ToString();
	//        row.Cells.Add(cell);

	//        TableStatistic.Rows.Add(row);
	//    }

	//    return true;
	//}

	protected void ZedGraphWebStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
	{
		if (_server != null)
		{
			GraphPane graphPane = masterPane[0];

			string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };
			string staticType = StatisticTypes[_statisticType];
			string staticTypeName = StatisticTypeNames[_statisticType];
			SqlCommand cmd = new SqlCommand("SELECT " + staticType + ",COUNT(*) FROM rolesfirst " + _whereStatement + " GROUP BY " + staticType);
            if (!_server.IsConnected)
            {
                //LabelMessage.Visible = true;
                //LabelMessage.Text = StringDef.NoConnectionAlert;
                return;
            }
			SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id,_server, cmd);

			if (result != null && result.Success)
			{
				//整理数据
				SqlDataType[] dataTypes = new SqlDataType[] { SqlDataType.Int32, SqlDataType.Int32 };
				result.SetFieldType(dataTypes);

				object[] statistic = null;
				switch (_statisticType)
				{
					case 0:
						{
							statistic = new object[FS2GameDataManager.MaxLevel];
							for (int level = 1; level <= FS2GameDataManager.MaxLevel; level++)
							{
								statistic[level - 1] = level;
							}
						}
						break;
					case 1:
						{
							statistic = new object[FS2GameDataManager.RoleClasses.Length];
							for (int i = 0; i < FS2GameDataManager.RoleClasses.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleClasses[i];
							}
						}
						break;
					case 2:
						{
							statistic = new object[FS2GameDataManager.RoleSexes.Length];
							for (int i = 0; i < FS2GameDataManager.RoleSexes.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleSexes[i];
							}
						}
						break;
					case 3:
						statistic = new object[] { 0, 1, 2, 3, 4 };
						break;
				}
				
				StatisticInfo[] infos = new StatisticInfo[statistic.Length];
				for (int i = 0; i < infos.Length; i++)
				{
					infos[i] = new StatisticInfo(int.Parse(statistic[i].ToString()), 0);
				}

				object[] record = null;
				while ((record = result.ReadRecord()) != null)
				{
					int type = (int)record[0];
					int count = (int)record[1];

					for (int i = 0; i < infos.Length; i++)
					{
						if (infos[i].Type == type)
						{
							infos[i].Count = count;
						}
					}
				}

				////构造数据表格
				//bool success = CreateStatisticTable(infos, _statisticType, statistic);
				//if (success)
				//{
				//    TableStatistic.Visible = true;
				//}

				graphPane.Title.Text = staticTypeName;
				graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

				graphPane.Legend.IsVisible = false;

				string[] textLabels = new string[statistic.Length];
				for (int i = 0; i < statistic.Length; i++)
				{
					textLabels[i] = statistic[i].ToString();
				}

				graphPane.XAxis.Title.Text = staticTypeName;
				graphPane.XAxis.MajorGrid.Color = WebConfig.GraphXAxisGridColor;

				if (_statisticType > 0)
				{
					graphPane.XAxis.MajorTic.IsBetweenLabels = true;
					graphPane.XAxis.Type = AxisType.Text;
					graphPane.XAxis.Scale.TextLabels = textLabels;
				}

				graphPane.YAxis.Title.Text = StringDef.Count;
				graphPane.YAxis.Scale.Min = 0;
				graphPane.YAxis.MajorGrid.IsVisible = true;
				graphPane.YAxis.MajorGrid.DashOff = 0;
				graphPane.YAxis.MajorGrid.Color = Color.Gray;
				graphPane.YAxis.MinorGrid.IsVisible = true;
				graphPane.YAxis.MinorGrid.Color = Color.LightGray;
				graphPane.YAxis.MinorGrid.DashOff = 0;

				if (_chartType == ChartType.Bar)
				{
					graphPane.BarSettings.Type = BarType.Stack;

					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制柱子
					BarItem barItem = graphPane.AddBar(StringDef.Count, types, counts, WebConfig.GraphColors[0]);
					barItem.Bar.Fill = new Fill(WebConfig.GraphColors[0]);
				}
				else if (_chartType == ChartType.Line)
				{
					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制线条
					LineItem lineItem = graphPane.AddCurve("xxx", types, counts, WebConfig.GraphColors[1], SymbolType.None);
				}

				graphPane.AxisChange(g);
			}
		}
	}
Beispiel #31
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();
        }
Beispiel #32
0
        bool ZedGraphControl_MouseMoveEvent( ZedGraph.ZedGraphControl sender, MouseEventArgs e )
        {
            if( CurrentGraphForm == null || !peakIntegrationMode.Checked || !CurrentGraphForm.ZedGraphControl.Focused )
                return false;

            if( integratePeaksLine != null && e.Button == MouseButtons.Left )
            {
                double x = CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.ReverseTransform( (float) e.X );
                double y = CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.ReverseTransform( (float) e.Y );
                //CurrentGraphForm.ZedGraphControl.GraphPane.GraphObjList.Remove( integratePeaksLine );
                //integratePeaksLine = new ZedGraph.LineItem( integratePeaksLine.Location.X1, integratePeaksLine.Location.Y1, x, y );
                //integratePeaksLine.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale;
                //CurrentGraphForm.ZedGraphControl.GraphPane.GraphObjList.Add( integratePeaksLine );
                integratePeaksLine.Points[1].X = Math.Min( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Max, Math.Max( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Min, x ) );
                integratePeaksLine.Points[1].Y = Math.Min( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Max, Math.Max( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Min, y ) );

                if( CurrentGraphForm.ZedGraphControl.GraphPane.CurveList[0].Points is PointList )
                {
                    foreach( ZedGraph.PolyObj obj in integratePeaksAreas )
                        CurrentGraphForm.ZedGraphControl.GraphPane.GraphObjList.Remove( obj );
                    integratePeaksAreas.Clear();

                    PointList pointList = (PointList) CurrentGraphForm.ZedGraphControl.GraphPane.CurveList[0].Points;
                    if( pointList.ScaledCount == 0 )
                        return false;

                    double x1, y1, x2, y2;
                    if( integratePeaksLine.Points[0].X > integratePeaksLine.Points[1].X )
                    {
                        x1 = integratePeaksLine.Points[1].X;
                        y1 = integratePeaksLine.Points[1].Y;
                        x2 = integratePeaksLine.Points[0].X;
                        y2 = integratePeaksLine.Points[0].Y;
                    } else
                    {
                        x1 = integratePeaksLine.Points[0].X;
                        y1 = integratePeaksLine.Points[0].Y;
                        x2 = integratePeaksLine.Points[1].X;
                        y2 = integratePeaksLine.Points[1].Y;
                    }

                    int lowerBoundIndex = pointList.LowerBound( x1 );
                    int upperBoundIndex = pointList.LowerBound( x2 );
                    if( upperBoundIndex < 0 )
                        upperBoundIndex = pointList.ScaledCount - 1;

                    double totalIntegratedArea = 0.0;
                    int totalAreaPoints = 0;
                    int totalAreaCount = 0;

                    // integration line can be in any of these states:

                    // * entirely to the left of the curve:
                    //		- no integration
                    // * entirely to the right of the curve:
                    //		- no integration
                    // * entirely between two consecutive points:
                    //		- integration is entirely interpolated based on data slope
                    // * starts to the left of the curve and ends between two consecutive points:
                    //		- start integration at the X value of the first data point
                    //		- end integration at the line's right X value
                    // * starts between two consecutive points and ends to the right of the curve:
                    //		- start integration at the line's left X value
                    //		- end integration at the X value of the last data point
                    // * starts between two consecutive points and ends between two different consecutive points:
                    //		- start integration at the line's left X value
                    //		- end integration at the line's right X value

                    // * entirely above the curve:
                    //		- no integration
                    // * starts above the curve and ends below the curve:
                    //		- start integration at the first intersection of the line with the curve
                    //		- end integration at the X value where the line ends
                    // * starts below the curve and ends above the curve:
                    //		- start integration at the X value where the line starts
                    //		- end integration at the last intersection of the line with the curve
                    // * entirely below the curve:
                    //		- start and end integration at the X values of the line

                    // * the Y value of the line's start point is less than 0 and the end point's is not:
                    //		- a special area point must be added before the first area's bottom left point
                    //		- add it at the intersection of the line with the X axis
                    // * the Y value of the line's end point is less than 0 and the start point's is not:
                    //		- a special area point must be added after the last area's bottom right point
                    //		- add it at the intersection of the line with the X axis
                    // * the Y values of both the start and end points of the line are less than 0:
                    //		- no special points are necessary

                    if( lowerBoundIndex >= 0 && x2 > x1 )
                    {
                        // calculate the linear function for integration line
                        double integratePeaksLineA = ( y2 - y1 ) / ( x2 - x1 );
                        double integratePeaksLineB = y1 - ( integratePeaksLineA * x1 );

                        // restrict the X range of the integration line to the minimum and maximum X values of the curve
                        // interpolate the Y value of the integration line at those X values
                        double leftInterpolatedX = Math.Max( pointList.ScaledList[0].X, x1 );
                        double leftInterpolatedY = Math.Max( 0, integratePeaksLineA * leftInterpolatedX + integratePeaksLineB );
                        double rightInterpolatedX = Math.Min( pointList.ScaledList[pointList.ScaledCount - 1].X, x2 );
                        double rightInterpolatedY = Math.Max( 0, integratePeaksLineA * rightInterpolatedX + integratePeaksLineB );

                        List<ZedGraph.PointD> areaPoints = new List<ZedGraph.PointD>();
                        //List<List<ZedGraph.PointD>> areaTrapezoids = new List<List<ZedGraph.PointD>>();
                        for( int i = Math.Max( 1, lowerBoundIndex ); i <= upperBoundIndex; ++i )
                        {
                            ZedGraph.PointPair rightPoint = pointList.ScaledList[i];
                            ZedGraph.PointPair leftPoint = pointList.ScaledList[i - 1];

                            // interpolate the Y value of the integration line at the previous and current points' X value
                            double lastPointLineY = integratePeaksLineA * leftPoint.X + integratePeaksLineB;
                            double curPointLineY = integratePeaksLineA * rightPoint.X + integratePeaksLineB;

                            // calculate the linear function between the previous and current points
                            double dataA = ( rightPoint.Y - leftPoint.Y ) / ( rightPoint.X - leftPoint.X );
                            double dataB = rightPoint.Y - ( dataA * rightPoint.X );

                            double leftInterpolatedPointY = dataA * leftInterpolatedX + dataB;
                            double rightInterpolatedPointY = dataA * rightInterpolatedX + dataB;

                            bool leftInterpolatedPointIsAboveLine = ( leftInterpolatedPointY >= leftInterpolatedY );
                            bool rightInterpolatedPointIsAboveLine = ( rightInterpolatedPointY >= rightInterpolatedY );

                            bool leftPointIsAboveLine = ( leftPoint.Y > lastPointLineY );
                            bool rightPointIsAboveLine = ( rightPoint.Y > curPointLineY );

                            bool leftPointIsLowerBound = ( i == 1 || i == lowerBoundIndex );
                            bool rightPointIsUpperBound = ( i == upperBoundIndex );

                            if( !leftInterpolatedPointIsAboveLine && !rightInterpolatedPointIsAboveLine ||
                                !leftPointIsAboveLine && !rightPointIsAboveLine )
                                continue;

                            bool needIntersection = ( leftInterpolatedPointIsAboveLine != rightInterpolatedPointIsAboveLine );

                            bool areaIsEmpty = ( areaPoints.Count == 0 );

                            if( rightPointIsAboveLine || leftPointIsAboveLine )
                            {
                                if( areaIsEmpty ) // start a new area
                                {
                                    if( leftPointIsLowerBound && leftInterpolatedPointIsAboveLine ) // interpolate the point on the curve above the line
                                    {
                                        if( y1 <= 0 && y2 > 0 )
                                        {
                                            double croppedBottomX = -integratePeaksLineB / integratePeaksLineA;
                                            if( croppedBottomX != leftInterpolatedX )
                                                areaPoints.Add( new ZedGraph.PointD( croppedBottomX, 0 ) );
                                        }
                                        areaPoints.Add( new ZedGraph.PointD( leftInterpolatedX, leftInterpolatedY ) ); // bottom left
                                        areaPoints.Add( new ZedGraph.PointD( leftInterpolatedX, leftInterpolatedPointY ) ); // top left

                                    } else if( needIntersection ) // interpolate the intersection of line and curve
                                    {
                                        double intersectX = ( dataB - integratePeaksLineB ) / ( integratePeaksLineA - dataA );
                                        double intersectY = dataA * intersectX + dataB;

                                        areaPoints.Add( new ZedGraph.PointD( intersectX, intersectY ) );
                                    }
                                }

                                if( rightPointIsUpperBound ) // end at the upper bound and add current area to the area list
                                {
                                    if( rightInterpolatedPointIsAboveLine )
                                    {
                                        // add a new point to the current area
                                        //areaPoints.Add( new ZedGraph.PointD( pointList.ScaledList[i].X, pointList.ScaledList[i].Y ) );

                                        areaPoints.Add( new ZedGraph.PointD( rightInterpolatedX, rightInterpolatedPointY ) ); // top right
                                        areaPoints.Add( new ZedGraph.PointD( rightInterpolatedX, rightInterpolatedY ) ); // bottom right
                                        if( y2 <= 0 && y1 > 0 ) // add another point if line extends below X axis
                                        {
                                            double croppedBottomX = -integratePeaksLineB / integratePeaksLineA;
                                            if( croppedBottomX != rightInterpolatedX )
                                                areaPoints.Add( new ZedGraph.PointD( croppedBottomX, 0 ) );
                                        }
                                    } else if( needIntersection ) // interpolate the intersection of line and curve
                                    {
                                        double intersectX = ( dataB - integratePeaksLineB ) / ( integratePeaksLineA - dataA );
                                        double intersectY = dataA * intersectX + dataB;

                                        areaPoints.Add( new ZedGraph.PointD( intersectX, intersectY ) );
                                    }

                                    if( areaPoints.Count == 0 )
                                        continue;

                                    ZedGraph.PolyObj integratePeaksArea = new ZedGraph.PolyObj( areaPoints.ToArray(), Color.Black, Color.Cyan, Color.Cyan );
                                    integratePeaksArea.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale;
                                    //integratePeaksArea.IsClosedFigure = true;
                                    areaPoints.Add( areaPoints[0] );
                                    integratePeaksAreas.Add( integratePeaksArea );

                                    double currentIntegratedArea = 0.0;
                                    for( int k, j = 0; j < areaPoints.Count; ++j )
                                    {
                                        k = ( j + 1 ) % areaPoints.Count;
                                        currentIntegratedArea += areaPoints[j].X * areaPoints[k].Y;
                                        currentIntegratedArea -= areaPoints[j].Y * areaPoints[k].X;
                                    }
                                    totalIntegratedArea += Math.Abs( currentIntegratedArea / 2.0 );
                                    totalAreaPoints += areaPoints.Count - 1;
                                    ++totalAreaCount;
                                    areaPoints.Clear();
                                } else
                                {
                                    // add a new top right point to the current area
                                    areaPoints.Add( new ZedGraph.PointD( pointList.ScaledList[i].X, pointList.ScaledList[i].Y ) );
                                }

                            }

                            if( !rightPointIsAboveLine && !rightPointIsUpperBound )// close the current area and add it to the area list
                            {
                                double intersectX = ( dataB - integratePeaksLineB ) / ( integratePeaksLineA - dataA );
                                double intersectY = dataA * intersectX + dataB;

                                areaPoints.Add( new ZedGraph.PointD( intersectX, intersectY ) );

                                if( areaPoints.Count == 0 )
                                    continue;

                                ZedGraph.PolyObj integratePeaksArea = new ZedGraph.PolyObj( areaPoints.ToArray(), Color.Black, Color.Cyan, Color.Cyan );
                                integratePeaksArea.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale;
                                //integratePeaksArea.IsClosedFigure = true;
                                areaPoints.Add( areaPoints[0] );
                                integratePeaksAreas.Add( integratePeaksArea );
                                double currentIntegratedArea = 0.0;
                                for( int k, j = 0; j < areaPoints.Count; ++j )
                                {
                                    k = ( j + 1 ) % areaPoints.Count;
                                    currentIntegratedArea += areaPoints[j].X * areaPoints[k].Y;
                                    currentIntegratedArea -= areaPoints[j].Y * areaPoints[k].X;
                                }
                                totalIntegratedArea += Math.Abs( currentIntegratedArea / 2.0 );
                                totalAreaPoints += areaPoints.Count - 1;
                                ++totalAreaCount;
                                areaPoints.Clear();
                            }
                        }

                                /*if( areaPoints.Count > 2 )
                                {
                                    List<ZedGraph.PointD> areaTrapezoid = new List<ZedGraph.PointD>();
                                    areaTrapezoid.Add( areaPoints[areaPoints.Count - 3] ); // top left
                                    areaTrapezoid.Add( areaPoints[areaPoints.Count - 2] ); // top right
                                    areaTrapezoid.Add( areaPoints[areaPoints.Count - 1] ); // bottom right

                                    // bottom left
                                    double bottomLeftY = Math.Max( 0, integratePeaksLineA * areaPoints[areaPoints.Count - 3].X + integratePeaksLineB );
                                    areaTrapezoid.Add( new ZedGraph.PointD( areaPoints[areaPoints.Count - 3].X, bottomLeftY ) );

                                    areaTrapezoids.Add( areaTrapezoid );
                                }*/
                        /*foreach( List<ZedGraph.PointD> trapezoidPoints in areaTrapezoids )
                        {
                            ZedGraph.PolyObj trapezoid = new ZedGraph.PolyObj( trapezoidPoints.ToArray(), Color.Black, Color.Green, Color.Green );
                            trapezoid.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale;
                            trapezoid.IsClosedFigure = true;
                            integratePeaksAreas.Add( trapezoid );
                        }*/
                        foreach( ZedGraph.PolyObj obj in integratePeaksAreas )
                            CurrentGraphForm.ZedGraphControl.GraphPane.GraphObjList.Add( obj );
                        //CurrentGraphForm.ZedGraphControl.GraphPane.Title.Text = totalIntegratedArea.ToString("f0") + " " + totalAreaPoints + " " + totalAreaCount;
                        //CurrentGraphForm.ZedGraphControl.GraphPane.Title.IsVisible = true;
                        CurrentGraphForm.CurrentGraphItem.TotalIntegratedArea = totalIntegratedArea;
                        //int currentIndex = scanNumberComboBox.SelectedIndex;
                        //object currentObject = scanNumberComboBox.SelectedItem;
                        //scanNumberComboBox.Items.RemoveAt( currentIndex );
                        //scanNumberComboBox.Items.Insert( currentIndex, currentObject );
                    }
                }
                CurrentGraphForm.ZedGraphControl.Refresh();
                return false;
            }
            return true;
        }
Beispiel #33
0
        bool ZedGraphControl_MouseDownEvent( ZedGraph.ZedGraphControl sender, MouseEventArgs e )
        {
            if( CurrentGraphForm == null || !peakIntegrationMode.Checked || !CurrentGraphForm.ZedGraphControl.Focused )
                return false;

            if( e.Button == MouseButtons.Left )
            {
                if( integratePeaksLine != null )
                {
                    double distanceToMouseDownLocation = Math.Sqrt( Math.Pow( e.Location.X - integratePeaksMouseDownLocation.X, 2.0 ) +
                                                        Math.Pow( e.Location.Y - integratePeaksMouseDownLocation.Y, 2.0 ) );
                    if( distanceToMouseDownLocation < 5.0 )
                    {
                        ZedGraph.PointPair tmp = integratePeaksLine.Points[1].Clone();
                        integratePeaksLine.Points[1].X = integratePeaksLine.Points[0].X;
                        integratePeaksLine.Points[1].Y = integratePeaksLine.Points[0].Y;
                        integratePeaksLine.Points[0].X = tmp.X;
                        integratePeaksLine.Points[0].Y = tmp.Y;
                        Point tmp2 = integratePeaksMouseUpLocation;
                        integratePeaksMouseUpLocation = integratePeaksMouseDownLocation;
                        integratePeaksMouseDownLocation = tmp2;
                        return false;
                    } else
                    {
                        double distanceToMouseUpLocation = Math.Sqrt( Math.Pow( e.Location.X - integratePeaksMouseUpLocation.X, 2.0 ) +
                                                        Math.Pow( e.Location.Y - integratePeaksMouseUpLocation.Y, 2.0 ) );
                        if( distanceToMouseUpLocation >= 5.0 )
                        {
                            // clear existing line and start a new one
                            CurrentGraphForm.ZedGraphControl.GraphPane.CurveList.Remove( integratePeaksLine );
                            integratePeaksLine = null;
                            foreach( ZedGraph.PolyObj obj in integratePeaksAreas )
                                CurrentGraphForm.ZedGraphControl.GraphPane.GraphObjList.Remove( obj );
                            integratePeaksAreas.Clear();
                            CurrentGraphForm.ZedGraphControl.Refresh();
                        } else
                            return false;
                    }
                }

                integratePeaksMouseDownLocation = e.Location;
                double x = CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.ReverseTransform( (float) e.X );
                double y = CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.ReverseTransform( (float) e.Y );
                x = Math.Min( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Max, Math.Max( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Min, x ) );
                y = Math.Min( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Max, Math.Max( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Min, y ) );
                integratePeaksLine = new ZedGraph.LineItem( "", new double[] { x, x }, new double[] { y, y }, Color.Black, ZedGraph.SymbolType.None );
                integratePeaksLine.Line.IsAntiAlias = true;
                integratePeaksLine.Symbol.Type = ZedGraph.SymbolType.Square;
                integratePeaksLine.Symbol.IsVisible = true;
                integratePeaksLine.Symbol.Border.Width = 2;
                integratePeaksLine.Symbol.Border.Color = Color.Black;
                //integratePeaksLine.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale;
                CurrentGraphForm.ZedGraphControl.GraphPane.CurveList.Add( integratePeaksLine );
            }
            return false;
        }
 internal void ShowResultType2Mass(ZedGraph.PointPairList p, Dictionary<string, List<ResPointViewType2>> r)
 {
     this.listBox1.Items.Clear();
     this.r = r;
     foreach (string s in r.Keys)
     {
         this.listBox1.Items.Add(s);
     }
     //p.Sort(SortType.XValues);
     this.zgSolve1.GraphPane.AddCurve("divide", p, Color.Red, SymbolType.Circle);
     this.listBox1.SelectedIndex = 0;
     this.zgSolve1.AxisChange();
     this.zgSolve1.Refresh();
 }
Beispiel #35
0
    protected void ZedGraphWebExpStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
    {
        Color statColor = Color.Blue;
        string statTitle = string.Empty;
        string statXAxisTitle = string.Empty;
        switch (ListBoxViewContent.SelectedValue)
        {
            case "NpcBeKilled":
                statColor = Color.Orange;
                statTitle = StringDef.NpcBeKilledStatistic;
                statXAxisTitle = StringDef.NpcBeKilledCount;
                break;
            case "NpcKill":
                statColor = Color.Red;
                statTitle = StringDef.NpcKillPlayerStatistic;
                statXAxisTitle = StringDef.NpcKillPlayerCount;
                break;
        }

        GraphPane graphPane = masterPane[0];
        graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);
        graphPane.Title.Text = statTitle;
        graphPane.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.Title.FontSpec.Size = 10;
        graphPane.Legend.IsVisible = false;
        graphPane.BarSettings.Base = BarBase.Y;

        graphPane.XAxis.Title.Text = statXAxisTitle;
        graphPane.XAxis.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.XAxis.Title.FontSpec.Size = 6.2f;
        graphPane.XAxis.MajorGrid.IsVisible = true;
        graphPane.XAxis.MajorGrid.DashOff = 0;
        graphPane.XAxis.MajorGrid.Color = Color.Gray;
        graphPane.XAxis.MinorGrid.IsVisible = true;
        graphPane.XAxis.MinorGrid.Color = Color.LightGray;
        graphPane.XAxis.MinorGrid.DashOff = 0;
        graphPane.XAxis.Scale.FontSpec.Size = 5.6f;
        graphPane.XAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;

        //graphPane.YAxis.Title.Text = StringDef.NpcTemplate;
        graphPane.YAxis.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.YAxis.MajorTic.IsBetweenLabels = true;
        graphPane.YAxis.Scale.IsPreventLabelOverlap = false;
        graphPane.YAxis.Scale.AlignH = AlignH.Center;
        graphPane.YAxis.Scale.FontSpec.Size = 5.6f;
        graphPane.YAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.YAxis.Scale.IsReverse = true;
        graphPane.YAxis.Type = AxisType.Text;

        double[] countList = new double[_recordList.Count];
        string[] templateList = new string[_recordList.Count];
        for (int i = 0; i < _recordList.Count; i++)
        {
            NpcStatisticInfo info = _recordList[i];
            countList[i] = info.Count;
            FS2NpcData npcData = FS2GameDataManager.TheInstance.GetNpcData(int.Parse(info.TemaplteId));
            if (npcData != null)
            {
                templateList[i] = npcData.ToString();
            }
            else
            {
                templateList[i] = info.TemaplteId;
            }
        }
        BarItem barItem = graphPane.AddBar(StringDef.NpcBeKilledCount, countList, null, Color.Blue);
        barItem.Bar.Fill = new Fill(statColor);
        graphPane.YAxis.Scale.TextLabels = templateList;
        masterPane.AxisChange();
        BarItem.CreateBarLabels(graphPane, false, string.Empty, StringDef.DefaultFontFamily, 5.6f, TextObj.Default.FontColor, false, false, false);
    }
Beispiel #36
0
        private static void SetupGraph(ZedGraph.GraphPane g)
        {
            var color = Color.FromArgb(0xCC, 0xCC, 0xCC);

            #if SHOW_DERIVATION_2
            g.Legend.IsVisible = true;
            #else
            g.Legend.IsVisible = false;
            #endif
            g.XAxis.IsVisible = false;
            g.Legend.Border.IsVisible = false;

            g.Border.Color = color;
            g.Chart.Border.Color = color;

            g.XAxis.MajorGrid.IsVisible = true;
            g.YAxis.MajorGrid.IsVisible = true;
            g.YAxis.MinorGrid.IsVisible = true;

            g.Title.FontSpec.Size = 18.0f;
            g.Legend.FontSpec.Size = 18.0f;
            g.XAxis.Scale.FontSpec.Size = 18.0f;
            g.YAxis.Scale.FontSpec.Size = 18.0f;
            g.XAxis.Title.FontSpec.Size = 18.0f;
            g.YAxis.Title.FontSpec.Size = 18.0f;
        }
Beispiel #37
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="pane"></param>
 /// <param name="curve"></param>
 /// <param name="iPt"></param>
 /// <returns></returns>
 string zedGraphControl1_PointValueEvent(ZedGraph.ZedGraphControl sender, ZedGraph.GraphPane pane, ZedGraph.CurveItem curve, int iPt)
 {
     PointPair pt = curve[iPt];
     DateTime dt = XDate.XLDateToDateTime( pt.X);
     string s = string.Format("{0}\r\n{1}\r\n{2}", curve.Label.Text,
         dt, pt.Y.ToString("f2"));
     return s;
 }
Beispiel #38
0
        bool ZedGraphControl_MouseUpEvent( ZedGraph.ZedGraphControl sender, MouseEventArgs e )
        {
            if( CurrentGraphForm == null || !peakIntegrationMode.Checked || !CurrentGraphForm.ZedGraphControl.Focused )
                return false;

            int x0 = (int) Math.Round( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Transform( integratePeaksLine.Points[0].X ) );
            int y0 = (int) Math.Round( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Transform( integratePeaksLine.Points[0].Y ) );
            int x1 = (int) Math.Round( CurrentGraphForm.ZedGraphControl.GraphPane.XAxis.Scale.Transform( integratePeaksLine.Points[1].X ) );
            int y1 = (int) Math.Round( CurrentGraphForm.ZedGraphControl.GraphPane.YAxis.Scale.Transform( integratePeaksLine.Points[1].Y ) );
            integratePeaksMouseDownLocation.X = x0;
            integratePeaksMouseDownLocation.Y = y0;
            integratePeaksMouseUpLocation.X = x1;
            integratePeaksMouseUpLocation.Y = y1;
            return false;
        }