Exemple #1
0
        private void DrawPointPlot(DataTable dt)
        {
            #region 1.初始化 volumePS
            this.volumePS = new NPlot.Windows.PlotSurface2D();

            //
            // volumePS
            //
            this.volumePS.AutoScaleAutoGeneratedAxes = false;
            this.volumePS.AutoScaleTitle             = false;
            this.volumePS.BackColor       = System.Drawing.SystemColors.ControlLightLight;
            this.volumePS.DateTimeToolTip = false;
            this.volumePS.Legend          = null;
            this.volumePS.LegendZOrder    = -1;
            //this.volumePS.Location = new System.Drawing.Point(70, 636);
            this.volumePS.Dock            = DockStyle.Fill;
            this.volumePS.Name            = "volumePS";
            this.volumePS.RightMenu       = null;
            this.volumePS.ShowCoordinates = false;
            this.volumePS.Size            = new System.Drawing.Size(1053, 139);
            this.volumePS.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.None;
            this.volumePS.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;
            #endregion
            /*--============================================volumePS-PointPlot========================================================--*/
            #region 3.1 创建PointPlot【pp】.
            PointPlot pp = new PointPlot();
            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            #endregion

            #region 3.2 添加pp到volumePS
            volumePS.Clear();

            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured);
            volumePS.PreRefresh         += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh);
            #endregion
        }
Exemple #2
0
        private void DrawCandlePlot(DataTable dt)
        {
            #region 1.初始化costPS
            this.costPS = new NPlot.Windows.PlotSurface2D();

            this.costPS.AutoScaleAutoGeneratedAxes = false;
            this.costPS.AutoScaleTitle             = false;
            this.costPS.BackColor       = System.Drawing.SystemColors.ControlLightLight;
            this.costPS.DateTimeToolTip = false;
            this.costPS.Legend          = null;
            this.costPS.LegendZOrder    = -1;
            //this.costPS.Location = new System.Drawing.Point(70, 52);
            this.costPS.Dock            = DockStyle.Fill;
            this.costPS.Size            = new System.Drawing.Size(1053, 557);
            this.costPS.Name            = "costPS";
            this.costPS.RightMenu       = null;
            this.costPS.ShowCoordinates = false;

            this.costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            this.costPS.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;
            #endregion
            /*--===========================================costPS-CandlePlot=========================================================--*/
            #region 2.1 创建 CandlePlot【cp】.
            CandlePlot cp = new CandlePlot();
            cp.DataSource   = dt;
            cp.AbscissaData = "Date";
            cp.OpenData     = "Open";
            cp.LowData      = "Low";
            cp.HighData     = "High";
            cp.CloseData    = "Close";

            cp.BearishColor = Color.White; //方框颜色
            cp.BullishColor = Color.Green; //方框颜色

            cp.Style = CandlePlot.Styles.Filled;
            #endregion

            #region 2.2 添加cp到costPS
            costPS.Clear();
            costPS.DateTimeToolTip = true;

            costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            costPS.Add(new Grid());
            costPS.Add(cp);
            // costPS.Title = "AU:JBH";//标题
            // costPS.YAxis1.Label = "Price [$]"; //左侧标题
            costPS.YAxis1.LabelOffset         = 40;
            costPS.YAxis1.LabelOffsetAbsolute = true;
            costPS.XAxis1.HideTickText        = true;

            costPS.YAxis1.HideTickText = true;//是否隐藏垂直刻度线标尺

            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            costPS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(costPS_InteractionOccured);
            costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));

            this.costPS.RightMenu = new ReducedContextMenu();
            #endregion
        }
        public FinancialDemo()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            costPS.Clear();
            costPS.DateTimeToolTip = true;

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

            System.IO.Stream file =
                Assembly.GetExecutingAssembly().GetManifestResourceStream("NPlotDemo.resources.asx_jbh.xml");
            ds.ReadXml(file, System.Data.XmlReadMode.ReadSchema);
            DataTable dt = ds.Tables[0];
            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      = Color.Red;
            cp.BullishColor      = Color.Green;
            cp.Style             = CandlePlot.Styles.Filled;
            costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            costPS.Add(new Grid());
            costPS.Add(cp);
            costPS.Title                      = "AU:JBH";
            costPS.YAxis1.Label               = "Price [$]";
            costPS.YAxis1.LabelOffset         = 40;
            costPS.YAxis1.LabelOffsetAbsolute = true;
            costPS.XAxis1.HideTickText        = true;
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            costPS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(costPS_InteractionOccured);
            costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));

            PointPlot pp = new PointPlot();

            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured);
            volumePS.PreRefresh         += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh);

            this.costPS.RightMenu = new ReducedContextMenu();
        }