当前位置: 首页>>代码示例>>C#>>正文


C# XDate.AddDays方法代码示例

本文整理汇总了C#中ZedGraph.XDate.AddDays方法的典型用法代码示例。如果您正苦于以下问题:C# XDate.AddDays方法的具体用法?C# XDate.AddDays怎么用?C# XDate.AddDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZedGraph.XDate的用法示例。


在下文中一共展示了XDate.AddDays方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CandleStickDemo

        public CandleStickDemo()
            : base("Demonstration of the Candlestick Chart Type",
									"CandleStick Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            myPane.Title.Text = "Candlestick Chart Demo";
            myPane.XAxis.Title.Text = "Trading Date";
            myPane.YAxis.Title.Text = "Share Price, $US";

            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;

            for ( int i = 0; i < 50; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );
                spl.Add( pt );

                open = close;
                // Advance one day
                xDate.AddDays( 1.0 );
                // but skip the weekends
                if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                    xDate.AddDays( 2.0 );
            }

            CandleStickItem myCurve = myPane.AddCandleStick( "trades", spl, Color.Black );
            myCurve.Stick.IsAutoSize = true;
            myCurve.Stick.Color = Color.Blue;

            // Use DateAsOrdinal to skip weekend gaps
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 );

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );

            base.ZedGraphControl.AxisChange();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:49,代码来源:CandleStickDemo.cs

示例2: CreateGraph_junk5

        public void CreateGraph_junk5( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Japanese Candlestick Chart Demo";
            myPane.XAxis.Title.Text = "Trading Date";
            myPane.YAxis.Title.Text = "Share Price, $US";

            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;

            for ( int i = 0; i < 1000; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );
                spl.Add( pt );

                open = close;
                if ( xDate.DateTime.Hour < 23 )
                    xDate.AddHours( 1.0 );
                else
                {
                    // Advance one day
                    xDate.AddHours( 1.0 );
                    // but skip the weekends
                    if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                        xDate.AddDays( 2.0 );
                }
            }

            JapaneseCandleStickItem myCurve = myPane.AddJapaneseCandleStick( "trades", spl );
            myCurve.Stick.IsAutoSize = true;
            myCurve.Stick.Color = Color.Blue;

            // Use DateAsOrdinal to skip weekend gaps
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 );
            myPane.XAxis.Scale.Format = "dd-MMM-yy hh:mm";

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );

            PointPairList ppl = new PointPairList();

            for ( int i = 19; i < spl.Count; i++ )
            {
                double avg = 0.0;
                for ( int j = 0; j < 20; j++ )
                    avg += spl.GetAt( i - j ).Close;
                ppl.Add( i + 1, avg / 20.0 );
            }
            LineItem item = myPane.AddCurve( "MA-20", ppl, Color.Red );
            item.IsOverrideOrdinal = true;
            item.Line.Width = 3;
            item.Symbol.Type = SymbolType.None;
            item.Line.IsSmooth = true;

            // Tell ZedGraph to calculate the axis ranges
            zgc.AxisChange();
            zgc.Invalidate();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:71,代码来源:Form1.cs

