Example #1
0
        public ZedGraphDataLoader(ZedGraphControl chart)
        {
            chart1 = chart;
            pane = chart1.GraphPane;
            pane.Chart.Border.IsVisible = false;

            // set scale
            pane.YAxis.Scale.MinGrace = 0;
            pane.YAxis.Scale.MaxGrace = 0;
            pane.XAxis.Scale.MinGrace = 0;
            pane.XAxis.Scale.MaxGrace = 0;
            pane.XAxis.Scale.MagAuto = false;
            pane.YAxis.Scale.MagAuto = false;

            SetPaneVisible(false);

            chart1.ZoomEvent += chart1_ZoomEvent;
            chart1.MouseDownEvent += chart1_MouseDownEvent;
            chart1.MouseUpEvent += chart1_MouseUpEvent;

            using (Graphics g = chart1.CreateGraphics())
            {
                _dpiFactor = Convert.ToSingle(g.DpiX / 96.0);
            }

            // set fonts
            ApplyFontDefaults();
        }
Example #2
0
        public void ConfigGraphPane(ZedGraphControl zgc, Form f, PaneLayout pl, List<ChartInfo> chInfo)
        {
            MasterPane master = zgc.MasterPane;

            master.PaneList.Clear();
            master.Title.IsVisible = true;
            foreach (ChartInfo ci in chInfo)
            {
                var pane = new GraphPane();
                master.PaneList.Add(pane);
                ConfigGraphPane(pane, ci.Title, ci.XAxisTitle, ci.YAxisTitle);
            }
            using (Graphics g = zgc.CreateGraphics())
            {
                master.SetLayout(g, pl);
                master.AxisChange(g);
            }
            zgc.AxisChange();
        }
        public SIPTransportMetricsGraphAgent(string localGraphsDir, string metricsFileName, string metricsFileCopy)
        {
            m_localGraphsDir = localGraphsDir;
            //m_serverFilename = serverFileName;
            m_metricsFileName = metricsFileName;
            m_metricsFileCopyName = metricsFileCopy;

            m_graphControl = new ZedGraphControl();
            m_g = m_graphControl.CreateGraphics();

            m_methodColours.Add(SIPMethodsEnum.REGISTER , Color.Red );
            m_methodColours.Add(SIPMethodsEnum.INVITE, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.BYE, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.CANCEL, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.ACK, Color.Blue);
            m_methodColours.Add(SIPMethodsEnum.OPTIONS, Color.Purple);
            m_methodColours.Add(SIPMethodsEnum.UNKNOWN, Color.Orange);
            m_methodColours.Add(SIPMethodsEnum.SUBSCRIBE, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.PING, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.INFO, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.PUBLISH, Color.Green);
            m_methodColours.Add(SIPMethodsEnum.NOTIFY, Color.Aquamarine);

            m_topTalkerColours[0] = Color.FromArgb(252, 2, 4);      // Red.
            m_topTalkerColours[1] = Color.FromArgb(4, 154, 252);    // Navy'ish.
            m_topTalkerColours[2] = Color.FromArgb(4, 154, 156);    // Green'ish.
            m_topTalkerColours[3] = Color.FromArgb(4, 254, 252);    // Aqua.
            m_topTalkerColours[4] = Color.FromArgb(4, 178, 4);      // Flat Green.
            m_topTalkerColours[5] = Color.FromArgb(252, 174, 172);  // Pink'ish.
            m_topTalkerColours[6] = Color.FromArgb(4, 2, 252);      // Blue.
            m_topTalkerColours[7] = Color.FromArgb(252, 202, 4);    // Orange-Yellow.
            m_topTalkerColours[8] = Color.FromArgb(180, 2, 180);    // Purple.
            m_topTalkerColours[9] = Color.Black;
        }
Example #4
0
        private void CreateGraph_MasterWithPies( ZedGraphControl z1 )
        {
            GraphPane pane = z1.GraphPane;

            pane.Title.Text = "Test Pie";

            PieItem myPie = pane.AddPieSlice( 10, Color.Red, 0.0, "First" );
            myPie = pane.AddPieSlice( 20, Color.Blue, 0.0, "Second" );
            myPie = pane.AddPieSlice( 15, Color.Green, 0.0, "Third" );
            myPie = pane.AddPieSlice( 40, Color.Purple, 0.0, "Fourth" );
            myPie = pane.AddPieSlice( 27, Color.Pink, 0.0, "Fifth" );

            z1.MasterPane[0] = pane;
            z1.MasterPane.Add( pane.Clone() as GraphPane );
            z1.MasterPane.Add( pane.Clone() as GraphPane );
            z1.MasterPane.Add( pane.Clone() as GraphPane );
            z1.MasterPane.Add( pane.Clone() as GraphPane );

            using ( Graphics g = z1.CreateGraphics() )
                z1.MasterPane.SetLayout( g, PaneLayout.ExplicitRow32 );
        }
