void InitZedGraph(LinkQualityIndicator[] lqis)
        {
            CreateSmoothing(lqis);

            var pane = zedGraphControl.GraphPane;

            zedGraphControl.IsAntiAlias = true;
            pane.CurveList.Clear();
            _tickStart = Environment.TickCount;

            const int interval = 1000 / 40; // 40fps

            var rotator = new ColorSymbolRotator();

            foreach (var lqi in lqis)
            {
                var list = new RollingPointPairList(30000 / interval); // 1 min buffer

                // Initially, a curve is added with no data points (list is empty)
                // Color is blue, and there will be no symbols
                pane.AddCurve(lqi.EndPointA + "<>" + lqi.EndPointB, list, rotator.NextColor, SymbolType.None);

                // Just manually control the X axis range so it scrolls continuously
                // instead of discrete step-sized jumps
                var xScale = pane.XAxis.Scale;
                xScale.Min       = 0;
                xScale.Max       = 20;
                xScale.MinorStep = 1;
                xScale.MajorStep = 5;
            }
        }
Esempio n. 2
0
        public MasterPaneLayout()
            : base("A Demo of the MasterPane with a complex layout",
                   "MasterPane Layout", DemoType.General, DemoType.Special)
        {
            MasterPane master = base.MasterPane;

            master.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            master.Title.Text      = "My MasterPane Title";

            master.Margin.All = 10;
            //master.InnerPaneGap = 10;
            //master.Legend.IsVisible = true;
            //master.Legend.Position = LegendPos.TopCenter;

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for (int j = 0; j < 6; j++)
            {
                master.Add(AddGraph(j, rotator));
            }

            using (Graphics g = base.ZedGraphControl.CreateGraphics())
            {
                //master.PaneLayoutMgr.SetLayout( PaneLayout.ExplicitRow32 );
                //master.PaneLayoutMgr.SetLayout( 2, 4 );
                master.SetLayout(g, false, new int[] { 1, 3, 2 }, new float[] { 2, 1, 3 });
                master.IsCommonScaleFactor = true;
                base.ZedGraphControl.AxisChange();

                //g.Dispose();
            }
        }
        private void UpdateEnd(bool state)
        {
            ColorSymbolRotator color = new ColorSymbolRotator();

            // Even if an error occurs during downloads, maybe some values are OK
            for (int i = 0; i < CurvesNumber; i++)
            {
                LineItem l = m_zedGraphCtl.GraphPane.AddCurve("", Pointslists[i], color.NextColor, SymbolType.None);
                l.Line.Width = 2;
            }
            m_zedGraphCtl.GraphPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 190), 45F);

            m_zedGraphCtl.RestoreScale(m_zedGraphCtl.GraphPane);

            this.UseWaitCursor    = false;
            m_progressBar.Visible = false;

            if (state == false)
            {
                m_progresslabel.Text = "Error loading trend";
            }
            else
            {
                m_progresslabel.Visible = false;
            }

            m_list.Visible = true;
        }
Esempio n. 4
0
        public GraphPane AddGraph(int j, ColorSymbolRotator rotator)
        {
            // Create a new graph with topLeft at (40,40) and size 600x400
            GraphPane myPaneT = new GraphPane(new Rectangle(40, 40, 600, 400),
                                              "Case #" + (j + 1).ToString(),
                                              "Time, Days",
                                              "Rate, m/s");

            myPaneT.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
            myPaneT.BaseDimension = 6.0F;

            // Make up some data arrays based on the Sine function
            double        x, y;
            PointPairList list = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                x = (double)i + 5;
                y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                list.Add(x, y);
            }

            LineItem myCurve = myPaneT.AddCurve("Type " + j.ToString(),
                                                list, rotator.NextColor, rotator.NextSymbol);

            myCurve.Symbol.Fill = new Fill(Color.White);

            return(myPaneT);
        }
Esempio n. 5
0
        public GraphData(Entry[] entries)
        {
            var rotator = new ColorSymbolRotator();

            var firstEntry = entries[0];

            DeviceCount = firstEntry.results.Count;

            Timeline = new double[entries.Length];
            var data = new double[DeviceCount][];

            for (int i = 0; i < data.Length; i++)
            {
                data[i] = new double[entries.Length];
            }

            var firstTimestamp = firstEntry.timestamp;

            for (int i = 0; i < entries.Length; i++)
            {
                var entry = entries[i];
                Timeline[i] = Utils.MillisecondsSinceEpoch(entry.timestamp - firstTimestamp).ToOADate();
                for (int j = 0; j < DeviceCount; j++)
                {
                    var q = entry.results[j].Quality;
                    data[j][i] = (q != 0.0 ? q : double.NaN);
                }
            }

            ConnectionDatas = new ConnectionData[DeviceCount];
            for (int i = 0; i < ConnectionDatas.Length; i++)
            {
                ConnectionDatas[i] = new ConnectionData(firstEntry.results[i].EndPointA, firstEntry.results[i].EndPointB, data[i], rotator.NextColor);
            }
        }
        public Bitmap GetCustomBitmapForWatershed()
        {
            if (Data.Count == 0 || Data[0].Count == 0)
            {
                return(new Bitmap(1, 1));
            }

            var csr         = new ColorSymbolRotator();
            var dirBmp      = new DirectBitmap(Data[0].Count, Data.Count);
            var savedColors = new Dictionary <double, Color>();

            for (var i = 0; i < dirBmp.Height; i++)
            {
                for (var j = 0; j < dirBmp.Width; j++)
                {
                    if ((int)Data[i][j].Y != -1)
                    {
                        if (!savedColors.ContainsKey(Data[i][j].Y))
                        {
                            savedColors.Add(Data[i][j].Y, csr.NextColor);
                        }
                        dirBmp.SetPixel(j, i, savedColors[Data[i][j].Y]);
                    }
                    else
                    {
                        dirBmp.SetPixel(j, i, Color.Gray);
                    }
                }
            }

            return(dirBmp.Bitmap);
        }
