Пример #1
0
        public StockChartBasic(string symbol)
        {
            this.Symbol = symbol;
            DataTable emptyTable = new DataTable();

            emptyTable.Columns.Add("Time", typeof(DateTime));
            emptyTable.Columns.Add("Price", typeof(float));

            // Create the price line for the plot
            priceLine              = new LinePlot();
            priceLine.DataSource   = emptyTable;
            priceLine.AbscissaData = TIME_DATA_TAG;
            priceLine.OrdinateData = PRICE_DATA_TAG;
            priceLine.Color        = GuiStyle.PRICE_COLOR_POSITIVE;

            // Create the origin open price line
            openLine                 = new LinePlot();
            openLine.DataSource      = emptyTable;
            openLine.AbscissaData    = TIME_DATA_TAG;
            openLine.OrdinateData    = PRICE_DATA_TAG;
            openLine.Pen             = new System.Drawing.Pen(GuiStyle.GUIDE_COLOR);
            openLine.Pen.DashPattern = new float[] { 2.0f, 2.0f };
            openLine.Pen.DashCap     = System.Drawing.Drawing2D.DashCap.Round;
            openLine.Pen.Width       = 1.5f;

            // Create the surface used to draw the plot
            stockPricePlot = new NPlot.Swf.InteractivePlotSurface2D();
            stockPricePlot.SurfacePadding = 0;
            stockPricePlot.Add(priceLine);
            stockPricePlot.Add(openLine);
            stockPricePlot.SmoothingMode       = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            stockPricePlot.ShowCoordinates     = false;
            stockPricePlot.XAxis1.HideTickText = true;
            //stockPricePlot.XAxis1.NumberFormat = " h";
            stockPricePlot.XAxis1.AxisColor = System.Drawing.Color.Transparent;
            TradingDateTimeAxis tradeAxis = new TradingDateTimeAxis(stockPricePlot.XAxis1);

            tradeAxis.StartTradingTime           = new TimeSpan(9, 30, 0);
            tradeAxis.EndTradingTime             = new TimeSpan(16, 0, 0);
            stockPricePlot.XAxis1                = tradeAxis;
            stockPricePlot.YAxis1.HideTickText   = true;
            stockPricePlot.YAxis1.Color          = System.Drawing.Color.Transparent;
            stockPricePlot.PlotBackColor         = GuiStyle.BACKGROUND_COLOR;
            stockPricePlot.Canvas.HandleCreated += (sender, e) =>
            {
                stockPricePlot.Canvas.BackColor = stockPricePlot.Canvas.Parent.BackColor;
                //SetChartData(Source);
            };

            stockPricePlot.Refresh();
        }
Пример #2
0
        public DataChart(Dictionary <string, List <StockDataSet <T> > > dataSets, StockDataFile file, StockSession session)
        {
            this.DataSets = dataSets;
            this.File     = file;
            this.Session  = session;
            this.Start    = File.Start;
            this.End      = File.End;

            // Load the dummy data
            var dummySrc = DataSets.First().Value[0];

            dummySrc.Load(session);
            DataSets.First().Value[1].Load(session);    // Work-around so that the processing state is reset if this symbol is loaded again in the future
            DummyData = new StockDataSet <T>(dummySrc.Symbol, dummySrc.Start, dummySrc.File);
            DummyData.DataSet.Initialize(dummySrc.DataSet.InternalArray);

            // Create the surface used to draw the plot
            Plot = new NPlot.Swf.InteractivePlotSurface2D();
            Plot.SurfacePadding      = 0;
            Plot.SmoothingMode       = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Plot.ShowCoordinates     = false;
            Plot.XAxis1              = new Axis();
            Plot.YAxis1              = new Axis();
            Plot.XAxis1.HideTickText = true;
            //stockPricePlot.XAxis1.NumberFormat = " h";
            Plot.XAxis1.AxisColor      = System.Drawing.Color.Transparent;
            Plot.YAxis1.HideTickText   = true;
            Plot.YAxis1.Color          = System.Drawing.Color.Transparent;
            Plot.PlotBackColor         = GuiStyle.DARK_GREY;
            Plot.Canvas.HandleCreated += (sender, e) =>
            {
                Plot.Canvas.BackColor = Plot.Canvas.Parent.BackColor;
                //SetChartData(Source);
            };

            // Set the time axis as default
            this.XAxis                = "Time";
            this.XAxisGetValue        = getExpressionEvaluator(this.XAxis);
            this.TimeAxis             = new TradingDateTimeAxis(Plot.XAxis1);
            TimeAxis.StartTradingTime = new TimeSpan(9, 30, 0);
            TimeAxis.EndTradingTime   = new TimeSpan(16, 0, 0);
            TimeAxis.WorldMin         = (double)(file.Start).Ticks;
            TimeAxis.WorldMax         = (double)(file.End).Ticks;
            Plot.XAxis1               = TimeAxis;

            Plot.Refresh();
        }