Example #5
0
        private void CreateGraph_junk10( ZedGraphControl zgc )
        {
            //Create a Masterpane
            MasterPane myMaster = zgc.MasterPane;
            myMaster.SetLayout( zgc.CreateGraphics(), false, new int[] { 3 }, new float[] { 1, 1, 4 } );
            myMaster.IsFontsScaled = false;

            myMaster.PaneList.Clear();

            GraphPane myPaneII = new GraphPane( new Rectangle( new Point( 0, 0 ),
                new Size( 400, 350 / 2 ) ), "", "", "" );
            GraphPane myPane = new GraphPane( new Rectangle( new Point( 0, 0 ),
                new Size( 400, 350 / 2 ) ), "", "", "" );

            myPane.Margin.All = 0;
            myPaneII.Margin.All = 0;
            myMaster.Margin.All = 0;

            myPane.Border.IsVisible = false;
            myPaneII.Border.IsVisible = false;
            myMaster.Border.IsVisible = false;

            //myPane
            //General
            myPane.Title.Text = "TLV-Resolver";
            myPane.Title.FontSpec.Size = 50;
            myPane.Legend.FontSpec.Size = 50;

            //XAxis
            myPane.XAxis.Title.Text = "Date";
            myPane.XAxis.Title.IsVisible = false;

            myPane.XAxis.Type = AxisType.Date;
            //myPane.XAxis.Scale.MinAuto = true;
            //myPane.XAxis.Scale.MinorUnit = DateUnit.Millisecond;
            //myPane.XAxis.Scale.MajorUnit = DateUnit.Millisecond;
            //myPane.XAxis.Scale.Format = "mm:ss.fff";
            myPane.XAxis.Scale.FontSpec.Size = 50;
            //myPane.XAxis.Scale.MajorStep = 5;
            //myPane.XAxis.Scale.MinorStep = 0.5;
            myPane.XAxis.Scale.IsVisible = true;

            myPane.XAxis.IsVisible = true;
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MinorGrid.IsVisible = true;
            myPane.XAxis.Scale.IsPreventLabelOverlap = false;

            //YAxis
            myPane.YAxis.Title.Text = "Status";
            myPane.YAxis.Scale.Max = 1;
            myPane.YAxis.Scale.FontSpec.Size = 50;
            myPane.YAxis.Scale.MajorStep = 2;
            myPane.YAxis.Scale.MinorStep = 1;
            myPane.YAxis.IsVisible = true;
            myPane.YAxis.Title.FontSpec.Size = 50;
            myPane.YAxis.MinorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            //2.Pane
            //General
            myPaneII.Title.Text = "COM-Resolver";
            myPaneII.Title.IsVisible = true;
            myPaneII.Title.FontSpec.Size = 50;
            myPaneII.Legend.FontSpec.Size = 50;

            //XAxis
            myPaneII.XAxis.Title.Text = "Date";
            myPaneII.XAxis.Title.IsVisible = false;
            myPaneII.XAxis.Type = AxisType.Date;
            //myPaneII.XAxis.Scale.MinorUnit = DateUnit.Millisecond;
            //myPaneII.XAxis.Scale.MajorUnit = DateUnit.Millisecond;
            //myPaneII.XAxis.Scale.Format = "mm:ss.fff";

            myPaneII.XAxis.MajorGrid.IsVisible = true;
            myPaneII.XAxis.MinorGrid.IsVisible = true;
            //myPaneII.XAxis.Scale.MajorStep = 5;
            //myPaneII.XAxis.Scale.MinorStep = 0.5;
            myPaneII.XAxis.Scale.FontSpec.Size = 50;
            myPaneII.XAxis.IsVisible = true;
            myPaneII.XAxis.Scale.IsVisible = true;

            //YAxis
            myPaneII.YAxis.Title.Text = "Status";
            myPaneII.YAxis.Title.FontSpec.Size = 50;
            myPaneII.YAxis.Scale.MajorStep = 1;
            myPaneII.YAxis.Scale.MinorStep = 1;
            myPaneII.YAxis.Scale.Max = 1;
            myPaneII.YAxis.Scale.FontSpec.Size = 50;

            // Make up some data arrays based on the Sine function
            double x, x2;
            int y1 = 0, y2 = 1;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            for ( int i = 0; i < 1000; i++ )
            {
                int year = DateTime.Now.Year, month = DateTime.Now.Month, day = DateTime.Now.Day, hour = DateTime.Now.Hour, minute = DateTime.Now.Minute, second = DateTime.Now.Second, mil = DateTime.Now.Millisecond;

                //System.Threading.Thread.Sleep( 10 );

                //Getting just time value exapmle(0.1248874895d)
                double myDate = DateTime.Now.ToOADate();
                double mySubtrahend = Convert.ToDouble( DateTime.Now.ToOADate().ToString().Trim().Substring( 0, myDate.ToString().Trim().IndexOf( "." ) ) );
                myDate = myDate - mySubtrahend;

                x = myDate;

                x2 = DateTime.FromOADate( myDate ).AddMilliseconds( 347 ).ToOADate();

                switch ( y1 )
                {
                    case 0:
                        y1 = 1;
                        break;
                    case 1:
                        y1 = 0;
                        break;
                    default:
                        y1 = 0;
                        break;
                }

                switch ( y2 )
                {
                    case 0:
                        y2 = 1;
                        break;
                    case 1:
                        y2 = 0;
                        break;
                    default:
                        y2 = 0;
                        break;
                }

                list1.Add( x, y1, DateTime.FromOADate( x ).ToLongTimeString() + ";" + DateTime.FromOADate( x ).Millisecond.ToString() );
                list2.Add( x2, y2, DateTime.FromOADate( x2 ).ToLongTimeString() + ";" + DateTime.FromOADate( x2 ).Millisecond.ToString() );
            }

            // Generate a red curve with diamond
            // symbols, and "Laser" in the legend
            LineItem myCurve = myPane.AddCurve( "Laser",
                list1, Color.Red, SymbolType.Diamond );

            //myCurve.Label.FontSpec = new FontSpec( "Arial", 20, Color.Black, true, false, false );
            myPane.Legend.FontSpec.Size = 100;

            // Generate a blue curve with circle
            // symbols, and "Shutter" in the legend
            LineItem myCurveII = myPaneII.AddCurve( "Shutter", list2, Color.Blue, SymbolType.Circle );

            zgc.MasterPane.InnerPaneGap = 0;
            myMaster.PaneList.Add( myPane );
            myMaster.PaneList.Add( myPaneII );

            zgc.IsShowHScrollBar = false;

            zgc.IsSynchronizeXAxes = true;
            zgc.IsSynchronizeYAxes = true;

            zgc.IsEnableHZoom = true;

            zgc.IsEnableVZoom = false;
            zgc.IsEnableVPan = false;

            //zgc.ContextMenu.MenuItems.Clear();

            zgc.IsZoomOnMouseCenter = false;
            zgc.AxisChange();
        }
 /// <summary>
 /// Redraw the chart
 /// </summary>
 /// <param name="zedChart"></param>
 private void RefreshChart(ref ZedGraphControl chart)
 {
     using (Graphics g = chart.CreateGraphics())
     {
         chart.MasterPane.SetLayout(g, PaneLayout.SingleColumn);
         chart.AxisChange();
     }
     chart.Invalidate();
 }
        private void initializeGraphControl (ZedGraphControl zedGraphControl)
        {
            zedGraphControl.MasterPane.PaneList.Clear();
            zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), 1, (int) IonSeries.Count + 1);
            zedGraphControl.MasterPane.InnerPaneGap = 0;
            zedGraphControl.MasterPane.Border.IsVisible = true;
            zedGraphControl.IsEnableHPan = false;
            zedGraphControl.IsEnableHZoom = false;
            zedGraphControl.IsSynchronizeYAxes = true;
            zedGraphControl.IsZoomOnMouseCenter = true;

            var axisPane = new GraphPane();
            axisPane.Legend.IsVisible = false;
            axisPane.IsFontsScaled = false;
            axisPane.XAxis.IsVisible = false;
            axisPane.YAxis.Scale.Min = 0;
            axisPane.YAxis.Scale.Max = 100;
            axisPane.YAxis.Title.Text = zedGraphControl.Text;
            axisPane.YAxis.Title.Gap = 0.05f;
            axisPane.YAxis.MajorTic.IsOpposite = false;
            axisPane.YAxis.MinorTic.IsOpposite = false;
            axisPane.Chart.Border.IsVisible = false;
            axisPane.Border.IsVisible = false;
            axisPane.Margin.Left = 1;
            axisPane.Margin.Right = 0;
            axisPane.Title.Text = "Series:";
            zedGraphControl.MasterPane.Add(axisPane);

            var csr = new ColorSymbolRotator();
            for (int i = 0; i < (int) IonSeries.Count; ++i)
            {
                var graphPane = new GraphPane();
                graphPane.Title.Text = IonSeriesLabels[i];
                graphPane.Legend.IsVisible = false;
                graphPane.IsFontsScaled = false;
                graphPane.Chart.Border.IsVisible = false;
                graphPane.Border.IsVisible = false;
                graphPane.XAxis.Scale.Min = -1;
                graphPane.XAxis.Scale.Max = 1;
                graphPane.XAxis.IsVisible = false;
                graphPane.YAxis.Scale.Min = 0;
                graphPane.YAxis.Scale.Max = 100;
                graphPane.YAxis.IsVisible = false;
                zedGraphControl.MasterPane.Add(graphPane);

                graphPane.BarSettings.Type = BarType.Overlay;
                graphPane.BarSettings.ClusterScaleWidth = 1;

                var mean = graphPane.AddCurve(IonSeriesLabels[i],
                                              new PointPairList(),
                                              Color.Black,
                                              SymbolType.Circle);
                mean.Line.IsVisible = false;
                mean.Symbol.Border.IsVisible = false;
                mean.Symbol.Fill.Type = FillType.Solid;

                var errorBar = graphPane.AddErrorBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                errorBar.Bar.IsVisible = true;
                errorBar.Bar.PenWidth = .1f;
                errorBar.Bar.Symbol.IsVisible = true;
                errorBar.Bar.Symbol.Type = SymbolType.HDash;
                errorBar.Bar.Symbol.Border.Width = .1f;
                errorBar.Bar.Symbol.Size = 4;

                var hiLowBar = graphPane.AddHiLowBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                hiLowBar.Bar.Fill.Type = FillType.None;

                var scatter = graphPane.AddCurve(IonSeriesLabels[i],
                                                 new PointPairList(),
                                                 csr.NextColor,
                                                 SymbolType.Circle);
                scatter.Line.IsVisible = false;
                scatter.Symbol.IsAntiAlias = true;
                scatter.Symbol.Border.IsVisible = false;
                scatter.Symbol.Fill.Type = FillType.Solid;
                scatter.Symbol.Size = 3f;
            }

            zedGraphControl.MasterPane.AxisChange();
            zedGraphControl.Refresh();
        }
