Example #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            myPlot.Clear();           //清空
            Grid mygrid = new Grid(); //加入网格

            myPlot.Add(mygrid);

            int leng = 10;

            int[] p = new int[10] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            int[] X = new int[10] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            string[] strLabel = new string[leng];
            for (int i = 0; i < leng; i++)
            {
                strLabel[i] = Convert.ToString(p[i]) + " label";
            }

            LabelPointPlot labp = new LabelPointPlot();

            labp.AbscissaData      = X;
            labp.OrdinateData      = p;
            labp.TextData          = strLabel;
            labp.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            labp.Marker            = new Marker(Marker.MarkerType.Square, 8);
            labp.Marker.Color      = Color.Blue;
            myPlot.Add(labp);

            myPlot.Refresh();
        }
Example #2
0
        public void DrawLpp(string BS, int Price, int iTime)
        {
            NPlot.LabelPointPlot lpp = new LabelPointPlot()
            {
                DataSource   = new int[] { Price },
                AbscissaData = new int[] { iTime },
                TextData     = new string[] { BS }
            };


            lpp.Marker.Size = 10;
            if (BS == "B")
            {
                lpp.Marker.Color = System.Drawing.Color.Red;
                lpp.Marker.Type  = Marker.MarkerType.TriangleUp;
            }
            else
            {
                lpp.Marker.Color = System.Drawing.Color.Green;
                lpp.Marker.Type  = Marker.MarkerType.TriangleDown;
            }
            lpp.Marker.Filled = true;
            PS.Add(lpp);
        }
Example #3
0
        /// <summary>
        /// 利用雅虎接口获取日K线图
        /// </summary>
        /// <param name="stockNo"></param>
        /// <returns></returns>
        public static void GetStockMapDay(string stockNo, NPlot.Windows.PlotSurface2D myPlot)
        {
            DataTable dt = CommonFunction.GetStockHistoryInfo(stockNo);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (int.Parse(dt.Rows[i]["Volume"].ToString()) == 0)
                {
                    dt.Rows.RemoveAt(i);
                    i = 0;
                }
            }
            dt.DefaultView.Sort = " Date asc";
            dt = dt.DefaultView.ToTable();
            dt.Columns.Add("Date2", typeof(DateTime));
            foreach (DataRow dr in dt.Rows)
            {
                dr["Date2"] = DateTime.Parse(dr["Date"].ToString());
            }
            myPlot.Clear();
            List <double> listOpen  = new List <double>();
            List <double> listLow   = new List <double>();
            List <double> listHigh  = new List <double>();
            List <double> listClose = new List <double>();
            ArrayList     dates     = new ArrayList();
            ArrayList     closes    = new ArrayList();
            List <string> listText  = new List <string>();
            List <int>    listCount = new List <int>();
            int           n         = 0;

            foreach (DataRow dr in dt.Rows)
            {
                n++;
                listCount.Add(n);
                //if (n == 24) break;
                listOpen.Add(double.Parse(dr["Open"].ToString()));
                dates.Add(DateTime.Parse(dr["Date"].ToString()));
                listHigh.Add(double.Parse(dr["High"].ToString()));
                listLow.Add(double.Parse(dr["Low"].ToString()));
                listClose.Add(double.Parse(dr["Adj Close"].ToString()));
                closes.Add(double.Parse(dr["Adj Close"].ToString()));
                listText.Add(Math.Round(double.Parse(dr["Adj Close"].ToString()), 2, MidpointRounding.AwayFromZero).ToString());
            }
            ////////网格//////////
            Grid mygrid = new Grid();

            myPlot.Add(mygrid);
            ///////蜡烛图///////////
            CandlePlot cp = new CandlePlot();

            cp.DataSource   = dt;
            cp.AbscissaData = "Date2";
            cp.OpenData     = "Open";
            cp.LowData      = "Low";
            cp.HighData     = "High";
            cp.CloseData    = "Adj Close";
            cp.BullishColor = Color.Red;
            cp.BearishColor = Color.Green;
            cp.Centered     = false;
            //cp.StickWidth = 3;
            //cp.Color = Color.DarkBlue;
            myPlot.Add(cp);
            LabelPointPlot lp = new LabelPointPlot();

            lp.AbscissaData      = dates;
            lp.OrdinateData      = listHigh.ToArray();
            lp.TextData          = listText.ToArray();
            lp.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            lp.Marker            = new Marker(Marker.MarkerType.None, 10);
            myPlot.Add(lp);
            myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.MouseWheelZoom());
            myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true));
            myPlot.Title        = string.Format("Stcok {0}", stockNo);
            myPlot.XAxis1.Label = "Date / Time";
            myPlot.YAxis1.Label = "Price [$]";
            //myPlot.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.XAxisPosition.Bottom, 100));
            //////画箭头//////////
            //ArrowItem a = new ArrowItem(new PointD(2016, 10), 0, "Arrow");
            //a.HeadOffset = 0;
            //a.ArrowColor = Color.Red;
            //a.TextColor = Color.Purple;
            //myPlot.Add(a);


            myPlot.Refresh();
        }