Пример #3
0
        public PlotSample()
        {
            plotSurface = new NPlot.Swf.InteractivePlotSurface2D ();

            // Set defaults for the sample plotSurface
            plotSurface.AutoScaleAutoGeneratedAxes = false;
            plotSurface.AutoScaleTitle = false;
            plotSurface.Legend = null;
            plotSurface.ShowCoordinates = true;
            plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            plotSurface.Title = "";
            plotSurface.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            plotSurface.Canvas.Name = "plotCanvas";
            plotSurface.Canvas.BackColor = System.Drawing.SystemColors.Control;
            plotSurface.Canvas.Anchor =
                AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
        }
Пример #4
0
        public PlotSample()
        {
            plotSurface = new NPlot.Swf.InteractivePlotSurface2D();

            // Set defaults for the sample plotSurface
            plotSurface.AutoScaleAutoGeneratedAxes = false;
            plotSurface.AutoScaleTitle             = false;
            plotSurface.Legend           = null;
            plotSurface.ShowCoordinates  = true;
            plotSurface.SmoothingMode    = System.Drawing.Drawing2D.SmoothingMode.None;
            plotSurface.Title            = "";
            plotSurface.TitleFont        = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            plotSurface.Canvas.Name      = "plotCanvas";
            plotSurface.Canvas.BackColor = System.Drawing.SystemColors.Control;
            plotSurface.Canvas.Anchor    =
                AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
        }
Пример #5
0
        public DataChart(Dictionary <string, List <StockDataInterface> > dataSets, StockSession session)
        {
            this.DataSets = session.Data;
            this.Session  = session;
            this.Start    = session.SinkFile.Start;
            this.End      = session.SinkFile.End;

            // Create the surface used to draw the plot
            Plot = new NPlot.Swf.InteractivePlotSurface2D();
            Plot.SurfacePadding      = 0;
            Plot.SmoothingMode       = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Plot.ShowCoordinates     = false;
            Plot.XAxis1              = new Axis();
            Plot.YAxis1              = new Axis();
            Plot.XAxis1.HideTickText = true;
            //stockPricePlot.XAxis1.NumberFormat = " h";
            Plot.XAxis1.AxisColor      = System.Drawing.Color.Transparent;
            Plot.YAxis1.HideTickText   = true;
            Plot.YAxis1.Color          = System.Drawing.Color.Transparent;
            Plot.PlotBackColor         = GuiStyle.DARK_GREY;
            Plot.Canvas.HandleCreated += (sender, e) =>
            {
                Plot.Canvas.BackColor = Plot.Canvas.Parent.BackColor;
                //SetChartData(Source);
            };

            // Set the time axis as default
            this.XAxis                = "Time";
            this.XAxisGetValue        = getExpressionEvaluator(this.XAxis);
            this.TimeAxis             = new TradingDateTimeAxis(Plot.XAxis1);
            TimeAxis.StartTradingTime = new TimeSpan(9, 30, 0);
            TimeAxis.EndTradingTime   = new TimeSpan(16, 0, 0);
            TimeAxis.WorldMin         = (double)(Start).Ticks;
            TimeAxis.WorldMax         = (double)(End).Ticks;
            Plot.XAxis1               = TimeAxis;

            InitPlotColors();
            Plot.Refresh();
        }
