Encapsulates functionality for drawing a vertical line on a plot surface.
상속: IPlot
예제 #1
0
파일: PlotCandle.cs 프로젝트: sanyu1/NPlot
        public PlotCandle()
        {
            infoText = "";
            infoText += "Simple CandlePlot example. Demonstrates - \n";
            infoText += " * Setting candle plot datapoints using arrays \n";
            infoText += " * Plot Zoom interaction using MouseWheel ";

            plotSurface.Clear();

            FilledRegion fr = new FilledRegion(
                new VerticalLine(1.2),
                new VerticalLine(2.4));
            fr.Brush = Brushes.BlanchedAlmond;
            plotSurface.Add(fr);

            // note that arrays can be of any type you like.
            int[] opens =  { 1, 2, 1, 2, 1, 3 };
            double[] closes = { 2, 2, 2, 1, 2, 1 };
            float[] lows =	 { 0, 1, 1, 1, 0, 0 };
            System.Int64[] highs =	{ 3, 2, 3, 3, 3, 4 };
            int[] times =  { 0, 1, 2, 3, 4, 5 };

            CandlePlot cp = new CandlePlot();
            cp.CloseData = closes;
            cp.OpenData = opens;
            cp.LowData = lows;
            cp.HighData = highs;
            cp.AbscissaData = times;
            plotSurface.Add(cp);

            HorizontalLine line = new HorizontalLine( 1.2 );
            line.LengthScale = 0.89f;
            plotSurface.Add( line, -10 );

            VerticalLine line2 = new VerticalLine( 1.2 );
            line2.LengthScale = 0.89f;
            plotSurface.Add( line2 );

            plotSurface.AddInteraction (new PlotZoom());

            plotSurface.Title = "Line in the Title Number 1\nFollowed by another title line\n and another";
            plotSurface.Refresh();
        }
예제 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="l1">Vertical line to provide bounds for filled region</param>
 /// <param name="l2">The other Vertical line to provide bounds for filled region</param>
 public FilledRegion(VerticalLine l1, VerticalLine l2)
 {
     vl1_ = l1;
     vl2_ = l2;
 }
        private List<VerticalLine> GetVerticalLines(List<int> happenTimes, int duration)
        {
            if (happenTimes == null || happenTimes.Count == 0) return null;

            List<VerticalLine> vlines = new List<VerticalLine>();
            int starttime = happenTimes[0];
            foreach (int time in happenTimes)
            {
                if (time == starttime 
                    || ((time - starttime) > (duration * 1000)))
                {
                    VerticalLine vl = new VerticalLine((time - this.mFaultInfo.PHYHeader.GPSStartTime) / 1000, Color.Red);
                    vl.Pen.Width = 2;
                    vlines.Add(vl);
                    starttime = time;
                }
            }
            return vlines;
        }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="l1">Vertical line to provide bounds for filled region</param>
 /// <param name="l2">The other Vertical line to provide bounds for filled region</param>
 public FilledRegion(VerticalLine l1, VerticalLine l2)
 {
     vl1_ = l1;
     vl2_ = l2;
 }
예제 #5
0
파일: GrafForm.cs 프로젝트: sevo/Calc
        private void DrawGraf()
        {
            lock (typeof(GrafForm))
            {
                string[] lines = {
                "Circular Example. Demonstrates - ",
                "  * PiAxis, Horizontal and Vertical Lines.",
                "  * Placement of legend" };

                this.GrafSurface2D.Clear();
                GrafSurface2D.Add(new HorizontalLine(0.0, Color.LightGray));
                GrafSurface2D.Add(new VerticalLine(0.0, Color.LightGray));

                double start = (double)XMinNumericUpDown.Value;
                double end = (double)XMaxNumericUpDown.Value;
                Random random = new Random();
                double[] xs = new double[N+1];

                double x = start;
                for (int i = 0; i < N+1; i++)
                {

                    xs[i] = x;
                    x += ((end - start) / (N));//mozno tu treba N+1
                }
                functionsMutex.WaitOne();
                for (int i = 0; i < functions.Count; i++)
                {
                    if (checkedListBox.GetItemChecked(i))
                    {
                        LinePlot lp = new LinePlot(((Function)functions[i]).data, xs);
                        lp.Pen = new Pen(Color.FromArgb(((Function)functions[i]).colorR, ((Function)functions[i]).colorG, ((Function)functions[i]).colorB), 2.0f);
                        lp.Label = ((Function)functions[i]).label; // no legend, but still useful for copy data to clipboard.
                        GrafSurface2D.Add(lp);
                    }
                }
                functionsMutex.ReleaseMutex();

                VerticalLine line = new VerticalLine((double)XnumericUpDown.Value, new Pen(Color.Black, 2.0f));
                GrafSurface2D.Add(line);

                //GrafSurface2D.XAxis1 = new PiAxis(GrafSurface2D.XAxis1);
                GrafSurface2D.XAxis1 = new LinearAxis(GrafSurface2D.XAxis1);

                GrafSurface2D.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                GrafSurface2D.Legend = new Legend();
                GrafSurface2D.Legend.AttachTo(PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Right);
                GrafSurface2D.Legend.HorizontalEdgePlacement = Legend.Placement.Inside;
                GrafSurface2D.Legend.VerticalEdgePlacement = Legend.Placement.Inside;
                GrafSurface2D.Legend.XOffset = -10;
                GrafSurface2D.Legend.YOffset = -10;
                GrafSurface2D.Legend.NeverShiftAxes = true;

                GrafSurface2D.Inner.XAxis1.WorldMax = (double)XMaxNumericUpDown.Value;
                GrafSurface2D.Inner.XAxis1.WorldMin = (double)XMinNumericUpDown.Value;
                GrafSurface2D.Inner.YAxis1.WorldMax = (double)YMaxNumericUpDown.Value;
                GrafSurface2D.Inner.YAxis1.WorldMin = (double)YMinNumericUpDown.Value;

                GrafSurface2D.Refresh();
               }
        }