예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="width">The width of the plots.</param>
        /// <param name="height">The height of the plots.</param>
        public PlotRegressionTests(int width, int height)
        {
            this.plotSize = new Size(width, height);

            this.PlotSurface = new NPlot.PlotSurface2D();

            //this.PlotSurface.ClientSize = this.plotSize;
            this.PlotDemos = new PlotDemos(this.PlotSurface, () => new Random(RandomSeedForPlotDemos));

            string desktop = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "NPlot Regression Test Plots");

            folderForNewRegressionTestOutput = new DirectoryInfo(desktop);

            string folder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).LocalPath);
            string edf    = Path.Combine(folder, ExpectedDataFolderName);

            for (int i = 0; this.expectedDataFolder == null && i < 4; i++)
            {
                if (Directory.Exists(edf))
                {
                    this.expectedDataFolder = new DirectoryInfo(edf);
                }
                else
                {
                    edf = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(edf)), ExpectedDataFolderName);
                }
            }

            Assert.NotNull(this.expectedDataFolder, "Did not find expected data folder.");
        }
예제 #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            m_PlotSurface2D = new PlotSurface2D();

            m_PlotSurface2D.Clear();
            Example_NPlot_Tour.
#if WINDOWS_PHONE_7 || WINDOWS_PHONE_71
    PlotParticles
#else
            PlotDataSet    //PlotWave
#endif
                (m_PlotSurface2D);

            m_PlotSurface2D.TitleColor = plotSurface_Label_Default;

            m_PlotSurface2D.XAxis1.AxisColor     = plotSurface_AxisColor_Default;
            m_PlotSurface2D.XAxis1.TickTextColor = plotSurface_TickTextColor_Default;
            m_PlotSurface2D.XAxis1.LabelColor    = plotSurface_Label_Default;

            m_PlotSurface2D.YAxis1.AxisColor     = plotSurface_AxisColor_Default;
            m_PlotSurface2D.YAxis1.TickTextColor = plotSurface_TickTextColor_Default;
            m_PlotSurface2D.YAxis1.LabelColor    = plotSurface_Label_Default;

            m_NPlotBitmap = new NPlotBitmap(m_PlotSurface2D);
        }
예제 #3
0
        internal PlotSurface2D CreatePlot(PerfTestSuite suite, PerfTest test)
        {
            PlotSurface2D plot = new PlotSurface2D();

            plot.Title = String.Format("{0} - {1}", suite.Name, test.Name);
            // setting up plot
            plot.LegendBorderStyle = Legend.BorderType.Shadow;
            plot.ShowLegend = true;
            plot.PlotBackColor = Color.White;
            plot.VerticalEdgeLegendPlacement = Legend.Placement.Outside;

            return plot;
        }
예제 #4
0
 internal void AddLine(PlotSurface2D plot, double[] x, double[] y, string name)
 {
     ArrayAdapter data = new ArrayAdapter(x,y);
     Color c= NextColor();
     LinePlot line = new LinePlot(data);
     line.Label = name;
     Pen p = new Pen(c,2);
     line.Pen = p;
     plot.Add(line);
 }
예제 #5
0
    //========NPLOT===========
    void OnIvFtpBrowserItemActivated_NPlot(object o, ItemActivatedArgs args)
    {
        //TODO: Implement OnIvFtpBrowserItemActivated

        /* Get and parse file.
         * Populate appropriate classes.
         * --> LogFileEntries.
         * --> Graph Class
         * Plot graph and alarms.
         */

        NPlot.Gtk.PlotSurface2D graph = null;

        string selected_file = get_BrowserItem_Value (ivFtpBrowser);
        StreamReader file_reader = c_current_ftp_session.CFTP_GetFile (selected_file);

        Viewport _port = new Viewport (new Adjustment(1000, 500, 1000, 5, 0, 500),
            new Adjustment (500, 500, 500, 0, 0, 500));
        _port.WidthRequest = 2000;
        _port.ResizeMode = ResizeMode.Parent;

        c_current_logfile = new CLogFile
            (
                file_reader,
                c_current_ftp_session.CFTP_LogFileDate,
                c_current_device.DeviceFileDescription
            );

        c_current_graph = new CGraph (c_current_logfile.LogFileEntries);
        //c_current_graph.YAxisCodeIndex = c_current_logfile.CLogFile_Get_Y_Axis_Code_Index (c_current_device);
        c_current_graph.Title = selected_file;
        c_current_graph.YAxisCode = "CURTEMP";
        c_current_graph.YAxisLabel = "Current Temperature";
        c_current_graph.XAxisLabel = "Time Stamp";
        c_current_graph.CGRAPH_X_AxisData = c_current_logfile.LogFileTime;
        c_current_graph.CGRAPH_Y_AxisData = c_current_logfile.LogFileTemps;

        /**
         * Plot Graph
         */

        swGraph.Remove ((Widget)swGraph.Child);

        graph = new PlotSurface2D();
        graph.WidthRequest = 2000;
        graph.Allocation  = (new Gdk.Rectangle (0, 0, 2000, 500));

        c_current_graph.plot_nplot (out graph);

        swGraph.ReallocateRedraws = true;

        //swGraph.AddWithViewport (graph);
        _port.Add (graph);
        swGraph.ResizeMode = ResizeMode.Queue;
        swGraph.Add (_port);
        graph.QueueResize ();
        swGraph.QueueDraw ();
        swGraph.ShowAll ();

        /**
         * Fill Alarms Table
         */

        FillAlarmsTable (c_current_logfile.LogFileAlarms);

        file_reader.Close ();
        file_reader.Dispose ();

        nbFrames.CurrentPage = (int)nb_Notebook_Pages.GRAPH;
    }