Пример #6
0
        public StockChart()
        {
            DataTable emptyTable = new DataTable();

            emptyTable.Columns.Add("Time", typeof(DateTime));
            emptyTable.Columns.Add("Price", typeof(float));

            // Create the price line for the plot
            priceLine              = new LinePlot();
            priceLine.DataSource   = emptyTable;
            priceLine.AbscissaData = TIME_DATA_TAG;
            priceLine.OrdinateData = PRICE_DATA_TAG;
            priceLine.Color        = PRICE_COLOR_POSITIVE;

            // Create the origin open price line
            openLine                 = new LinePlot();
            openLine.DataSource      = emptyTable;
            openLine.AbscissaData    = TIME_DATA_TAG;
            openLine.OrdinateData    = PRICE_DATA_TAG;
            openLine.Pen             = new System.Drawing.Pen(GUIDE_COLOR);
            openLine.Pen.DashPattern = new float[] { 2.0f, 2.0f };
            openLine.Pen.DashCap     = System.Drawing.Drawing2D.DashCap.Round;
            openLine.Pen.Width       = 1.5f;

            // Create the surface used to draw the plot
            stockPricePlot = new NPlot.Swf.InteractivePlotSurface2D();
            stockPricePlot.Add(priceLine);
            stockPricePlot.Add(openLine);
            stockPricePlot.SmoothingMode             = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            stockPricePlot.ShowCoordinates           = false;
            stockPricePlot.XAxis1.TicksCrossAxis     = false;
            stockPricePlot.XAxis1.TickTextNextToAxis = true;
            stockPricePlot.XAxis1.SmallTickSize      = 0;
            stockPricePlot.XAxis1.LargeTickSize      = 0;
            stockPricePlot.XAxis1.HideTickText       = false;
            //stockPricePlot.XAxis1.NumberFormat = " h";
            stockPricePlot.XAxis1.TickTextColor   = openLine.Pen.Color;
            stockPricePlot.XAxis1.TickTextFont    = new System.Drawing.Font("monospace", 8.0f, System.Drawing.FontStyle.Bold);
            stockPricePlot.XAxis1.AxisColor       = System.Drawing.Color.Transparent;
            stockPricePlot.XAxis1.TicksLabelAngle = (float)0;
            TradingDateTimeAxis tradeAxis = new TradingDateTimeAxis(stockPricePlot.XAxis1);

            tradeAxis.StartTradingTime               = new TimeSpan(9, 30, 0);
            tradeAxis.EndTradingTime                 = new TimeSpan(16, 0, 0);
            stockPricePlot.XAxis1                    = tradeAxis;
            stockPricePlot.YAxis1.HideTickText       = false;
            stockPricePlot.YAxis1.Color              = System.Drawing.Color.Transparent;
            stockPricePlot.YAxis1.TickTextNextToAxis = true;
            stockPricePlot.YAxis1.TicksIndependentOfPhysicalExtent = true;
            stockPricePlot.YAxis1.TickTextColor = openLine.Pen.Color;
            stockPricePlot.PlotBackColor        = BACKGROUND_COLOR;
            stockPricePlot.SurfacePadding       = 5;

            // Create the interaction for the chart
            stockPricePlot.AddInteraction(new PlotDrag(true, false));
            stockPricePlot.AddInteraction(new AxisDrag());
            stockPricePlot.AddInteraction(new HoverInteraction(this));

            // Create the text controls
            priceText           = new Label();
            priceText.Location  = new System.Drawing.Point((stockPricePlot.Canvas.Width - 100) / 2, 10);
            priceText.Font      = new System.Drawing.Font("monoprice", 12.0f, System.Drawing.FontStyle.Regular);
            priceText.ForeColor = System.Drawing.Color.White;
            priceText.BackColor = System.Drawing.Color.Transparent;
            priceText.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            stockPricePlot.Canvas.Controls.Add(priceText);
            priceText.BringToFront();

            stockPricePlot.Refresh();
        }
Пример #7
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.closeButton = new System.Windows.Forms.Button();
            this.volumePS    = new NPlot.Swf.InteractivePlotSurface2D();
            this.costPS      = new NPlot.Swf.InteractivePlotSurface2D();
            this.SuspendLayout();
//
// closeButton
//
            this.closeButton.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.closeButton.Location = new System.Drawing.Point(8, 421);
            this.closeButton.Name     = "closeButton";
            this.closeButton.TabIndex = 1;
            this.closeButton.Text     = "Close";
            this.closeButton.Click   += new System.EventHandler(this.closeButton_Click);