Example #8
0
        /// <summary>
        /// Add a new graph to the control.
        /// </summary>
        /// <param name="data">The points to plot.</param>
        /// <param name="key">Name of the set to put in the graph key</param>
        /// <param name="control">The control to plot on.</param>
        /// <param name="color">The color for this key.</param>
        /// <param name="offset">The starting point for this plot.</param>
        /// <param name="lineStyle">The style of line to plot.</param>
        public void AddGraph(
            Dictionary<DateTime, Dictionary<string, double>> data, 
            string key, 
            ZedGraphControl control, 
            Color color, 
            int offset, 
            System.Drawing.Drawing2D.DashStyle lineStyle)
        {
            GraphPane pane;
            int num_panels = control.MasterPane.PaneList.Count;
            if (num_panels == 2)
            {
                pane = control.MasterPane.PaneList[1];
            }
            else
            {
                pane = new GraphPane();
                control.MasterPane.PaneList.Add(pane);
            }

            pane.XAxis.Scale.Max = data.Count;
            if (data.Count >= 99)
            {
                pane.XAxis.Scale.Min = data.Count - 99;
            }
            else
            {
                pane.XAxis.Scale.Min = 0;
            }

            PointPairList list = ExtractPointPair(data, key, offset);

            LineItem line = pane.AddCurve(key, list, color, SymbolType.None);
            line.Line.Style = lineStyle;
            line.IsOverrideOrdinal = true;

            pane.IsBoundedRanges = true;
            pane.Title.Text = "OHLC Graph";
            pane.XAxis.Type = AxisType.Ordinal;
            pane.XAxis.Title.Text = "Date";
            pane.YAxis.Title.Text = "KEY";
            pane.Margin.All = 0;
            pane.Margin.Bottom = 10;
            pane.YAxis.MinSpace = 80;
            pane.Y2Axis.MinSpace = 20;
            pane.AxisChange();
            control.MasterPane.AxisChange();
            using (Graphics g = control.CreateGraphics())
            {
                control.MasterPane.SetLayout(g, PaneLayout.SingleColumn);
                control.MasterPane.AxisChange(g);

                // Synchronize the Axes
                ////control.IsAutoScrollRange = true;
                control.IsShowHScrollBar = true;
                ////control.IsShowVScrollBar = true;
                control.IsSynchronizeXAxes = true;
                ////g.Dispose();
            }
        }