Esempio n. 7
0
        private void PlotData(double[,] oData)
        {
            var oRotator = new ColorSymbolRotator();

            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.IsAntiAlias = _ChangeTimeCoursePlot.IsAntiAlias;

            var oColumnNames = new ArrayList(_ChangeTimeCoursePlot.XAxisValues);

            // Assumptions:
            //
            //      - one column is used exclusively for x data
            //        this column is usually 0 = time, but maybe changed
            //      - Hence in n columns there are n-1 curves to plut
            //        UNLESS the selected one is not time then we have n-2 curves ...
            //

            int nSelectedXAxis = _ChangeTimeCoursePlot.SelectedIndex;
            int numCurves      = oData.GetLength(1) - 1 - (nSelectedXAxis == 0 ? 0 : 1);


            var oLists = new PointPairList[numCurves];

            int nIndex = 1;

            for (int i = 0; i < numCurves; i++)
            {
                if (nIndex == nSelectedXAxis)
                {
                    nIndex++;
                }
                oLists[i] = new PointPairList();
                for (int j = 0; j < oData.GetLength(0); j++)
                {
                    oLists[i].Add(oData[j, nSelectedXAxis], oData[j, nIndex]);
                }

                zedGraphControl1.GraphPane.AddCurve((string)oColumnNames[nIndex], oLists[i], oRotator.NextColor,
                                                    SymbolType.None);
                nIndex++;
            }

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
Esempio n. 8
0
        public void draw(double[] y, string title = "", string x_title = "", string y_title = "", int vertical_line = -1, string[] datanotes = null)
        {
            GraphPane myPane = zGraph1.GraphPane;

            this.Text               = title;
            myPane.Title.Text       = title;
            myPane.XAxis.Title.Text = x_title;
            myPane.YAxis.Title.Text = y_title;
            datastring              = datanotes;

            ColorSymbolRotator rotator = new ColorSymbolRotator();



            double[] x = new double[y.Length];

            for (int j = 0; j < y.Length; j++)
            {
                x[j] = j;
            }

            LineItem curve1 = myPane.AddCurve("", x, y, rotator.NextColor, SymbolType.None);

            curve1.Symbol.Fill     = new Fill(Color.White);
            curve1.Line.Width      = 2;
            myPane.YAxis.Scale.Min = y.Min();
            myPane.YAxis.Scale.Max = y.Max();
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = y.Length - 1;

            if (vertical_line >= 0)
            {
                LineObj line = new LineObj(Color.Brown, vertical_line, 0, vertical_line, myPane.YAxis.Scale.Max);
                line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                myPane.GraphObjList.Add(line);
            }

            myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);
            zGraph1.AxisChange();
        }
Esempio n. 9
0
        public void draw(double[,] data, string[] titles)
        {
            MasterPane myMaster = zGraph1.MasterPane;

            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "Cointegration coefficients";
            myMaster.Title.IsVisible = true;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Enable the masterpane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;



            // Initialize a color and symbol type rotator
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            // Create some new GraphPanes
            int n = data.GetLength(0);
            int m = data.GetLength(1);

            for (int i = 0; i < m; i++)
            {
                double[] x = new double[n];
                double[] y = new double[n];
                for (int j = 0; j < n; j++)
                {
                    x[j] = j;
                    y[j] = data[j, i];
                }

                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                                 titles[i],
                                                 "",
                                                 "Value");

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;



                // Add a curve to the Graph, use the next sequential color and symbol
                LineItem myCurve = myPane.AddCurve(titles[i], x, y, rotator.NextColor, SymbolType.None);
                // Fill the symbols with white to make them opaque
                myCurve.Symbol.Fill = new Fill(Color.White);
                myCurve.Line.Width  = 4;
                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);
                zGraph1.Height += 100;
            }



            using (Graphics g = this.CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.SingleColumn);
            }

            zGraph1.AxisChange();
        }