//
// volumePS
//
            this.volumePS.AutoScaleAutoGeneratedAxes = false;
            this.volumePS.AutoScaleTitle             = false;
            this.volumePS.Canvas.BackColor           = System.Drawing.SystemColors.ControlLightLight;
            this.volumePS.Legend          = null;
            this.volumePS.Canvas.Location = new System.Drawing.Point(13, 305);
            this.volumePS.Canvas.Name     = "volumePS";
            // HWT this.volumePS.RightMenu = null;
            // HWT this.volumePS.ShowCoordinates = false;
            this.volumePS.Canvas.Size     = new System.Drawing.Size(606, 109);
            this.volumePS.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.None;
            this.volumePS.Canvas.TabIndex = 3;
            this.volumePS.Title           = "";
            this.volumePS.TitleFont       = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            this.volumePS.XAxis1          = null;
            this.volumePS.XAxis2          = null;
            this.volumePS.YAxis1          = null;
            this.volumePS.YAxis2          = null;
//
// costPS
//
            this.costPS.AutoScaleAutoGeneratedAxes = false;
            this.costPS.AutoScaleTitle             = false;
            this.costPS.Canvas.BackColor           = System.Drawing.SystemColors.ControlLightLight;
            this.costPS.Legend          = null;
            this.costPS.Canvas.Location = new System.Drawing.Point(13, 13);
            this.costPS.Canvas.Name     = "costPS";
            this.costPS.Canvas.Size     = new System.Drawing.Size(606, 285);
            this.costPS.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.None;
            this.costPS.Canvas.TabIndex = 2;
            this.costPS.Title           = "";
            this.costPS.TitleFont       = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            this.costPS.XAxis1          = null;
            this.costPS.XAxis2          = null;
            this.costPS.YAxis1          = null;
            this.costPS.YAxis2          = null;
//
// FinancialDemo
//
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize        = new System.Drawing.Size(631, 450);
            this.Controls.Add(this.volumePS.Canvas);
            this.Controls.Add(this.costPS.Canvas);
            this.Controls.Add(this.closeButton);
            this.Name = "FinancialDemo";
            this.Text = "BasicDemo";
            this.ResumeLayout(false);
        }
Пример #8
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.closeButton = new System.Windows.Forms.Button();
     this.volumePS = new NPlot.Swf.InteractivePlotSurface2D();
     this.costPS = new NPlot.Swf.InteractivePlotSurface2D();
     this.SuspendLayout();
     //
     // closeButton
     //
     this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.closeButton.Location = new System.Drawing.Point(8, 421);
     this.closeButton.Name = "closeButton";
     this.closeButton.TabIndex = 1;
     this.closeButton.Text = "Close";
     this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
     //
     // volumePS
     //
     this.volumePS.AutoScaleAutoGeneratedAxes = false;
     this.volumePS.AutoScaleTitle = false;
     this.volumePS.Canvas.BackColor = System.Drawing.SystemColors.ControlLightLight;
     this.volumePS.Legend = null;
     this.volumePS.Canvas.Location = new System.Drawing.Point(13, 305);
     this.volumePS.Canvas.Name = "volumePS";
     // HWT this.volumePS.RightMenu = null;
     // HWT this.volumePS.ShowCoordinates = false;
     this.volumePS.Canvas.Size = new System.Drawing.Size(606, 109);
     this.volumePS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
     this.volumePS.Canvas.TabIndex = 3;
     this.volumePS.Title = "";
     this.volumePS.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     this.volumePS.XAxis1 = null;
     this.volumePS.XAxis2 = null;
     this.volumePS.YAxis1 = null;
     this.volumePS.YAxis2 = null;
     //
     // costPS
     //
     this.costPS.AutoScaleAutoGeneratedAxes = false;
     this.costPS.AutoScaleTitle = false;
     this.costPS.Canvas.BackColor = System.Drawing.SystemColors.ControlLightLight;
     this.costPS.Legend = null;
     this.costPS.Canvas.Location = new System.Drawing.Point(13, 13);
     this.costPS.Canvas.Name = "costPS";
     this.costPS.Canvas.Size = new System.Drawing.Size(606, 285);
     this.costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
     this.costPS.Canvas.TabIndex = 2;
     this.costPS.Title = "";
     this.costPS.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     this.costPS.XAxis1 = null;
     this.costPS.XAxis2 = null;
     this.costPS.YAxis1 = null;
     this.costPS.YAxis2 = null;
     //
     // FinancialDemo
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize = new System.Drawing.Size(631, 450);
     this.Controls.Add(this.volumePS.Canvas);
     this.Controls.Add(this.costPS.Canvas);
     this.Controls.Add(this.closeButton);
     this.Name = "FinancialDemo";
     this.Text = "BasicDemo";
     this.ResumeLayout(false);
 }