Example #4
0
        public PlotQE()
        {
            infoText  = "";
            infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n";
            infoText += "  * LabelPointPlot (allows text to be associated with points) \n";
            infoText += "  * PointPlot droplines \n";
            infoText += "  * LabelAxis \n";
            infoText += "  * PhysicalSpacingMin property of LabelAxis \n";
            infoText += "You cannot interact with this chart";

            // This doesn't currently work, as the Timer is not in a Window
            qeExampleTimer          = new System.Windows.Forms.Timer();
            qeExampleTimer.Interval = 500;
            qeExampleTimer.Tick    += new EventHandler(qeExampleTimer_Tick);
            qeExampleTimerEnabled   = true;

            plotSurface.Clear();

            int len = 24;

            string[] s = new string[len];
            PlotQEExampleValues     = new double[len];
            PlotQEExampleTextValues = new string[len];

            Random r = new Random();

            for (int i = 0; i < len; i++)
            {
                PlotQEExampleValues[i] = 8.0f + 12.0f * (double)r.Next(10000) / 10000.0f;
                if (PlotQEExampleValues[i] > 18.0f)
                {
                    PlotQEExampleTextValues[i] = "KCsTe";
                }
                else
                {
                    PlotQEExampleTextValues[i] = "";
                }
                s[i] = i.ToString("00") + ".1";
            }

            PointPlot pp = new PointPlot();

            pp.DataSource      = PlotQEExampleValues;
            pp.Marker          = new Marker(Marker.MarkerType.Square, 10);
            pp.Marker.DropLine = true;
            pp.Marker.Pen      = Pens.CornflowerBlue;
            pp.Marker.Filled   = false;
            plotSurface.Add(pp);

            LabelPointPlot tp1 = new LabelPointPlot();

            tp1.DataSource        = PlotQEExampleValues;
            tp1.TextData          = PlotQEExampleTextValues;
            tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            tp1.Marker            = new Marker(Marker.MarkerType.None, 10);
            plotSurface.Add(tp1);

            LabelAxis la = new LabelAxis(plotSurface.XAxis1);

            for (int i = 0; i < len; ++i)
            {
                la.AddLabel(s[i], i);
            }
            FontFamily ff = new FontFamily("Verdana");

            la.TickTextFont       = new Font(ff, 7);
            la.PhysicalSpacingMin = 25;
            plotSurface.XAxis1    = la;

            plotSurface.Title               = "Cs2Te Photocathode QE evolution";
            plotSurface.TitleFont           = new Font(ff, 15);
            plotSurface.XAxis1.WorldMin     = -1.0f;
            plotSurface.XAxis1.WorldMax     = len;
            plotSurface.XAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.XAxis1.Label        = "Cathode ID";
            plotSurface.YAxis1.Label        = "QE [%]";
            plotSurface.YAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.YAxis1.TickTextFont = new Font(ff, 10);

            plotSurface.YAxis1.WorldMin = 0.0;
            plotSurface.YAxis1.WorldMax = 25.0;

            plotSurface.XAxis1.TicksLabelAngle = 60.0f;

            plotSurface.Refresh();
        }