示例3: CreateGraph_StickToCurve

        private void CreateGraph_StickToCurve( ZedGraphControl z1 )
        {
            PointPairList listCurve = new PointPairList();
            PointPairList listPts = new PointPairList();

            Random rand = new Random();
            double val = 155.0;
            XDate date = new XDate( 2005, 7, 1 );

            for ( int iDay = 0; iDay < 60; iDay++ )
            {
                double dv = rand.NextDouble() * 3 - 1.5;
                listCurve.Add( date, val );
                listPts.Add( date, val + dv, val );

                val += rand.NextDouble() * 0.4 - 0.3;
                date.AddDays( 1 );
            }

            GraphPane myPane = z1.GraphPane;
            myPane.XAxis.Type = AxisType.Date;

            myPane.AddCurve( "val", listCurve, Color.Red, SymbolType.None );
            LineItem scatter = myPane.AddCurve( "pts", listPts, Color.Blue, SymbolType.Diamond );
            scatter.Line.IsVisible = false;
            scatter.Symbol.Fill = new Fill( Color.White );
            scatter.Symbol.Size = 5;

            ErrorBarItem myBar = myPane.AddErrorBar( "bars", listPts, Color.Green );
            myBar.Bar.Symbol.IsVisible = false;

            z1.AxisChange();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:33,代码来源:Form1.cs

示例4: CreateGraph_OHLCBarTest

        // OHLC Bar Test
        private void CreateGraph_OHLCBarTest( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            myPane.Title.Text = "OHLC Chart Demo";
            myPane.XAxis.Title.Text = "Trading Date";
            myPane.YAxis.Title.Text = "Share Price, $US";

            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;

            for ( int i = 0; i < 50; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );
                spl.Add( pt );

                open = close;
                // Advance one day
                //xDate.AddMinutes( 1.0 );
                xDate.AddDays( 1.0 );
                // but skip the weekends
                //if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                //	xDate.AddMinutes( 2.0 );
            }

            OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Blue);
            //myCurve.Bar.IsAutoSize = true;
            myCurve.Bar.Color = Color.Blue;

            // Use DateAsOrdinal to skip weekend gaps
            //myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.XAxis.Type = AxisType.Date;
            //myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 );

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );

            // Tell ZedGraph to calculate the axis ranges
            z1.AxisChange();
            z1.Invalidate();

            //z1.PointValueEvent += new ZedGraphControl.PointValueHandler( z1_PointValueEvent );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:54,代码来源:Form1.cs

示例5: CreateGraph_OHLCBar

        // Traditional Open-High-Low-Close Bar chart
        private void CreateGraph_OHLCBar( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            myPane.Title.Text = "OHLC Chart Demo";
            myPane.XAxis.Title.Text = "Trading Date";
            myPane.YAxis.Title.Text = "Share Price, $US";

            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is feb 1st
            XDate xDate = new XDate( 2006, 2, 1 );
            double open = 50.0;

            for ( int i = 0; i < 20; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );
                spl.Add( pt );

                open = close;
                // Advance one day
                xDate.AddDays( 1.0 );
                // but skip the weekends
                if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                    xDate.AddDays( 2.0 );
            }

            //OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Black );
            OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Blue );
            //myCurve.Bar.Size = 20;
            myCurve.Bar.IsAutoSize = true;
            //myCurve.Bar.PenWidth = 2;
            //myCurve.Bar.IsOpenCloseVisible = false;

            Fill fill = new Fill( Color.Red, Color.Yellow, Color.Blue );
            fill.RangeMin = 40;
            fill.RangeMax = 70;
            fill.Type = FillType.GradientByY;
            myCurve.Bar.GradientFill = fill;

            // Use DateAsOrdinal to skip weekend gaps
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            //myPane.XAxis.Type = AxisType.Date;
            //myPane.XAxis.Scale.MajorStep = 1.0;

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );

            //BoxObj box = new BoxObj( 4, 60, 5, 50000 );
            //myPane.GraphObjList.Add( box );

            // Tell ZedGraph to calculate the axis ranges
            z1.AxisChange();
            z1.Invalidate();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:63,代码来源:Form1.cs

示例6: CreateGraph_JapaneseCandleStickDemo

        // Call this method from the Form_Load method, passing your ZedGraphControl
        public void CreateGraph_JapaneseCandleStickDemo( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Japanese Candlestick Chart Demo";
            myPane.XAxis.Title.Text = "Trading Date";
            myPane.YAxis.Title.Text = "Share Price, $US";

            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;

            for ( int i = 0; i < 50; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );
                spl.Add( pt );

                open = close;
                // Advance one day
                //xDate.AddDays( 1 + 0.4 * rand.NextDouble() - 0.2 );
                xDate.AddDays( 1 );
                // but skip the weekends
                if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                    xDate.AddDays( 2.0 );
            }

            JapaneseCandleStickItem myCurve = myPane.AddJapaneseCandleStick( "trades", spl );
            myCurve.Stick.IsAutoSize = true;
            myCurve.Stick.Color = Color.Blue;

            // Use DateAsOrdinal to skip weekend gaps
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            //myPane.XAxis.Type = AxisType.Date;
            //myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 );

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );

            // Tell ZedGraph to calculate the axis ranges
            zgc.AxisChange();
            zgc.Invalidate();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:53,代码来源:Form1.cs