Esempio n. 10
0
        public PeakStatisticsForm(IDPickerForm owner)
        {
            InitializeComponent();

            this.owner = owner;

            FormClosing += delegate(object sender, FormClosingEventArgs e)
            {
                e.Cancel  = true;
                DockState = DockState.DockBottomAutoHide;
            };

            Text = TabText = "Peak Statistics";
            Icon = Properties.Resources.BlankIcon;

            var csr    = new ColorSymbolRotator();
            var colors = new List <Color>()
            {
                Color.Gray
            };

            for (int i = 0; i < (int)IonSeries.Count; ++i)
            {
                colors.Add(csr.NextColor);
            }

            var graphPane = zedGraphControl.GraphPane;

            graphPane.Title.Text                = "Peak m/z - precursor m/z";
            graphPane.XAxis.Title.Text          = "m/z";
            graphPane.YAxis.Title.Text          = "Intensity";
            graphPane.YAxis.MajorTic.IsOpposite = false;
            graphPane.YAxis.MinorTic.IsOpposite = false;
            graphPane.Legend.IsVisible          = false;
            graphPane.IsFontsScaled             = false;

            precursorScatterPlot = graphPane.AddCurve("", new PointPairList(), Color.Gray, SymbolType.Circle);
            precursorScatterPlot.Line.IsVisible          = false;
            precursorScatterPlot.Symbol.IsAntiAlias      = false;
            precursorScatterPlot.Symbol.Border.IsVisible = false;
            precursorScatterPlot.Symbol.Fill             = new Fill(colors.ToArray())
            {
                Type = FillType.GradientByColorValue, RangeMin = 0, RangeMax = (double)IonSeries.Count, SecondaryValueGradientColor = Color.Gray
            };
            precursorScatterPlot.Symbol.Size = 5f;

            graphPane                           = new GraphPane();
            graphPane.Title.Text                = "Peak m/z - charge reduced precursor m/z";
            graphPane.XAxis.Title.Text          = "m/z";
            graphPane.YAxis.Title.Text          = "Intensity";
            graphPane.YAxis.MajorTic.IsOpposite = false;
            graphPane.YAxis.MinorTic.IsOpposite = false;
            graphPane.Legend.IsVisible          = false;
            graphPane.IsFontsScaled             = false;
            zedGraphControl.MasterPane.PaneList.Add(graphPane);

            chargeReducedScatterPlot = graphPane.AddCurve("", new PointPairList(), Color.Gray, SymbolType.Circle);
            chargeReducedScatterPlot.Line.IsVisible          = false;
            chargeReducedScatterPlot.Symbol.IsAntiAlias      = false;
            chargeReducedScatterPlot.Symbol.Border.IsVisible = false;
            chargeReducedScatterPlot.Symbol.Fill             = new Fill(colors.ToArray())
            {
                Type = FillType.GradientByColorValue, RangeMin = 0, RangeMax = (double)IonSeries.Count, SecondaryValueGradientColor = Color.Gray
            };
            chargeReducedScatterPlot.Symbol.Size = 5f;

            zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), PaneLayout.SingleColumn);
            zedGraphControl.MasterPane.InnerPaneGap = 0;

            zedGraphControl.MasterPane.AxisChange();
            zedGraphControl.Refresh();
        }
