• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ZedGraph.XDate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XDate类属于ZedGraph命名空间,在下文中一共展示了XDate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UpdateGraph

        public void UpdateGraph(XDate xValue, double roll, double pitch, double yaw)
        {
            this.imu_Roll_List.Add(xValue, roll);
             this.imu_Pitch_List.Add(xValue, pitch);
             this.imu_Yaw_List.Add(xValue, yaw);

            zedGraphControl1.Invalidate();
            zedGraphControl1.AxisChange();
        }
开发者ID:jnzim,项目名称:dev-repo,代码行数:9,代码来源:frmPlotChart.cs


示例2: 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


示例3: FilledCurveDemo

        public FilledCurveDemo()
            : base("A Line Graph with the Area Under the Curves Filled",
			"Filled Curve Demo", DemoType.General, DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "My Test Date Graph";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points from the Sine function
            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            for ( int i=0; i<36; i++ )
            {
                double x = new XDate( 1995, i+1, 1 );
                double y = Math.Sin( (double) i * Math.PI / 15.0 );
                double y2 = 2 * y;

                list.Add( x, y );
                list2.Add( x, y2 );
            }

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve2 = myPane.AddCurve( "My Curve 2", list, Color.Blue,
                                    SymbolType.Circle );
            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill( Color.White, Color.Red, 45F );
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill( Color.White );

            // Generate a red curve with diamond symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve( "My Curve",
                list2, Color.MediumVioletRed, SymbolType.Diamond );
            // Fill the area under the curve with a white-green gradient
            myCurve.Line.Fill = new Fill( Color.White, Color.Green );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Set the XAxis to date type
            myPane.XAxis.Type = AxisType.Date;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F );

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


示例4: GetPointList

 /// <summary>
 /// 
 /// </summary>
 /// <param name="tbl"></param>
 /// <param name="cc"></param>
 /// <returns></returns>
 private IPointList GetPointList(DataTable tbl, GRDataCurveConfig cc)
 {
     PointPairList list = new PointPairList();
     foreach (DataRow row in tbl.Rows)
     {
         DateTime dt = Convert.ToDateTime(row["DT"]);
         float value = Convert.ToSingle(row[cc.GRDataEnum.ToString()]);
         XDate xdt = new XDate(dt);
         list.Add(new PointPair(xdt, value));
     }
     return list;
 }
开发者ID:hkiaipc,项目名称:fnq,代码行数:18,代码来源:frmContrastCurve.cs


示例5: PopulateByDataSource


//.........这里部分代码省略.........

                    //Add points
                    PointPairList points = new PointPairList();
                    PointPair pair = new PointPair();
                    object oColumnValue;

                    try
                    {
                        int nRow = 0;
                        foreach ( object row in list )
                        {
                            //
                            // Value axis binding (Y axis)
                            //
                            object valueRow = valueList[nRow];

                            //Get item value in 'row'
                            if ( bValueListContainsList )
                            {
                                if ( !( valueRow is IList ) )
                                    throw new System.InvalidCastException( "The DataSource contains a list which declares its items as lists, but these don't support the IList interface." );
                                oColumnValue = ( valueRow as IList )[indexValueColumn];
                            }
                            else
                            {
                                oColumnValue = pd.GetValue( valueRow );
                            }

                            //Convert value to double (always double)
                            double v = 0;
                            switch ( oColumnValue.GetType().ToString() )
                            {
                                case "System.DateTime":
                                    v = new XDate( Convert.ToDateTime( oColumnValue ) ).XLDate;
                                    break;
                                default:
                                    try
                                    {
                                        v = Convert.ToDouble( oColumnValue );
                                    }
                                    catch
                                    {
                                        throw new NotImplementedException( "Conversion from " + oColumnValue.GetType() + " to double not implemented." );
                                    }
                                    break;
                            }

                            //
                            // Base axis binding (X axis)
                            //
                            pair.Tag = oColumnValue; //Original typed value
                            pair.Y = v;
                            if ( this.XAxis.Type == AxisType.DateAsOrdinal
                                || this.XAxis.Type == AxisType.Date )
                            {
                                pair.X = new XDate( Convert.ToDateTime( basePd.GetValue( row ) ) ).XLDate;
                            }
                            else
                                pair.X = Convert.ToDouble( basePd.GetValue( row ) );

                            points.Add( pair );

                            nRow++;
                        }
                    }
                    catch ( System.ArgumentOutOfRangeException )