示例7: CreateGraph_SortedOverlayBars2

        public void CreateGraph_SortedOverlayBars2( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;
            const int count = 52;
            PointPairList ppl1 = new PointPairList();
            PointPairList ppl2 = new PointPairList();
            PointPairList ppl3 = new PointPairList();
            double val1 = 50.0;
            double val2 = 50.0;
            double val3 = 50.0;
            Random rand = new Random();
            XDate xDate = new XDate( 2005, 1, 1 );
            for ( int i = 0; i < count; i++ )
            {
                //double x = i + 1;
                val1 += rand.NextDouble() * 10.0 - 5.0;
                val2 += rand.NextDouble() * 10.0 - 5.0;
                val3 += rand.NextDouble() * 10.0 - 5.0;

                if ( i == 30 )
                    xDate.AddDays( 7 );

                //double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                //double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;
                ppl1.Add( xDate, val1 );
                ppl2.Add( xDate, val2 );
                ppl3.Add( xDate, val3 );

                xDate.AddDays( 7 );
            }
            // Generate a red bar with "Curve 1" in the legend
            CurveItem myCurve = myPane.AddBar( "Curve 1", ppl1, Color.Red );
            // Generate a blue bar with "Curve 2" in the legend
            myCurve = myPane.AddBar( "Curve 2", ppl2, Color.Blue );
            // Generate a green bar with "Curve 3" in the legend
            myCurve = myPane.AddBar( "Curve 3", ppl3, Color.Green );
            //myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.XAxis.Type = AxisType.Date;
            // Make the bars a sorted overlay type so that they are drawn on top of eachother
            // (without summing), and each stack is sorted so the shorter bars are in front
            // of the taller bars
            myPane.BarSettings.Type = BarType.SortedOverlay;
            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0F );
            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:47,代码来源:Form1.cs