Esempio n. 11
0
 /// <summary>
 /// Loads some pseudo unique colors/symbols into this LineItem.  This
 /// is mainly useful for differentiating a set of new LineItems without
 /// having to pick your own colors/symbols.
 /// <seealso cref="CurveItem.MakeUnique( ColorSymbolRotator )"/>
 /// </summary>
 /// <param name="rotator">
 /// The <see cref="ColorSymbolRotator"/> that is used to pick the color
 ///  and symbol for this method call.
 /// </param>
 public override void MakeUnique( ColorSymbolRotator rotator )
 {
     this.Color			= rotator.NextColor;
     this.Symbol.Type	= rotator.NextSymbol;
 }
        public MasterPaneWithSplitterDemo() : base("MasterPane With Splitter",
                                                   "MasterPane With Splitter Sample", DemoType.Financial)
        {
            var myMaster = base.MasterPane;

            // Remove the default GraphPane that comes with ZedGraphControl
            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "ZedGraph MasterPane With Splitter Example";
            myMaster.Title.IsVisible = true;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Enable the masterpane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;

            // Initialize a color and symbol type rotator
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            const int TotPanes = 3;

            // Create some new GraphPanes
            for (int j = 0; j < TotPanes; j++)
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                                 "Case #" + (j + 1).ToString(),
                                                 "Time, Days",
                                                 "Rate, m/s");

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    double x = (double)i + 5;
                    double y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                // Add a curve to the Graph, use the next sequential color and symbol
                LineItem myCurve = myPane.AddCurve("Type " + j.ToString(),
                                                   list, rotator.NextColor, rotator.NextSymbol);
                // Fill the symbols with white to make them opaque
                myCurve.Symbol.Fill = new Fill(Color.White);

                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);

                if (j == TotPanes - 1)
                {
                    break;
                }

                var splitter = new SplitterPane(false);
                myMaster.Add(splitter);
            }

            using (var g = ZedGraphControl.CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.SingleColumn);
                myMaster.AxisChange(g);
            }
        }
        void setData(object sender, DoWorkEventArgs e)
        {
            try
            {
                Map <int, List <PSMRow> > precursorMassErrorsByCharge = new Map <int, List <PSMRow> >();;
                IDictionary <int, int>    spectralCountByChargeState;
                lock (session)
                {
                    var randomIds = session.CreateQuery("SELECT psm.Id " + viewFilter.GetFilteredQueryString(DataFilter.FromPeptideSpectrumMatch))
                                    .List <long>()
                                    .Shuffle()
                                    .Take(50000)
                                    .OrderBy(o => o);
                    string randomIdSet = String.Join(",", randomIds.Select(o => o.ToString()).ToArray());
                    var    query       = session.CreateSQLQuery("SELECT psm.ObservedNeutralMass, psm.MonoisotopicMassError, psm.MolecularWeightError, s.ScanTimeInSeconds, psm.Charge " +
                                                                "FROM PeptideSpectrumMatch psm " +
                                                                "JOIN Spectrum s ON psm.Spectrum=s.Id " +
                                                                "WHERE psm.Id IN (" + randomIdSet + ") " +
                                                                "GROUP BY psm.Id");
                    query.List <object[]>().ForEach(o =>
                                                    precursorMassErrorsByCharge[Convert.ToInt32(o[4])].Add(new PSMRow
                    {
                        ObservedNeutralMass = Convert.ToDouble(o[0]),
                        MassError           = PeptideSpectrumMatch.GetSmallerMassError(Convert.ToDouble(o[1]), Convert.ToDouble(o[2])),
                        ScanTime            = Convert.ToDouble(o[3]) / 60, // convert to minutes
                        Charge = Convert.ToInt32(o[4])
                    }));

                    var query2 = session.CreateQuery("SELECT psm.Charge, COUNT(DISTINCT psm.Spectrum.id) " +
                                                     dataFilter.GetFilteredQueryString(DataFilter.FromPeptideSpectrumMatch) +
                                                     "GROUP BY psm.Charge");
                    spectralCountByChargeState = query2.List <object[]>().ToDictionary(o => Convert.ToInt32(o[0]), o => Convert.ToInt32(o[1]));
                }

                Map <int, List <List <PSMRow> > > clusteredPrecursorMassErrorsByCharge = clusterMassErrors(precursorMassErrorsByCharge);

                // convert to PPM if the user requested it
                if (!ppmMassErrorMenuItem.Text.Contains("PPM"))
                {
                    clusteredPrecursorMassErrorsByCharge.Values.ForEach(o3 => o3.ForEach(o2 => o2.ForEach(o => o.MassError = o.MassError / o.ObservedNeutralMass * 1e6)));
                }

                {
                    var csr = new ColorSymbolRotator();
                    precursorMassErrorForm.ZedGraphControl.GraphPane.CurveList.Clear();
                    foreach (var kvp in clusteredPrecursorMassErrorsByCharge)
                    {
                        bool firstCluster = true;
                        var  color        = csr.NextColor;
                        foreach (var precursorMassErrorCluster in kvp.Value)
                        {
                            var precursorMassErrors      = precursorMassErrorCluster;
                            var precursorMassErrorValues = precursorMassErrors.Select(o => o.MassError).ToArray();
                            var densityCurve             = new LineItem(firstCluster ? kvp.Key.ToString() : "", getDensityCurve(precursorMassErrorValues, 0), color, SymbolType.None);
                            var grassPlot = new LineItem("", precursorMassErrorValues, Enumerable.Repeat(0.0, precursorMassErrorValues.Length).ToArray(), color, SymbolType.VDash)
                            {
                                Tag = kvp.Key
                            };
                            densityCurve.Line.IsAntiAlias = true;
                            precursorMassErrorForm.ZedGraphControl.GraphPane.CurveList.Add(densityCurve);
                            precursorMassErrorForm.ZedGraphControl.GraphPane.CurveList.Add(grassPlot);
                            firstCluster = false;
                        }
                    }
                }

                {
                    var csr = new ColorSymbolRotator();
                    scanTimeDistributionForm.ZedGraphControl.GraphPane.CurveList.Clear();
                    foreach (var kvp in precursorMassErrorsByCharge)
                    {
                        var precursorMassErrors = kvp.Value;
                        var scanTimeValues      = precursorMassErrors.Select(o => o.ScanTime).ToList();
                        var color = csr.NextColor;
                        if (scanTimeValues.Max() > 0)
                        {
                            var densityCurve = new LineItem(kvp.Key.ToString(), getDensityCurve(scanTimeValues, 0), color, SymbolType.None);
                            var grassPlot    = new LineItem("", scanTimeValues.ToArray(), Enumerable.Repeat(0.0, scanTimeValues.Count).ToArray(), color, SymbolType.VDash);
                            densityCurve.Line.IsAntiAlias = true;
                            scanTimeDistributionForm.ZedGraphControl.GraphPane.CurveList.Add(densityCurve);
                            scanTimeDistributionForm.ZedGraphControl.GraphPane.CurveList.Add(grassPlot);
                        }
                    }

                    if (scanTimeDistributionForm.ZedGraphControl.GraphPane.CurveList.IsNullOrEmpty())
                    {
                        scanTimeDistributionForm.ZedGraphControl.GraphPane.GraphObjList.Add(
                            new TextObj("No scan time information present.\r\nUse File/Embed to import scan times from raw data.",
                                        0.5, 0.5, CoordType.ChartFraction, AlignH.Center, AlignV.Center)
                        {
                            FontSpec = new FontSpec("monospace", 18.0f, Color.Black, true, false, false)
                        });
                    }
                }

                var colorRotator = new ColorSymbolRotator();
                var colors       = new List <Color>();
                foreach (var kvp in spectralCountByChargeState)
                {
                    colors.Add(colorRotator.NextColor);
                }

                chargeStatesForm.ZedGraphControl.GraphPane.CurveList.Clear();
                chargeStatesForm.ZedGraphControl.GraphPane.BarSettings.MinClusterGap = 8;
                var barItem = chargeStatesForm.ZedGraphControl.GraphPane.AddBar("", spectralCountByChargeState.Keys.Select(o => (double)o).ToArray(), spectralCountByChargeState.Values.Select(o => (double)o).ToArray(), Color.White) as BarItem;
                for (int i = 0; i < barItem.Points.Count; ++i)
                {
                    barItem.Points[i].ColorValue = (double)i + 1;
                }
                barItem.Bar.Fill = new Fill(colors.ToArray())
                {
                    Type     = FillType.GradientByColorValue,
                    RangeMin = 1,
                    RangeMax = colors.Count
                };
                chargeStatesForm.ZedGraphControl.GraphPane.XAxis.Scale.TextLabels = spectralCountByChargeState.Keys.Select(o => o.ToString()).ToArray();
            }
            catch (Exception ex)
            {
                e.Result = ex;
            }
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        public MasterSampleDemo() : base("Code Project MasterPane Sample",
                                         "MasterPane Sample", DemoType.Tutorial)
        {
            MasterPane myMaster = base.MasterPane;

            // Remove the default GraphPane that comes with ZedGraphControl
            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "ZedGraph MasterPane Example";
            myMaster.Title.IsVisible = true;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Enable the masterpane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;

            // Add a priority stamp
            TextObj text = new TextObj("Priority", 0.88F, 0.12F);

            text.Location.CoordinateFrame  = CoordType.PaneFraction;
            text.FontSpec.Angle            = 15.0F;
            text.FontSpec.FontColor        = Color.Red;
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color     = Color.Red;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Left;
            text.Location.AlignV           = AlignV.Bottom;
            myMaster.GraphObjList.Add(text);

            // Add a draft watermark
            text = new TextObj("DRAFT", 0.5F, 0.5F);
            text.Location.CoordinateFrame  = CoordType.PaneFraction;
            text.FontSpec.Angle            = 30.0F;
            text.FontSpec.FontColor        = Color.FromArgb(70, 255, 100, 100);
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 100;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Center;
            text.Location.AlignV           = AlignV.Center;
            text.ZOrder = ZOrder.B_BehindLegend;
            myMaster.GraphObjList.Add(text);

            // Initialize a color and symbol type rotator
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            // Create some new GraphPanes
            for (int j = 0; j < 5; j++)
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                                 "Case #" + (j + 1).ToString(),
                                                 "Time, Days",
                                                 "Rate, m/s");

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    double x = (double)i + 5;
                    double y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                // Add a curve to the Graph, use the next sequential color and symbol
                LineItem myCurve = myPane.AddCurve("Type " + j.ToString(),
                                                   list, rotator.NextColor, rotator.NextSymbol);
                // Fill the symbols with white to make them opaque
                myCurve.Symbol.Fill = new Fill(Color.White);

                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);
            }

            using (Graphics g = this.ZedGraphControl.CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.ExplicitRow32);
                myMaster.AxisChange(g);
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Loads some pseudo unique colors/symbols into this CurveItem.  This
 /// is mainly useful for differentiating a set of new CurveItems without
 /// having to pick your own colors/symbols.
 /// <seealso cref="MakeUnique(ColorSymbolRotator)"/>
 /// </summary>
 /// <param name="rotator">
 /// The <see cref="ColorSymbolRotator"/> that is used to pick the color
 ///  and symbol for this method call.
 /// </param>
 public virtual void MakeUnique( ColorSymbolRotator rotator )
 {
     this.Color = rotator.NextColor;
 }