예제 #6
0
 public NPlotBitmap(PlotSurface2D plotSurface2D)
 {
     m_PlotSurface2D = plotSurface2D;
 }
예제 #7
0
    public static void PlotDataSet(PlotSurface2D plotSurface)
    {
        plotSurface.Clear();
        //plotSurface.DateTimeToolTip = true;

        // obtain stock information from xml file
        DataSet ds = new DataSet();

        System.IO.Stream file = Alt.IO.VirtualFile.OpenRead("AltData/NPlot/asx_jbh.xml");
        ds.ReadXml(file, XmlReadMode.ReadSchema);
        DataTable dt = ds.Tables[0];
        //NoNeed	DataView dv = new DataView( dt );

        // create CandlePlot.
        CandlePlot cp = new CandlePlot();

        cp.DataSource   = dt;
        cp.AbscissaData = "Date";
        cp.OpenData     = "Open";
        cp.LowData      = "Low";
        cp.HighData     = "High";
        cp.CloseData    = "Close";
        cp.BearishColor = Alt.Sketch.Color.Red;
        cp.BullishColor = Alt.Sketch.Color.Green;
        cp.Style        = CandlePlot.Styles.Filled;

        // calculate 10 day moving average and 2*sd line
        ArrayList av10    = new ArrayList();
        ArrayList sd2_10  = new ArrayList();
        ArrayList sd_2_10 = new ArrayList();
        ArrayList dates   = new ArrayList();

        for (int i = 0; i < dt.Rows.Count - 10; ++i)
        {
            float sum = 0.0f;
            for (int j = 0; j < 10; ++j)
            {
                sum += (float)dt.Rows[i + j]["Close"];
            }
            float average = sum / 10.0f;
            av10.Add(average);
            sum = 0.0f;
            for (int j = 0; j < 10; ++j)
            {
                sum += ((float)dt.Rows[i + j]["Close"] - average) * ((float)dt.Rows[i + j]["Close"] - average);
            }
            sum /= 10.0f;
            sum  = 2.0f * (float)Math.Sqrt(sum);
            sd2_10.Add(average + sum);
            sd_2_10.Add(average - sum);
            dates.Add((DateTime)dt.Rows[i + 10]["Date"]);
        }

        // and a line plot of close values.
        LinePlot av = new LinePlot();

        av.OrdinateData = av10;
        av.AbscissaData = dates;
        av.Color        = Alt.Sketch.Color.LightGray;
        av.Pen.Width    = 2.0f;

        LinePlot top = new LinePlot();

        top.OrdinateData = sd2_10;
        top.AbscissaData = dates;
        top.Color        = Alt.Sketch.Color.LightSteelBlue;
        top.Pen.Width    = 2.0f;

        LinePlot bottom = new LinePlot();

        bottom.OrdinateData = sd_2_10;
        bottom.AbscissaData = dates;
        bottom.Color        = Alt.Sketch.Color.LightSteelBlue;
        bottom.Pen.Width    = 2.0f;

        FilledRegion fr = new FilledRegion(top, bottom);

        //fr.RectangleBrush = new RectangleBrushes.Vertical( Color.FloralWhite, Color.GhostWhite );
        fr.RectangleBrush         = new RectangleBrushes.Vertical(Alt.Sketch.Color.FromArgb(255, 255, 240), Alt.Sketch.Color.FromArgb(240, 255, 255));
        plotSurface.SmoothingMode = SmoothingMode.AntiAlias;

        plotSurface.Add(fr);

        plotSurface.Add(new Grid());

        plotSurface.Add(av);
        plotSurface.Add(top);
        plotSurface.Add(bottom);
        plotSurface.Add(cp);

        // now make an arrow...
        ArrowItem arrow = new ArrowItem(new PointD(((DateTime)dt.Rows[60]["Date"]).Ticks, 2.28), -80, "An interesting flat bit");

        arrow.ArrowColor     = Alt.Sketch.Color.DarkBlue;
        arrow.PhysicalLength = 50;

        //plotSurface.Add( arrow );

        plotSurface.Title            = "AU:JBH";
        plotSurface.XAxis1.Label     = "Date / Time";
        plotSurface.XAxis1.WorldMin += plotSurface.XAxis1.WorldLength / 4.0;
        plotSurface.XAxis1.WorldMax -= plotSurface.XAxis1.WorldLength / 2.0;
        plotSurface.YAxis1.Label     = "Price [$]";

        plotSurface.XAxis1 = new TradingDateTimeAxis(plotSurface.XAxis1);
    }