示例8: CreateGraph_OHLCBarMaster

        // Make a masterpane with 3 charts
        // Top = OHLC Bar Chart
        // Mid = Volume Chart
        // Bot = Price Change
        public void CreateGraph_OHLCBarMaster( ZedGraphControl zgc )
        {
            // ================================================
            // First, set up some lists with random data...
            // ================================================
            StockPointList spl = new StockPointList();
            PointPairList volList = new PointPairList();
            PointPairList changeList = new PointPairList();

            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;
            double prevClose = 50.0;
            const int numDays = 365;

            // Loop to make 365 days of data
            for ( int i = 0; i < numDays; i++ )
            {
                double x = xDate.XLDate;
                //double close = open + rand.NextDouble() * 10.0 - 5.0;
                double close = open * ( 0.95 + rand.NextDouble() * 0.1 );
                //double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                //double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;
                double hi = Math.Max( open, close ) * ( 1.0 + rand.NextDouble() * 0.05 );
                double low = Math.Min( open, close ) * ( 0.95 + rand.NextDouble() * 0.05 );
                double vol = 25.0 + rand.NextDouble() * 100.0;
                double change = close - prevClose;

                // Create a StockPt instead of a PointPair so we can carry 6 properties
                StockPt pt = new StockPt( x, hi, low, open, close, vol );

                //if price is increasing color=black, else color=red
                pt.ColorValue = close > prevClose ? 2 : 1;
                spl.Add( pt );

                volList.Add( x, vol );
                changeList.Add( x, change );

                prevClose = close;
                open = close;
                // Advance one day
                xDate.AddDays( 1.0 );
                // but skip the weekends
                if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                    xDate.AddDays( 2.0 );
            }

            // ================================================
            // Create 3 GraphPanes to display the data
            // ================================================

            // get a reference to the masterpane
            MasterPane master = zgc.MasterPane;

            // The first chart is already in the MasterPane, so add the other two charts
            master.Add( new GraphPane() );
            master.Add( new GraphPane() );

            // ================================================
            // The first pane is an OHLCBarItem
            // ================================================

            // Get a reference to the pane
            GraphPane pane = master[0];

            // Set the title and axis labels
            pane.Title.Text = "Open-High-Low-Close History";
            pane.XAxis.Title.Text = "Date";
            pane.YAxis.Title.Text = "Price";

            // Setup the gradient fill...
            // Use Red for negative days and black for positive days
            Color[] colors = { Color.Red, Color.Black };
            Fill myFill = new Fill( colors );
            myFill.Type = FillType.GradientByColorValue;
            myFill.SecondaryValueGradientColor = Color.Empty;
            myFill.RangeMin = 1;
            myFill.RangeMax = 2;

            //Create the OHLC and assign it a Fill
            OHLCBarItem ohlcCurve = pane.AddOHLCBar( "Price", spl, Color.Empty );
            ohlcCurve.Bar.GradientFill = myFill;
            ohlcCurve.Bar.IsAutoSize = true;
            // Create a JapaneseCandleStick
            //JapaneseCandleStickItem jcsCurve = pane.AddJapaneseCandleStick( "Price", spl );
            //jcsCurve.Stick.IsAutoSize = false;

            // ================================================
            // The second pane is a regular BarItem to show daily volume
            // ================================================

            // Get a reference to the pane
            pane = master[1];

//.........这里部分代码省略.........
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:101,代码来源:Form1.cs

示例9: CreateGraph_OHLCBarGradient

        public void CreateGraph_OHLCBarGradient( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "OHLC Chart Demo";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "Price";

            //Load a StockPointList with random data.........................
            StockPointList spl = new StockPointList();
            Random rand = new Random();

            // First day is jan 1st
            XDate xDate = new XDate( 2006, 1, 1 );
            double open = 50.0;
            double prevClose = 0;

            // Loop to make 50 days of data
            for ( int i = 0; i < 50; i++ )
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0;
                double low = Math.Min( open, close ) - rand.NextDouble() * 5.0;

                // Create a StockPt instead of a PointPair so we can carry 6 properties
                StockPt pt = new StockPt( x, hi, low, open, close, 100000 );

                //if price is increasing color=black, else color=red
                pt.ColorValue = close > prevClose ? 2 : 1;
                spl.Add( pt );

                prevClose = close;
                open = close;
                // Advance one day
                xDate.AddDays( 1.0 );
                // but skip the weekends
                if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 )
                    xDate.AddDays( 2.0 );
            }

            // Setup the gradient fill...
            // Use Red for negative days and black for positive days
            Color[] colors = { Color.Red, Color.Black };
            Fill myFill = new Fill( colors );
            myFill.Type = FillType.GradientByColorValue;
            myFill.SecondaryValueGradientColor = Color.Empty;
            myFill.RangeMin = 1;
            myFill.RangeMax = 2;

            //Create the OHLC and assign it a Fill
            OHLCBarItem myCurve = myPane.AddOHLCBar( "Price", spl, Color.Empty );
            myCurve.Bar.GradientFill = myFill;
            myCurve.Bar.IsAutoSize = true;

            // Use DateAsOrdinal to skip weekend gaps
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            //myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 );

            // pretty it up a little
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f );
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );
            myPane.Title.FontSpec.Size = 20.0f;
            myPane.XAxis.Title.FontSpec.Size = 18.0f;
            myPane.XAxis.Scale.FontSpec.Size = 16.0f;
            myPane.YAxis.Title.FontSpec.Size = 18.0f;
            myPane.YAxis.Scale.FontSpec.Size = 16.0f;
            myPane.Legend.IsVisible = false;

            //			BoxObj box = new BoxObj( 4.5, 0.0, 1.0, 1.0, Color.Transparent,
            //					Color.FromArgb( 100, Color.LightBlue ) );
            //			box.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            //			myPane.GraphObjList.Add( box );

            // Tell ZedGraph to calculate the axis ranges
            zgc.AxisChange();
            zgc.Invalidate();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:79,代码来源:Form1.cs