Esempio n. 17
0
        private void PlotResults(AutoResult oResult)
        {
            graphControl1.ZedControl.GraphPane.CurveList.Clear();
            var oRot = new ColorSymbolRotator();

            CurrentPlot = new List <PlotInfo>();

            foreach (AutoResultRun run in oResult.AllRuns)
            {
                var series = run.DataSeries;

                if (series.Count < 2)
                {
                    continue;
                }


                if (series[0].Length < 10)
                {
                    continue;
                }

                for (int i = 0; i < series.Count - 1; i++)
                {
                    var sLabel     = GetNthName(i);
                    var oLineColor = oRot.NextColor;
                    var info       = new PlotInfo {
                        Label     = sLabel,
                        MainCurve = new PointPairList(series[0], series[i + 1])
                    };

                    if (oResult.Positions.Count == 0)
                    {
                        AddNthCurveToGraph(i, series, sLabel, oLineColor);
                    }
                    else
                    {
                        var thickSegments = FindNthThickSegments(i, oResult, series);
                        AddNthSegmentedCurveToGraph(i, thickSegments, series, sLabel, oLineColor);
                        info.ThickSegments = thickSegments;
                    }
                    CurrentPlot.Add(info);
                }


                foreach (IntTripple tripple in oResult.Labels)
                {
                    for (int i = 0; i < series.Count - 1; i++)
                    {
                        int currentPos = UtilLib.FindClosestStablePoint(tripple.Key, oResult.Positions);

                        double x    = series[0][currentPos];
                        double y    = series[1 + i][currentPos];
                        var    text = new TextObj(UtilLib.ConvertIntTypeToShortString(tripple.Value2), x, y);
                        text.Tag = new TagData {
                            Series = 1 + i, Tripple = tripple, Label = GetNthName(i)
                        };

                        graphControl1.ZedControl.GraphPane.GraphObjList.Add(text);
                    }
                }
            }

            graphControl1.ZedControl.GraphPane.XAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.XAxis.Scale.MinGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MinGrace = 0f;

            SetParameterAxisTitle();

            graphControl1.ZedControl.AxisChange();
            tabControl1.Refresh();
        }