开发者ID:JohnChantzis,项目名称:bark_GUI,代码行数:67,代码来源:ZedGraphWeb.cs


示例6: WidenDatesIfNeeded

 private void WidenDatesIfNeeded(XDate fDate, XDate lDate)
 {
     if (fDate.DateTime < _firstDate) _firstDate = fDate.DateTime;
     if (lDate.DateTime > _lastDate) _lastDate = lDate.DateTime;
 }
开发者ID:intille,项目名称:mitessoftware,代码行数:5,代码来源:Form1.cs


示例7: buttonZoomOut_Click

        private void buttonZoomOut_Click(object sender, EventArgs e)
        {
            XDate startx = new XDate(_firstDate.Year, _firstDate.Month, _firstDate.Day, _firstDate.Hour, _firstDate.Minute, _firstDate.Second);

            XDate endx = new XDate(_lastDate.Year, _lastDate.Month, _lastDate.Day, _lastDate.Hour, _lastDate.Minute, _lastDate.Second);
            for (int i = 0; i < zedGraphControl1.MasterPane.PaneList.Count; i++)
            {
                zedGraphControl1.MasterPane[i].XAxis.Scale.Min = (double)startx;
                zedGraphControl1.MasterPane[i].XAxis.Scale.Max = (double)endx;
            }
            lbScrollTime.Text = "VIEWING ALL";

            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();

            if (_isAdaptingPointSize) SetPointSize(); 
        }
开发者ID:intille,项目名称:mitessoftware,代码行数:17,代码来源:Form1.cs