示例10: CalcMinorTicValue

		/// <summary>
		/// Determine the value for any minor tic.
		/// </summary>
		/// <remarks>
		/// This method properly accounts for <see cref="Scale.IsLog"/>, <see cref="Scale.IsText"/>,
		/// and other axis format settings.
		/// </remarks>
		/// <param name="baseVal">
		/// The value of the first major tic (floating point double).  This tic value is the base
		/// reference for all tics (including minor ones).
		/// </param>
		/// <param name="iTic">
		/// The major tic number (0 = first major tic).  For log scales, this is the actual power of 10.
		/// </param>
		/// <returns>
		/// The specified minor tic value (floating point double).
		/// </returns>
		internal override double CalcMinorTicValue(double baseVal, int iTic)
		{
			XDate xDate = new XDate(baseVal);

			switch (_minorUnit) {
				case DateUnit.Year:
				default:
					xDate.AddYears((double) iTic*_minorStep);
					break;
				case DateUnit.Month:
					xDate.AddMonths((double) iTic*_minorStep);
					break;
				case DateUnit.Day:
					xDate.AddDays((double) iTic*_minorStep);
					break;
				case DateUnit.Hour:
					xDate.AddHours((double) iTic*_minorStep);
					break;
				case DateUnit.Minute:
					xDate.AddMinutes((double) iTic*_minorStep);
					break;
				case DateUnit.Second:
					xDate.AddSeconds((double) iTic*_minorStep);
					break;
			}

			return xDate.XLDate;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:45,代码来源:DateScale.cs

示例11: DrawStatistics

        /// <summary>
        /// Draws the statistics.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-08-28</remarks>
        public void DrawStatistics()
        {
            if (loading)
                return;

            # region set values and start time/date
            int values;
            XDate date = new XDate(DateTime.Now);
            TimeSpan offset = new TimeSpan(1, 0, 0, 0);
            AxisType axisType = AxisType.Text;

            switch ((TimeFrame)CBShow.SelectedIndex)
            {
                case TimeFrame.Today:
                    values = date.DateTime.Hour;
                    //date.DateTime = date.DateTime.AddHours(-date.DateTime.Hour);
                    //date.DateTime = date.DateTime.AddMinutes(-date.DateTime.Minute);
                    //date.DateTime = date.DateTime.AddSeconds(-date.DateTime.Second);
                    date.DateTime = date.DateTime.Date;
                    offset = new TimeSpan(1, 0, 0);
                    axisType = AxisType.Date;
                    break;
                case TimeFrame.Week:
                    values = 7;
                    date.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59).AddDays(-7);
                    break;
                case TimeFrame.Month:
                    values = 30;
                    date.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59).AddDays(-30);
                    break;
                case TimeFrame.Year:
                    values = 12;
                    date.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59).AddDays(-365);
                    offset = new TimeSpan(31, 0, 0, 0);
                    break;
                case TimeFrame.All:
                default:
                    values = (Dictionary.Statistics.GetNewestStatistic().EndTimestamp -
                        Dictionary.Statistics.GetOldestStatistic().EndTimestamp).Days + 1;
                    date.DateTime = Dictionary.Statistics.GetOldestStatistic().EndTimestamp;
                    break;
            }
            values++;
            # endregion
            # region initialize graphs

            //for performance
            int activeCards = Dictionary.Cards.ActiveCardsCount;

            GraphPane knowledgePane = zedGraphControlKnowledge.GraphPane;
            GraphPane distrubutionPane = zedGraphControlMemoryDistribution.GraphPane;
            GraphPane currentPane = zedGraphControlCurrentDistribution.GraphPane;

            knowledgePane.CurveList.Clear();
            distrubutionPane.CurveList.Clear();
            currentPane.CurveList.Clear();

            knowledgePane.Title.Text = Properties.Resources.STATISTICS_KNOWLEDGE_CAPTION;
            knowledgePane.XAxis.Title.Text = Properties.Resources.STATISTICS_XAXIS;
            knowledgePane.YAxis.Title.Text = Properties.Resources.STATISTICS_YAXIS;
            distrubutionPane.Title.Text = Properties.Resources.STATISTICS_DISTRIBUTION_CAPTION;
            distrubutionPane.XAxis.Title.Text = Properties.Resources.STATISTICS_XAXIS;
            distrubutionPane.YAxis.Title.Text = Properties.Resources.STATISTICS_YAXIS;
            currentPane.Title.Text = Properties.Resources.STATISTICS_OTHER;
            currentPane.Title.FontSpec.Size = 24;
            currentPane.Title.FontSpec.IsBold = true;

            knowledgePane.YAxis.Scale.Max = activeCards + 1;
            knowledgePane.YAxis.Scale.Min = 0;
            distrubutionPane.YAxis.Scale.Max = 10;
            //distrubutionPane.YAxis.Scale.MinorStep = 1;
            distrubutionPane.YAxis.Scale.Min = 0;

            if (((TimeFrame)CBShow.SelectedIndex) == TimeFrame.Today)
            {
                knowledgePane.XAxis.Scale.Min = (new XDate(date.DateTime + offset)).XLDate;
                knowledgePane.XAxis.Scale.Max = (new XDate(DateTime.Now + offset)).XLDate;
                distrubutionPane.XAxis.Scale.Min = (new XDate(date.DateTime + offset)).XLDate;
                distrubutionPane.XAxis.Scale.Max = (new XDate(DateTime.Now + offset)).XLDate;
            }
            else
            {
                knowledgePane.XAxis.Scale.Min = 2;
                knowledgePane.XAxis.Scale.Max = values + 2;
                distrubutionPane.XAxis.Scale.Min = 1;
                distrubutionPane.XAxis.Scale.Max = values + 1;
            }

            knowledgePane.XAxis.Type = axisType;

            distrubutionPane.XAxis.Type = axisType;
            distrubutionPane.BarSettings.Type = BarType.Stack;
            distrubutionPane.Legend.Position = LegendPos.Right;
            distrubutionPane.Legend.Gap = 0;

            currentPane.Legend.IsVisible = false;