Esempio n. 18
0
        public SynchronizedPanes()
            : base("A demo that shows how multiple GraphPanes can be synchronized to scroll together." +
                   "  Test it by zooming in on one pane (all panes will zoom together).  Then, scroll to" +
                   " see all panes move together.",
                   "Synchronized Panes Demo", DemoType.Line)
        {
            MasterPane master = base.MasterPane;

            master.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            master.Title.Text      = "Synchronized Graph Demo";

            master.Margin.All   = 10;
            master.InnerPaneGap = 0;

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for (int j = 0; j < 3; j++)
            {
                // Create a new graph with topLeft at (40,40) and size 600x400
                GraphPane myPaneT = new GraphPane(new Rectangle(40, 40, 600, 400),
                                                  "Case #" + (j + 1).ToString(),
                                                  "Time, Days",
                                                  "Rate, m/s");

                myPaneT.Fill.IsVisible = false;

                myPaneT.Chart.Fill                = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPaneT.BaseDimension             = 3.0F;
                myPaneT.XAxis.Title.IsVisible     = false;
                myPaneT.XAxis.Scale.IsVisible     = false;
                myPaneT.Legend.IsVisible          = false;
                myPaneT.Border.IsVisible          = false;
                myPaneT.Title.IsVisible           = false;
                myPaneT.XAxis.MajorTic.IsOutside  = false;
                myPaneT.XAxis.MinorTic.IsOutside  = false;
                myPaneT.XAxis.MajorGrid.IsVisible = true;
                myPaneT.XAxis.MinorGrid.IsVisible = true;
                myPaneT.Margin.All                = 0;
                if (j == 0)
                {
                    myPaneT.Margin.Top = 20;
                }
                if (j == 2)
                {
                    myPaneT.XAxis.Title.IsVisible = true;
                    myPaneT.XAxis.Scale.IsVisible = true;
                    myPaneT.Margin.Bottom         = 10;
                }

                if (j > 0)
                {
                    myPaneT.YAxis.Scale.IsSkipLastLabel = true;
                }

                // This sets the minimum amount of space for the left and right side, respectively
                // The reason for this is so that the ChartRect's all end up being the same size.
                myPaneT.YAxis.MinSpace  = 60;
                myPaneT.Y2Axis.MinSpace = 20;

                // Make up some data arrays based on the Sine function
                double        x, y;
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    x = (double)i + 5 + j * 3;
                    y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                LineItem myCurve = myPaneT.AddCurve("Type " + j.ToString(),
                                                    list, rotator.NextColor, rotator.NextSymbol);
                myCurve.Symbol.Fill = new Fill(Color.White);

                master.Add(myPaneT);
            }

            using (Graphics g = base.ZedGraphControl.CreateGraphics())
            {
                ZedGraphControl z1 = base.ZedGraphControl;

                master.SetLayout(g, PaneLayout.SingleColumn);
                z1.AxisChange();

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

            base.ZedGraphControl.AxisChange();
        }
Esempio n. 19
0
        public void draw(double[] LB, double[] Mean, double[] UB)
        {
            GraphPane myPane = zGraph1.GraphPane;


            myPane.Title.Text       = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "Price ratio";

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            //double[] y = new double[100];
            //double[] lb = new double[100];
            //double[] m = new double[100];
            //double[] ub = new double[100];

            //for (int j = 0; j < 100; j++)
            //{
            //    y[j] = j;
            //    lb[j] = LB[j + 100];
            //    m[j] = Mean[j + 100];
            //    ub[j] = UB[j + 100];
            //}



            //LineItem curve1 = myPane.AddCurve("LB", y, lb, rotator.NextColor, SymbolType.None);
            //curve1.Symbol.Fill = new Fill(Color.White);
            //curve1.Line.Width = 1;

            //LineItem curve2 = myPane.AddCurve("Mean", y, m, rotator.NextColor, SymbolType.None);
            //curve2.Symbol.Fill = new Fill(Color.White);
            //curve2.Line.Width = 1;

            //LineItem curve3 = myPane.AddCurve("UB", y, ub, rotator.NextColor, SymbolType.None);
            //curve3.Symbol.Fill = new Fill(Color.White);
            //curve3.Line.Width = 1;

            double[] y = new double[LB.Length];

            for (int j = 0; j < LB.Length; j++)
            {
                y[j] = j;
            }



            LineItem curve1 = myPane.AddCurve("LB", y, LB, rotator.NextColor, SymbolType.None);

            curve1.Symbol.Fill = new Fill(Color.White);
            curve1.Line.Width  = 1;

            LineItem curve2 = myPane.AddCurve("Mean", y, Mean, rotator.NextColor, SymbolType.None);

            curve2.Symbol.Fill = new Fill(Color.White);
            curve2.Line.Width  = 1;

            LineItem curve3 = myPane.AddCurve("UB", y, UB, rotator.NextColor, SymbolType.None);

            curve3.Symbol.Fill = new Fill(Color.White);
            curve3.Line.Width  = 1;

            // Fill the axis background with a gradient
            //myPane.XAxis.Scale.Min = 0;
            //myPane.XAxis.Scale.Max = 99;

            myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);
            zGraph1.AxisChange();
        }