Example #5
0
        public LabelPointPlotSample()
        {
            infoText  = "";
            infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n";
            infoText += "  * LabelPointPlot (allows text to be associated with points) \n";
            infoText += "  * PointPlot droplines \n";
            infoText += "  * LabelAxis \n";
            infoText += "  * PhysicalSpacingMin property of LabelAxis \n";

            qeExampleTimerEnabled = true;
            plotCanvas.Clear();

            int len = 24;

            string[] s = new string[len];
            PlotQEExampleValues     = new double[len];
            PlotQEExampleTextValues = new string[len];

            Random r = new Random();

            for (int i = 0; i < len; i++)
            {
                PlotQEExampleValues[i] = 8.0 + 12.0 * (double)r.Next(10000) / 10000.0;
                if (PlotQEExampleValues[i] > 18.0)
                {
                    PlotQEExampleTextValues[i] = "KCsTe";
                }
                else
                {
                    PlotQEExampleTextValues[i] = "";
                }
                s[i] = i.ToString("00") + ".1";
            }

            PointPlot pp = new PointPlot();

            pp.DataSource       = PlotQEExampleValues;
            pp.Marker           = new Marker(Marker.MarkerType.Square, 10);
            pp.Marker.DropLine  = true;
            pp.Marker.LineColor = Colors.CornflowerBlue;
            pp.Marker.Filled    = false;
            plotCanvas.Add(pp);

            LabelPointPlot tp1 = new LabelPointPlot();

            tp1.DataSource        = PlotQEExampleValues;
            tp1.TextData          = PlotQEExampleTextValues;
            tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            tp1.Marker            = new Marker(Marker.MarkerType.None, 10);
            plotCanvas.Add(tp1);

            LabelAxis la = new LabelAxis(plotCanvas.XAxis1);

            for (int i = 0; i < len; ++i)
            {
                la.AddLabel(s[i], i);
            }
            Font ff = Font.FromName("Verdana");

            la.TickTextFont       = ff.WithSize(7);
            la.PhysicalSpacingMin = 25;
            plotCanvas.XAxis1     = la;

            plotCanvas.Title               = "Cs2Te Photocathode QE evolution";
            plotCanvas.TitleFont           = ff.WithSize(15);
            plotCanvas.XAxis1.WorldMin     = -1.0;
            plotCanvas.XAxis1.WorldMax     = len;
            plotCanvas.XAxis1.LabelFont    = ff.WithSize(10);
            plotCanvas.XAxis1.Label        = "Cathode ID";
            plotCanvas.YAxis1.Label        = "QE [%]";
            plotCanvas.YAxis1.LabelFont    = ff.WithSize(10);
            plotCanvas.YAxis1.TickTextFont = ff.WithSize(10);

            plotCanvas.YAxis1.WorldMin      = 0.0;
            plotCanvas.YAxis1.WorldMax      = 25.0;
            plotCanvas.XAxis1.TickTextAngle = 60.0;

            // Add timer into Xwt loop for data updates
            Application.TimeoutInvoke(750, qeExampleTimer_Tick);

            PackStart(plotCanvas.Canvas, true);
            Label info = new Label(infoText);

            PackStart(info);
        }
Example #6
0
        public void CreatePlot(InteractivePlotSurface2D plotSurface)
        {
            this.plotSurface = plotSurface;

            this.Timer          = new System.Timers.Timer();
            this.Timer.Interval = 500;
            this.Timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
            this.Timer.Enabled  = true;
            plotSurface.Clear();

            int len = 24;

            string[] s = new string[len];
            PlotQEExampleValues     = new double[len];
            PlotQEExampleTextValues = new string[len];

            Random r = new Random();

            for (int i = 0; i < len; i++)
            {
                PlotQEExampleValues[i] = 8.0f + 12.0f * (double)r.Next(10000) / 10000.0f;
                if (PlotQEExampleValues[i] > 18.0f)
                {
                    PlotQEExampleTextValues[i] = "KCsTe";
                }
                else
                {
                    PlotQEExampleTextValues[i] = "";
                }
                s[i] = i.ToString("00") + ".1";
            }

            PointPlot pp = new PointPlot();

            pp.DataSource      = PlotQEExampleValues;
            pp.Marker          = new Marker(Marker.MarkerType.Square, 10);
            pp.Marker.DropLine = true;
            pp.Marker.Pen      = Pens.CornflowerBlue;
            pp.Marker.Filled   = false;
            plotSurface.Add(pp);

            LabelPointPlot tp1 = new LabelPointPlot();

            tp1.DataSource        = PlotQEExampleValues;
            tp1.TextData          = PlotQEExampleTextValues;
            tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            tp1.Marker            = new Marker(Marker.MarkerType.None, 10);
            plotSurface.Add(tp1);

            LabelAxis la = new LabelAxis(plotSurface.XAxis1);

            for (int i = 0; i < len; ++i)
            {
                la.AddLabel(s[i], i);
            }
            FontFamily ff = new FontFamily("Verdana");

            la.TickTextFont       = new Font(ff, 7);
            la.PhysicalSpacingMin = 25;
            plotSurface.XAxis1    = la;

            plotSurface.Title               = "Cs2Te Photocathode QE evolution";
            plotSurface.TitleFont           = new Font(ff, 15);
            plotSurface.XAxis1.WorldMin     = -1.0f;
            plotSurface.XAxis1.WorldMax     = len;
            plotSurface.XAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.XAxis1.Label        = "Cathode ID";
            plotSurface.YAxis1.Label        = "QE [%]";
            plotSurface.YAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.YAxis1.TickTextFont = new Font(ff, 10);

            plotSurface.YAxis1.WorldMin = 0.0;
            plotSurface.YAxis1.WorldMax = 25.0;

            plotSurface.XAxis1.TicksLabelAngle = 60.0f;

            plotSurface.Refresh();
        }