//.........这里部分代码省略.........
开发者ID:hmehr,项目名称:OSS,代码行数:101,代码来源:Statistics.cs

示例12: CreateStockPointList

        private static StockPointList CreateStockPointList(long valueStepSizeMinutes)
        {
            StockPointList spl = new StockPointList();
            Random rand = new Random();

            XDate xDate = new XDate(2013, 1, 1);
            double open = 50.0;

            for (int i = 0; i < 50; i++)
            {
                double x = xDate.XLDate;
                double close = open + rand.NextDouble() * 10.0 - 5.0;
                double hi = Math.Max(open, close) + rand.NextDouble() * 5.0;
                double low = Math.Min(open, close) - rand.NextDouble() * 5.0;

                StockPt pt = new StockPt(x, hi, low, open, close, 100000);
                spl.Add(pt);

                open = close;
                xDate.AddMinutes(valueStepSizeMinutes);

                if (XDate.XLDateToDayOfWeek(xDate.XLDate) == 6)
                {
                    xDate.AddDays(2.0);
                }
            }

            return spl;
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:29,代码来源:OHLCBarItemTests.cs

示例13: CalcMinorTicValue

        /// <summary>
        /// Determine the value for any minor tic.
        /// </summary>
        /// <remarks>
        /// This method properly accounts for <see cref="IsLog"/>, <see cref="IsText"/>,
        /// and other axis format settings.
        /// </remarks>
        /// <param name="baseVal">
        /// The value of the first major tic (floating point double).  This tic value is the base
        /// reference for all tics (including minor ones).
        /// </param>
        /// <param name="iTic">
        /// The major tic number (0 = first major tic).  For log scales, this is the actual power of 10.
        /// </param>
        /// <returns>
        /// The specified minor tic value (floating point double).
        /// </returns>
        private double CalcMinorTicValue( double baseVal, int iTic )
        {
            double[] dLogVal = { 0, 0.301029995663981, 0.477121254719662, 0.602059991327962,
                                    0.698970004336019, 0.778151250383644, 0.845098040014257,
                                    0.903089986991944, 0.954242509439325, 1 };

            if ( this.IsDate ) // date scale
            {
                XDate xDate= new XDate( baseVal );

                switch ( this.minorUnit )
                {
                    case DateUnit.Year:
                    default:
                        xDate.AddYears( (double) iTic * this.minorStep );
                        break;
                    case DateUnit.Month:
                        xDate.AddMonths( (double) iTic * this.minorStep );
                        break;
                    case DateUnit.Day:
                        xDate.AddDays( (double) iTic * this.minorStep );
                        break;
                    case DateUnit.Hour:
                        xDate.AddHours( (double) iTic * this.minorStep );
                        break;
                    case DateUnit.Minute:
                        xDate.AddMinutes( (double) iTic * this.minorStep );
                        break;
                    case DateUnit.Second:
                        xDate.AddSeconds( (double) iTic * this.minorStep );
                        break;
                }

                return xDate.XLDate;
            }
            else if ( this.IsLog ) // log scale
            {
                return baseVal + Math.Floor( (double) iTic / 9.0 ) + dLogVal[ ( iTic + 9 ) % 9 ];
            }
            else // regular linear scale
            {
                return baseVal + (double) this.minorStep * (double) iTic;
            }
        }
开发者ID:InsungChoi,项目名称:dddd,代码行数:61,代码来源:Axis.cs

示例14: CalcMajorTicValue

        /// <summary>
        /// Determine the value for any major tic.
        /// </summary>
        /// <remarks>
        /// This method properly accounts for <see cref="IsLog"/>, <see cref="IsText"/>,
        /// and other axis format settings.
        /// </remarks>
        /// <param name="baseVal">
        /// The value of the first major tic (floating point double)
        /// </param>
        /// <param name="tic">
        /// The major tic number (0 = first major tic).  For log scales, this is the actual power of 10.
        /// </param>
        /// <returns>
        /// The specified major tic value (floating point double).
        /// </returns>
        private double CalcMajorTicValue( double baseVal, double tic )
        {
            if ( this.IsDate ) // date scale
            {
                XDate xDate = new XDate( baseVal );

                switch ( this.majorUnit )
                {
                    case DateUnit.Year:
                    default:
                        xDate.AddYears( tic * this.step );
                        break;
                    case DateUnit.Month:
                        xDate.AddMonths( tic * this.step );
                        break;
                    case DateUnit.Day:
                        xDate.AddDays( tic * this.step );
                        break;
                    case DateUnit.Hour:
                        xDate.AddHours( tic * this.step );
                        break;
                    case DateUnit.Minute:
                        xDate.AddMinutes( tic * this.step );
                        break;
                    case DateUnit.Second:
                        xDate.AddSeconds( tic * this.step );
                        break;
                }

                return xDate.XLDate;
            }
            else if ( this.IsLog ) // log scale
            {
                return baseVal + (double) tic;
            }
            else // regular linear scale
            {
                return baseVal + (double) this.step * tic;
            }
        }
开发者ID:InsungChoi,项目名称:dddd,代码行数:56,代码来源:Axis.cs


注:本文中的ZedGraph.XDate.AddDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。