Esempio n. 20
0
        public override void Refresh()
        {
            MasterPane mp = msGraphControl.MasterPane;

            mp.Border.IsVisible = false;
            //pane.Chart.Border.IsVisible = false;

            if (mp.PaneList.Count != paneList.Count)
            {
                mp.PaneList.Clear();
                foreach (Pane logicalPane in paneList)
                {
                    MSGraphPane pane = new MSGraphPane();
                    pane.Border.IsVisible        = false;
                    pane.IsFontsScaled           = false;
                    pane.YAxis.ScaleFormatEvent += YAxis_ScaleFormatEvent;
                    mp.Add(pane);
                }
                //mp.SetLayout( msGraphControl.CreateGraphics(), paneLayout );
            }
            else
            {
                for (int i = 0; i < paneList.Count; ++i)
                {
                    MSGraphPane pane = mp.PaneList[i] as MSGraphPane;
                    pane.Border.IsVisible = false;
                    pane.CurveList.Clear();
                    pane.GraphObjList.Clear();
                }
            }

            for (int i = 0; i < paneList.Count; ++i)
            {
                Pane        logicalPane = paneList[i];
                MSGraphPane pane        = mp.PaneList[i] as MSGraphPane;
                pane.IsFontsScaled    = false;
                pane.Border.IsVisible = false;

                bool needSourceNamePrefix = logicalPane.Select(o => o.Source).Distinct().Count() > 1;
                int  maxAutoLegendItems   = needSourceNamePrefix ? 5 : 10;

                foreach (GraphItem item in logicalPane.Take(logicalPane.Count - 1))
                {
                    //item.AddSourceToId = needSourceNamePrefix;
                    msGraphControl.AddGraphItem(pane, item, false);
                }
                //logicalPane.Last().AddSourceToId = needSourceNamePrefix;
                msGraphControl.AddGraphItem(pane, logicalPane.Last(), true);

                if (mp.PaneList.Count > 1)
                {
                    if (msGraphControl.IsSynchronizeXAxes && i < paneList.Count - 1)
                    {
                        pane.XAxis.Title.IsVisible = false;
                        pane.XAxis.Scale.IsVisible = false;
                        pane.Margin.Bottom         = 0;
                        //pane.Margin.Top = 0;
                    }
                    else
                    {
                        //pane.Margin.Top = 0;
                        pane.XAxis.Title.IsVisible = true;
                        pane.XAxis.Scale.IsVisible = true;
                    }
                    pane.YAxis.Title.IsVisible = true;
                    pane.YAxis.Scale.IsVisible = true;
                    pane.YAxis.Title.Text      = String.Join(", ", logicalPane.Select(o => o.Title)) + "\n" + pane.YAxis.Title.Text.Split('\n').Last();
                    pane.YAxis.Scale.SetupScaleData(pane, pane.YAxis);
                }
                else
                {
                    pane.XAxis.IsVisible       = true;
                    pane.XAxis.Title.IsVisible = true;
                    pane.XAxis.Scale.IsVisible = true;
                    pane.YAxis.Title.IsVisible = true;
                    pane.YAxis.Scale.IsVisible = true;
                }

                if (logicalPane.Count == 1)
                {
                    pane.Legend.IsVisible = false;
                }
                else
                {
                    pane.Legend.IsVisible = ShowPaneLegends ?? (logicalPane.Count < maxAutoLegendItems);
                    pane.Legend.Position  = ZedGraph.LegendPos.TopCenter;

                    ZedGraph.ColorSymbolRotator rotator = new ColorSymbolRotator();
                    foreach (CurveItem item in pane.CurveList)
                    {
                        item.Color = rotator.NextColor;
                    }
                }

                if (paneList.Count > 0 && paneList[0].Count > 0)
                {
                    this.Text = paneList[0][0].Id;
                    if (paneList[0][0].IsMassSpectrum)
                    {
                        this.TabText = (paneList[0][0] as MassSpectrum).AbbreviatedId;
                    }
                    else
                    {
                        this.TabText = this.Text;
                    }
                }

                if (pane.XAxis.Scale.MaxAuto)
                {
                    using (Graphics g = msGraphControl.CreateGraphics())
                    {
                        if (msGraphControl.IsSynchronizeXAxes || msGraphControl.IsSynchronizeYAxes)
                        {
                            foreach (GraphPane p in msGraphControl.MasterPane.PaneList)
                            {
                                p.XAxis.ResetAutoScale(p, g);
                                p.X2Axis.ResetAutoScale(p, g);
                                foreach (YAxis axis in p.YAxisList)
                                {
                                    axis.ResetAutoScale(p, g);
                                }
                                foreach (Y2Axis axis in p.Y2AxisList)
                                {
                                    axis.ResetAutoScale(p, g);
                                }
                            }
                        }
                        else
                        {
                            pane.XAxis.ResetAutoScale(pane, g);
                            pane.X2Axis.ResetAutoScale(pane, g);
                            foreach (YAxis axis in pane.YAxisList)
                            {
                                axis.ResetAutoScale(pane, g);
                            }
                            foreach (Y2Axis axis in pane.Y2AxisList)
                            {
                                axis.ResetAutoScale(pane, g);
                            }
                        }
                    }
                    //msGraphControl.RestoreScale(pane);
                }
                else
                {
                    pane.AxisChange();
                }
            }

            mp.SetLayout(msGraphControl.CreateGraphics(), paneLayout);

            /*if( isOverlay )
             * {
             *  pane.Legend.IsVisible = true;
             *  pane.Legend.Position = ZedGraph.LegendPos.TopCenter;
             *  for( int i = 0; i < pane.CurveList.Count; ++i )
             *  {
             *      pane.CurveList[i].Color = overlayColors[i];
             *      ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2;
             *  }
             * } else
             * {
             *  pane.Legend.IsVisible = false;
             *  currentGraphItem = chromatogram;
             * }*/

            //msGraphControl.RestoreScale( pane );
            //msGraphControl.ZoomOutAll( pane );

            /*bool isScaleAuto = !pane.IsZoomed;
             *
             * if( isScaleAuto )
             *  pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X );
             * else
             *  pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );*/

            // String.Format( "{0} - {1}", currentDataSource.Name, chromatogram.Id )

            if (mp.PaneList.Count > 0 &&
                (focusedPane == null ||
                 !mp.PaneList.Contains(focusedPane)))
            {
                focusedPane = mp.PaneList[0] as MSGraphPane;
            }

            if (mp.PaneList.Count > 0 &&
                mp.PaneList[0].CurveList.Count > 0 &&
                (focusedItem == null ||
                 //!focusedPane.CurveList.Contains( focusedItem ) ) ) // somehow focusedItem.Tag can be the same as one of focusedPane.CurveList's Tags, but Contains returns false
                 !focusedPane.CurveList.Any(o => o.Tag == focusedItem.Tag)))
            {
                setFocusedItem(mp.PaneList[0].CurveList[0]);
            }

            msGraphControl.Refresh();
        }
Esempio n. 21
0
        public override void Refresh()
        {
            MasterPane mp = msGraphControl.MasterPane;

            mp.Border.IsVisible = false;
            //pane.Chart.Border.IsVisible = false;

            if (mp.PaneList.Count != paneList.Count)
            {
                mp.PaneList.Clear();
                foreach (Pane logicalPane in paneList)
                {
                    MSGraphPane pane = new MSGraphPane();
                    pane.Border.IsVisible = false;
                    pane.IsFontsScaled    = false;
                    mp.Add(pane);
                }
                //mp.SetLayout( msGraphControl.CreateGraphics(), paneLayout );
            }
            else
            {
                for (int i = 0; i < paneList.Count; ++i)
                {
                    MSGraphPane pane = mp.PaneList[i] as MSGraphPane;
                    pane.Border.IsVisible = false;
                    pane.CurveList.Clear();
                    pane.GraphObjList.Clear();
                }
            }

            for (int i = 0; i < paneList.Count; ++i)
            {
                Pane        logicalPane = paneList[i];
                MSGraphPane pane        = mp.PaneList[i] as MSGraphPane;
                pane.IsFontsScaled    = false;
                pane.Border.IsVisible = false;

                foreach (GraphItem item in logicalPane)
                {
                    msGraphControl.AddGraphItem(pane, item);
                }

                if (mp.PaneList.Count > 1)
                {
                    //if( i < paneList.Count - 1 )
                    {
                        pane.XAxis.Title.IsVisible = false;
                        pane.XAxis.Scale.IsVisible = false;
                        pane.Margin.Bottom         = 0;
                        pane.Margin.Top            = 2;
                    }/* else
                      * {
                      * pane.XAxis.Title.IsVisible = true;
                      * pane.XAxis.Scale.IsVisible = true;
                      * }*/
                    pane.YAxis.Title.IsVisible = false;
                    pane.YAxis.Scale.IsVisible = false;
                    pane.YAxis.Scale.SetupScaleData(pane, pane.YAxis);
                }
                else
                {
                    pane.XAxis.IsVisible       = true;
                    pane.XAxis.Title.IsVisible = true;
                    pane.XAxis.Scale.IsVisible = true;
                    pane.YAxis.Title.IsVisible = true;
                    pane.YAxis.Scale.IsVisible = true;
                }

                if (logicalPane.Count == 1)
                {
                    pane.Legend.IsVisible = false;
                }
                else
                {
                    pane.Legend.IsVisible = true;
                    pane.Legend.Position  = ZedGraph.LegendPos.TopCenter;

                    ZedGraph.ColorSymbolRotator rotator = new ColorSymbolRotator();
                    foreach (CurveItem item in pane.CurveList)
                    {
                        item.Color = rotator.NextColor;
                    }
                }

                if (paneList.Count > 0 && paneList[0].Count > 0)
                {
                    this.Text = paneList[0][0].Id;
                    if (paneList[0][0].IsMassSpectrum)
                    {
                        this.TabText = pwiz.CLI.msdata.id.abbreviate(paneList[0][0].Id);
                    }
                    else
                    {
                        this.TabText = this.Text;
                    }
                }

                if (pane.XAxis.Scale.MaxAuto)
                {
                    msGraphControl.RestoreScale(pane);
                }
                else
                {
                    pane.AxisChange();
                }
            }

            mp.SetLayout(msGraphControl.CreateGraphics(), paneLayout);

            /*if( isOverlay )
             * {
             *  pane.Legend.IsVisible = true;
             *  pane.Legend.Position = ZedGraph.LegendPos.TopCenter;
             *  for( int i = 0; i < pane.CurveList.Count; ++i )
             *  {
             *      pane.CurveList[i].Color = overlayColors[i];
             *      ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2;
             *  }
             * } else
             * {
             *  pane.Legend.IsVisible = false;
             *  currentGraphItem = chromatogram;
             * }*/

            //msGraphControl.RestoreScale( pane );
            //msGraphControl.ZoomOutAll( pane );

            /*bool isScaleAuto = !pane.IsZoomed;
             *
             * if( isScaleAuto )
             *  pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X );
             * else
             *  pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );*/

            // String.Format( "{0} - {1}", currentDataSource.Name, chromatogram.Id )

            if (mp.PaneList.Count > 0 &&
                (focusedPane == null ||
                 !mp.PaneList.Contains(focusedPane)))
            {
                focusedPane = mp.PaneList[0] as MSGraphPane;
            }

            if (mp.PaneList.Count > 0 &&
                mp.PaneList[0].CurveList.Count > 0 &&
                (focusedItem == null ||
                 !focusedPane.CurveList.Contains(focusedItem)))
            {
                setFocusedItem(mp.PaneList[0].CurveList[0]);
            }

            msGraphControl.Refresh();
        }
Esempio n. 22
0
        // Call this method from the Form_Load method, passing your ZedGraphControl
        public void CreateChart(ZedGraphControl zgc, PointPairList pplist)
        {
            var myMaster = zgc.MasterPane;

            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "";
            myMaster.Title.IsVisible = false;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.LightGray, 45.0f);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Initialize a color and symbol type rotator
            var rotator = new ColorSymbolRotator();

            // Create some new GraphPanes
            for (var j = 0; j < nPatterns; j++)
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                var myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                           "Pattern: " + (j + 1).ToString(),
                                           "Dataset Number",
                                           "Intensity (normalized)");
                myPane.Title.FontSpec.Size       = 12F;
                myPane.XAxis.Title.FontSpec.Size = 10F;
                myPane.YAxis.Title.FontSpec.Size = 10F;
                myPane.YAxis.Scale.Min           = -0.1;
                myPane.YAxis.Scale.Max           = 1;
                // Make the XAxis start with the first label at -1
                myPane.XAxis.Scale.BaseTic = -1;

                // Hide the legend
                myPane.Legend.IsVisible = false;

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;

                // Data to plot
                list = new PointPairList();
                var vpattern = mhtPatterns[(j + 1).ToString()];

                for (var i = 0; i < vpattern.Count; i++)
                {
                    var x = (double)i + 1;
                    var y = vpattern[i];

                    list.Add(x, y);
                }

                // Add a curve to the Graph, use the next sequential color and symbol
                var myCurve = myPane.AddCurve("Type " + j,
                                              list, rotator.NextColor, rotator.NextSymbol);

                myCurve.Line.Width  = 1.5F;
                myCurve.Symbol.Fill = new Fill(Color.White);
                myCurve.Symbol.Size = 5;

                // Fill the axis background with a gradient
                myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);

                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);
            }

            using (var g = CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.SquareRowPreferred);
            }

            zgc.AxisChange();
        }