示例8: UpdateGraph

        public void UpdateGraph()
        {
            try
            {
                try
                {
                    DateTime startTime = DateTime.Now;

                    // Take a copy of the metrics file.
                    if (File.Exists(m_metricsFileCopyName))
                    {
                        File.Delete(m_metricsFileCopyName);
                    }

                    logger.Debug("Copying " + m_metricsFileName + " to " + m_metricsFileCopyName);
                    File.Copy(m_metricsFileName, m_metricsFileCopyName);

                    StreamReader metricsReader = new StreamReader(m_metricsFileCopyName);
                    m_totalSIPPacketsList.Clear();
                    m_sipRequestsInList.Clear();
                    m_sipResponsesInList.Clear();
                    m_sipRequestsOutList.Clear();
                    m_sipResponsesOutList.Clear();
                    m_pendingTransactionsList.Clear();
                    m_discardsList.Clear();
                    m_unrecognisedList.Clear();
                    m_tooLargeList.Clear();
                    m_badSIPList.Clear();
                    m_stunList.Clear();
                    m_totalParseTimeList.Clear();
                    m_avgParseTimeList.Clear();
                    m_sipMethodsLists = new Dictionary<SIPMethodsEnum, RollingPointPairList>();
                    m_topTalkersLists.Clear();
                    m_topTalkersCount.Clear();

                    string metricsLine = metricsReader.ReadLine();
                    int sampleCount = 0;
                    while (metricsLine != null)
                    {
                        #region Process metrics line.

                        if (metricsLine.Trim().Length != 0 && Regex.Match(metricsLine, ",").Success)
                        {
                            string[] fields = metricsLine.Split(',');
                            XDate sampleDate = new XDate(DateTime.Parse(fields[1]));
                            int samplePeriod = Convert.ToInt32(fields[2]);              // Sample period in seconds.
                            if (samplePeriod == 0)
                            {
                                throw new ApplicationException("The sample period for a measurement was 0 in SIPTransportMetricsGraphAgent.");
                            }

                            if (metricsLine.StartsWith(m_trafficMetrics))
                            {
                                try
                                {
                                    m_totalSIPPacketsList.Add(sampleDate, Convert.ToDouble(fields[3]) / samplePeriod);
                                    m_sipRequestsInList.Add(sampleDate, Convert.ToDouble(fields[4]) / samplePeriod);
                                    m_sipResponsesInList.Add(sampleDate, Convert.ToDouble(fields[5]) / samplePeriod);
                                    m_sipRequestsOutList.Add(sampleDate, Convert.ToDouble(fields[6]) / samplePeriod);
                                    m_sipResponsesOutList.Add(sampleDate, Convert.ToDouble(fields[7]) / samplePeriod);
                                    m_pendingTransactionsList.Add(sampleDate, Convert.ToDouble(fields[8]));
                                    m_unrecognisedList.Add(sampleDate, Convert.ToDouble(fields[9]) / samplePeriod);
                                    m_badSIPList.Add(sampleDate, Convert.ToDouble(fields[10]) / samplePeriod);
                                    m_stunList.Add(sampleDate, Convert.ToDouble(fields[11]) / samplePeriod);
                                    m_discardsList.Add(sampleDate, Convert.ToDouble(fields[12]) / samplePeriod);
                                    m_tooLargeList.Add(sampleDate, Convert.ToDouble(fields[13]) / samplePeriod);
                                    m_totalParseTimeList.Add(sampleDate, Convert.ToDouble(fields[14]) / samplePeriod);
                                    m_avgParseTimeList.Add(sampleDate, Convert.ToDouble(fields[15]));
                                    sampleCount++;
                                }
                                catch (Exception sampleExcp)
                                {
                                    logger.Warn("Could not process metrics sample: " + metricsLine + ". " + sampleExcp.Message);
                                }
                            }
                            else if (metricsLine.StartsWith(m_methodMetrics))
                            {
                                for (int index = 3; index < fields.Length; index++)
                                {
                                    string[] methodSplit = fields[index].Split('=');
                                    SIPMethodsEnum method = SIPMethods.GetMethod(methodSplit[0]);
                                    int methodPackets = Convert.ToInt32(methodSplit[1]) / samplePeriod;

                                    if(!m_sipMethodsLists.ContainsKey(method))
                                    {
                                        m_sipMethodsLists.Add(method, new RollingPointPairList(GRAPH_SAMPLES));
                                    }

                                    m_sipMethodsLists[method].Add(sampleDate, methodPackets);
                                }
                            }
                            else if (metricsLine.StartsWith(m_topTalkerMetrics))
                            {
                                for (int index = 3; index < fields.Length; index++)
                                {
                                    string[] talkersSplit = fields[index].Split('=');
                                    string topTalkerSocket = talkersSplit[0];
                                    int topTalkerPackets = Convert.ToInt32(talkersSplit[1]) / samplePeriod;

                                    if (!m_topTalkersLists.ContainsKey(topTalkerSocket))
//.........这里部分代码省略.........
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:101,代码来源:SIPTransportMetricsGraphAgent.cs


示例9: 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


示例10: CreateGraph_DateAsOrdinal

        // Basic curve test - Line Graph with DateAsOrdinal
        private void CreateGraph_DateAsOrdinal( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            PointPairList list = new PointPairList();

            for ( int i = 0; i < 100; i++ )
            {
                double x = new XDate( 2007, 6, 3 + i );
                double y = Math.Sin( i / 8.0 ) * 1 + 1;
                list.Add( x, y );
            }

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            z1.AxisChange();

            //myPane.YAxis.Scale.Format = "0.0'%'";
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:21,代码来源:Form1.cs


示例11: 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


示例12: 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


示例13: 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


示例14: CreatePlayerCountImageOneMonth

        private MemoryStream CreatePlayerCountImageOneMonth(GameServer server, out string fileName)
        {
            LordControl.PlayerCountStatisticInfo[] _infoArray = null;
            DateTime _endTime = DateTime.Now;
            DateTime _startTime = _endTime.AddMonths(-1);

            _infoArray = server.GetPlugInData(0, LordControl.PlugInGuid, LordControl.DataKeyPlayerCountStatistic, _startTime, _endTime) as LordControl.PlayerCountStatisticInfo[];

            if (_infoArray.Length != 0)
            {
                ArrayList playerCountArrayList = new ArrayList();

                LordControl.PlayerCountStatisticInfo tempInfo = new LordControl.PlayerCountStatisticInfo();
                tempInfo.Time = _infoArray[0].Time;

                int countInOneDay = 0;

                for (int i = 0; i < _infoArray.Length; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = _infoArray[i];

                    if (tempInfo.Time.Date == info.Time.Date)
                    {
                        if (info.MaxCount > tempInfo.MaxCount)
                            tempInfo.MaxCount = info.MaxCount;
                        if (info.MinCount < tempInfo.MinCount)
                            tempInfo.MinCount = info.MinCount;
                        tempInfo.AverageCount += info.AverageCount;
                        countInOneDay++;

                        if (i == _infoArray.Length - 1)
                        {
                            tempInfo.AverageCount /= countInOneDay;
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                    else
                    {
                        tempInfo.AverageCount /= countInOneDay;

                        playerCountArrayList.Add(tempInfo);

                        tempInfo = new LordControl.PlayerCountStatisticInfo();

                        tempInfo.Time = info.Time;
                        tempInfo.AverageCount = info.AverageCount;
                        tempInfo.MaxCount = info.MaxCount;
                        tempInfo.MinCount = info.MinCount;

                        countInOneDay = 1;

                        if (i == _infoArray.Length - 1)
                        {
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                }

                double[] maxCountArray = new double[playerCountArrayList.Count];
                double[] minCountArray = new double[playerCountArrayList.Count];
                double[] averageCountArray = new double[playerCountArrayList.Count];
                double[] timeArray = new double[playerCountArrayList.Count];

                for (int i = 0; i < playerCountArrayList.Count; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = playerCountArrayList[i] as LordControl.PlayerCountStatisticInfo;
                    maxCountArray[i] = info.MaxCount;
                    minCountArray[i] = info.MinCount;
                    averageCountArray[i] = info.AverageCount;
                    timeArray[i] = new XDate(info.Time);
                }

                GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 840, 450), String.Empty, String.Empty, String.Empty);

                graphPane.Fill = new Fill(Color.FromArgb(212, 208, 200));

                graphPane.Legend.Fill.IsVisible = false;
                graphPane.Legend.Border.IsVisible = false;
                graphPane.Legend.FontSpec.Fill.IsVisible = false;

                graphPane.XAxis.Title.Text = "时间";
                graphPane.XAxis.MajorGrid.Color = Color.DarkGreen;
                graphPane.XAxis.Type = AxisType.Date;
                graphPane.XAxis.Scale.FontSpec.Size = 11;

                graphPane.YAxis.Title.Text = "玩家数量";
                //graphPane.YAxis.MajorGrid.IsVisible = true;
                //graphPane.YAxis.MajorGrid.DashOff = 0;
                //graphPane.YAxis.MajorGrid.Color = Color.Gray;
                //graphPane.YAxis.MinorGrid.IsVisible = true;
                //graphPane.YAxis.MinorGrid.Color = Color.LightGray;
                //graphPane.YAxis.MinorGrid.DashOff = 0;
                graphPane.YAxis.Scale.Min = 0;

                graphPane.Title.Text = string.Format("{0} [ {1}  {2} ]", "玩家数量", _startTime, _endTime);

                graphPane.AddCurve("最大", timeArray, maxCountArray, Color.Red, SymbolType.Triangle);
                graphPane.AddCurve("最小", timeArray, minCountArray, Color.Green, SymbolType.TriangleDown);
                graphPane.AddCurve("平均", timeArray, averageCountArray, Color.Orange, SymbolType.Diamond);

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


示例15: 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


示例16: CreateGraph_Junk2

        public void CreateGraph_Junk2( ZedGraphControl z1 )
        {
            DateTime dateTime = new DateTime( 2006, 6, 16 );
            int hours = 1;

            double d1 = new XDate( dateTime - new TimeSpan( hours, 59, 59 ) );
            double d2 = new XDate( dateTime + new TimeSpan( 0, 0, 59 ) );

            //XDate x1 = d1 );
            //XDate x2 = new XDate( d2 );

            GraphPane pane = z1.GraphPane;
            pane.Title.Text = "Log Book";

            pane.LineType = LineType.Stack;
            pane.XAxis.Scale.Max = 24;

            pane.YAxis.Scale.Max = 4.5;
            string[] labels = { "Off Duty", "Sleeper Berth", "On Duty Driving", "On Duty Not Driving" };
            double[] x = { };
            double[] y = { };
            LineItem line = pane.AddCurve( "Driver1", x, y, Color.Red );

            line.Line.StepType = StepType.ForwardStep;

            line.Symbol.IsVisible = false;

            line.AddPoint( 0, 0 );
            line.AddPoint( 2, 2 );
            line.AddPoint( 9, 4 );
            line.AddPoint( 13, 2 );
            line.AddPoint( 24, 1 );
            pane.YAxis.MajorTic.IsBetweenLabels = true;
            pane.YAxis.Scale.TextLabels = labels;
            pane.YAxis.Type = AxisType.Text;
            pane.Chart.Fill = new Fill( Color.White, Color.LightSkyBlue, 45.0F );
            z1.AxisChange();
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:38,代码来源:Form1.cs


示例17: CreateGraph_DateAxis

        // Basic curve test - Date Axis
        private void CreateGraph_DateAxis( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();

            for ( int i = 0; i < 50; i++ )
            {
                double x = new XDate( 2005, 12 + i, 15 );
                double y = Math.Sin( i / 8.0 ) * 1000 + 1001;
                list.Add( x, y, 1500 );
                list2.Add( x, y * 1.2, 1500 );
            }

            LineItem line = myPane.AddCurve( "Line", list, Color.Blue, SymbolType.Diamond );
            //myPane.XAxis.Scale.Format = "MMM\nyyyy";
            myPane.XAxis.Type = AxisType.Date;

            //myPane.XAxis.Scale.MajorStep = 1;
            //myPane.XAxis.Scale.MajorUnit = DateUnit.Year;
            myPane.XAxis.Scale.MinorStep = 1;
            myPane.XAxis.Scale.MinorUnit = DateUnit.Month;

            /*
            BarItem myBar = myPane.AddBar( "Bar", list, Color.Blue );
            BarItem myBar2 = myPane.AddBar( "Bar2", list2, Color.Green );
            //LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            myPane.BarSettings.Type = BarType.ClusterHiLow;
            myPane.BarSettings.ClusterScaleWidth = 20.0;
            */

            z1.IsAutoScrollRange = true;
            z1.IsShowHScrollBar = true;
            z1.IsShowVScrollBar = true;

            XDate now = new XDate( DateTime.Now );
            ArrowObj arrow = new ArrowObj( Color.Black,
                    2.0f, (float) now.XLDate, 0.0f, (float) now.XLDate, 1.0f );
            arrow.IsArrowHead = false;
            arrow.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            arrow.IsClippedToChartRect = true;
            myPane.GraphObjList.Add( arrow );

            // Make the first year line
            double xDate = new XDate( 2006, 1, 1 ).XLDate;
            LineObj myLine = new LineObj();
            myLine.Location.X1 = xDate;
            myLine.Location.Y1 = 0.0;
            myLine.Location.Width = 0.0;
            myLine.Location.Height = 1.0;
            myLine.IsClippedToChartRect = true;
            myLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            myLine.Line.Width = 2.0f;
            myLine.Line.Color = Color.Red;
            myPane.GraphObjList.Add( myLine );

            // Repeat for each Grid by cloning
            xDate = new XDate( 2007, 1, 1 ).XLDate;
            ;
            myLine = new LineObj( myLine );
            myLine.Location.X1 = xDate;
            myPane.GraphObjList.Add( myLine );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:65,代码来源:Form1.cs


示例18: CreateGraph_junk9

        public void CreateGraph_junk9( ZedGraphControl z1 )
        {
         

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ZedGraph.ZedGraphControl类代码示例发布时间:2022-05-26
下一篇:
C# ZedGraph.ValueHandler类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap