Пример #1
0
        public LineGraphBandDemo()
            : base("A demo of a bar graph with a region highlighted.",
											"Line Graph Band Demo", DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Line Graph with Band Demo";
            myPane.XAxis.Title.Text = "Sequence";
            myPane.YAxis.Title.Text = "Temperature, C";

            // Enter some random data values
            double[] y = { 100, 115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, 35 };
            double[] y3 = { 80, 110, 65, 15, 54, 67, 18 };
            double[] x = { 100, 200, 300, 400, 500, 600, 700 };

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245), Color.FromArgb( 255, 255, 190), 90F );

            // Generate a red curve with "Curve 1" in the legend
            LineItem myCurve = myPane.AddCurve( "Curve 1", x, y, Color.Red );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Generate a blue curve with "Curve 2" in the legend
            myCurve = myPane.AddCurve( "Curve 2", x, y2, Color.Blue );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Generate a green curve with "Curve 3" in the legend
            myCurve = myPane.AddCurve( "Curve 3", x, y3, Color.Green );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Manually set the x axis range
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 800;
            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;

            // Draw a box item to highlight a value range
            BoxObj box = new BoxObj( 0, 100, 800, 30, Color.Empty,
                    Color.FromArgb( 150, Color.LightGreen ) );
            box.Fill = new Fill( Color.White, Color.FromArgb( 200, Color.LightGreen ), 45.0F );
            // Use the BehindGrid zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.F_BehindGrid;
            myPane.GraphObjList.Add( box );

            // Add a text item to label the highlighted range
            TextObj text = new TextObj( "Optimal\nRange", 750, 85, CoordType.AxisXYScale,
                                    AlignH.Right, AlignV.Center );
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold = true;
            text.FontSpec.IsItalic = true;
            myPane.GraphObjList.Add( text );
        }
Пример #2
0
 private void AddRegion(double x1, double x2, Color lightBlue)
 {
     BoxObj box = new BoxObj(x1, 0, x2 - x1, 80, Color.LightGreen, Color.LightGreen);
     box.Location.CoordinateFrame = CoordType.AxisXYScale;
     box.IsVisible = true;
     box.ZOrder = ZOrder.A_InFront;//.D_BehindAxis;//.E_BehindAxis;
     zedGraphControl1.GraphPane.GraphObjList.Add(box);
 }
Пример #3
0
 public Signal(GraphPane pane, FormControl formControl)
 {
     this.formControl = formControl;
     this.pane = pane;
     boxObj = new BoxObj(0, 0, 1, 0, Color.LightYellow, Color.LightYellow)
                  {
                      Location = { CoordinateFrame = CoordType.XChartFractionYScale },
                      IsClippedToChartRect = true,
                      ZOrder = ZOrder.F_BehindGrid,
                      IsVisible = false
                  };
     pane.GraphObjList.Insert(0, boxObj);
     formControl.RefreshGraph();
     muteTimer.Interval = 2000;
     muteTimer.Tick += muteTimer_Tick;
 }
Пример #4
0
        /// <summary>
        /// Render legend
        /// </summary>
        /// <param name="gp"></param>
        /// <param name="dataResults"></param>
        protected override void RenderLegend(GraphPane gp, IEnumerable<RequestDataResults> dataResults)
        {
            int fontSize = 6;
            int offset = 0;
            int unit = (int) gp.YAxis.Scale.Max/10;
            // Average time
            var avgLegendBox = new BoxObj(-4, unit, 1, unit)
            {
                Fill = new Fill(Color.FromArgb(75, Color.YellowGreen))
            };
            gp.GraphObjList.Add(avgLegendBox);

            var avgLegendText = new TextObj("125", -3.5, (double)unit / 2).Style(Color.Black, fontSize);
            gp.GraphObjList.Add(avgLegendText);

            var avgLegendLabel = new TextObj("Average time", -4, (double)unit / 2).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgLegendLabel);

            offset += unit*2;

            // Min/Max
            var minMaxLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            gp.GraphObjList.Add(minMaxLine);

            var minMaxLabel = new TextObj("Min/Max", -4, offset + unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(minMaxLabel);

            offset += 3*unit;

            // Min/Max excluding extreme deciles
            var minMaxExclLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            minMaxExclLine.Line.Width = 3;
            minMaxExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(minMaxExclLine);

            var avgExclLine = new LineObj(Color.Black, -3.8, offset + unit, -3.2, offset + unit);
            avgExclLine.Line.Width = 3;
            avgExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(avgExclLine);

            var avgExclLabel1 = new TextObj("Min/Max/Avg", -4, offset + 1.2 *unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel1);
            var avgExclLabel2 = new TextObj("excluding extremes", -4, offset + 0.8 * unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel2);
        }
		/// <summary>
		/// Строит диаграмму для интервального ряда
		/// </summary>
		/// <param name="intervalFreq">Интервальный ряд</param>
		public void Plot(Dictionary<Range, double> data, Color color)
		{
			//Вывод графика
			var pane = graph.GraphPane;
			double maxY = 0;

			//Находим интервалы
			var intervals = new double[data.Count];
			var height = new double[data.Count];
			var xi = new double[data.Count];

			//МЕГАКОСТЫЛь. Зря я использовал Dictionary
			int i = 0;
			foreach (var x in data)
			{
				intervals[i] = x.Key.Length;
				height[i] = x.Value / intervals[i];
				xi[i] = x.Key.Left;
				i++;
			}

			//Рисуем гистограмму
			for (i = 0; i < height.Length; i++)
			{
				var box = new BoxObj((float)xi[i], (float)height[i], (float)intervals[i], (float)height[i], Color.Black, color);

				pane.GraphObjList.Add(box);
				if (height[i] > maxY) maxY = height[i];
			}



			//Настраиваем масштаб
			pane.XAxis.Scale.Min = data.First().Key.Left;
			pane.XAxis.Scale.Max = data.Last().Key.Right;
			pane.YAxis.Scale.Min = 0;
			pane.YAxis.Scale.Max = maxY * 1.1;

			graph.AxisChange();
			graph.Invalidate();
		}
        ///////////////////////////////////////////////////////////////////////////////////////////////
        // Build the Chart
        private void CreateGraph(ZedGraphControl zgc)
        {
            // get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;

            // Set the Titles
            myPane.Title.Text = microphone.title;
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsZeroLine = false;

            myPane.XAxis.Scale.Min = -1;
            myPane.XAxis.Scale.Max = 1;

            // По оси Y установим автоматический подбор масштаба
            myPane.YAxis.Scale.MinAuto = true;
            myPane.YAxis.Scale.MaxAuto = true;

            // Создаем список точек
            RadarPointList points = new RadarPointList();
            // Т.к. в списке будет 4 точки, то и окружность будет разбиваться на 4 части
            // Обход точек будет осуществляться по часовой стрелке
            points.Clockwise = true;
            // Первая точка - сверху над началом координат. Расстояние до центра = 1. Второй параметр в большинстве случаев не используется
            for (int i = 0; i < pointsArray.Length; i++)
            {
                points.Add(pointsArray[i], 1);
            }

            // Добавляем кривую по этим четырем точкам
            LineItem myCurve = myPane.AddCurve("", points, Color.Black, SymbolType.None);
            // Отметим начало координат черным квадратиком
            BoxObj box = new BoxObj(-0.005, 0.005, 0.01, 0.01, Color.Black, Color.Black);
            myPane.GraphObjList.Add(box);

            zgc.AxisChange();
            zgc.Invalidate();
        }
Пример #7
0
 /// <summary>
 /// Render individual bar
 /// </summary>
 /// <param name="gp"></param>
 /// <param name="d"></param>
 /// <param name="dataResults"></param>
 /// <param name="selectedIndex"></param>
 /// <param name="x"></param>
 /// <param name="func">Function to retrieve color to apply to the bar</param>
 protected virtual void RenderBar(GraphPane gp, IEnumerable<RequestDataResults> dataResults, int selectedIndex, float x, Func<IEnumerable<RequestDataResults>, int, Color> func)
 {
     var color = Color.DarkGray;
     if(func != null)
     {
         color = func(dataResults, selectedIndex);
     }
     var d = dataResults.ElementAt(selectedIndex);
     var box = new BoxObj(x, d.AverageResponseTime, 1, d.AverageResponseTime)
     {
         Fill = { Color = color }
     };
     gp.GraphObjList.Add(box);
 }
Пример #8
0
        /// <summary>
        /// 图形描绘
        /// </summary>
        public override void DrawGraph()
        {
            #region 图形所需数据
            //线条数组[线条数] [每条线的刻度值]
            double[][] lines;
            //X轴刻度
            double[] xAixsScale;
            //线条标注
            string[] labels;
            //X轴刻度标注
            string[] xAxisScaleLabels;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                xAixsScale = new double[base.DataSource.Rows.Count];
                xAxisScaleLabels = new string[base.DataSource.Rows.Count];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    xAixsScale[i] = i;
                    xAxisScaleLabels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //要绘制的线条数为数据列数
                lines = new double[base.ShowValueColumns.Length][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                    labels[i] = base.ShowValueColumns[i].ColumnName;


                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.DataSource.Rows.Count; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]))
                            lines[i][j] = 0;
                        else
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]);
                    }
                }
            }
            else
            {
                xAixsScale = new double[base.ShowValueColumns.Length];
                xAxisScaleLabels = new string[base.ShowValueColumns.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    xAixsScale[i] = i;
                    xAxisScaleLabels[i] = base.ShowValueColumns[i].ColumnName;
                }
                //要绘制的线条数为数据集的纪录数
                lines = new double[base.DataSource.Rows.Count][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.ShowValueColumns.Length; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]))
                            lines[i][j] = 0;
                        else
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]);
                    }
                }
            }

            int maxXaisxScale = xAixsScale.Length;

            //Console.Beep();

            #endregion

            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom = false;
            grphTx.IsEnableVZoom = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text = base.GraphTitle;
            myPane.XAxis.Title.Text = base.XAxisTitle;
            myPane.YAxis.Title.Text = base.YAxisTitle;

            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            //线条显示
            for (int i = 0; i < lines.Length; i++)
            {
                Color color;
                if (base.Colors == null)
                    color = GetColor();
                else
                    color = base.Colors[i];

                ZedGraph.LineItem myCurve = myPane.AddCurve(labels[i], xAixsScale, lines[i], color);

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

            //X轴属性
            myPane.XAxis.Scale.Min = 0; //X轴刻度起始值
            myPane.XAxis.Scale.Max = maxXaisxScale;//X轴刻度最大值
            myPane.XAxis.Scale.TextLabels = xAxisScaleLabels;//x轴刻度中文标注
            myPane.XAxis.Type = AxisType.Text;   //类型
            myPane.XAxis.Scale.FontSpec.Angle = 90; //文字方向
            myPane.XAxis.Scale.FontSpec.Size = 11F;  //文字大小

            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;


            BoxObj box = new BoxObj(0, 100, 1, 30, Color.Empty,
            Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);

            box.ZOrder = ZOrder.E_BehindCurves;

            box.IsClippedToChartRect = true;

            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);

            TextObj text = new TextObj("", 0.95f, 85, CoordType.AxisXYScale,
                                    AlignH.Right, AlignV.Center);
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold = true;
            text.FontSpec.IsItalic = true;
            text.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            text.IsClippedToChartRect = true;

            myPane.GraphObjList.Add(text);

            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);

            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
Пример #9
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="BoxObj"/> object from which to copy</param>
		public BoxObj( BoxObj rhs ) : base( rhs )
		{
			this.Border = rhs.Border.Clone();
			this.Fill = rhs.Fill.Clone();
		}
 private void checkGaps(GraphObj current,GraphObj next)
 {
     if (current.Location.X2 < next.Location.X1)
     {
         double gapWidth = next.Location.X1 - current.Location.X2;
         BoxObj gapBox1 = new BoxObj(current.Location.X2, Math.Floor(current.Location.Y), gapWidth, 1, _gapColor, _gapColor)
         {
             IsClippedToChartRect = true
         };
         zgIsolationGraph.GraphPane.GraphObjList.Add(gapBox1);
         _gapBoxes.Add(gapBox1);
     }
 }
        public DiaIsolationWindowsGraphForm(List<IsolationWindow> isolationWindows, bool usesMargins, object deconv, int windowsPerScan)
        {
            InitializeComponent();
            Icon = Resources.Skyline;
            if (isolationWindows.Count == 0)
                return;

            bool overlap = Equals(deconv, EditIsolationSchemeDlg.DeconvolutionMethod.MSX_OVERLAP) ||
                           Equals(deconv, EditIsolationSchemeDlg.DeconvolutionMethod.OVERLAP);

            //Setup Graph
            zgIsolationGraph.GraphPane.Title.Text = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_Measurement_Windows;
            zgIsolationGraph.GraphPane.XAxis.Title.Text = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_m_z;
            zgIsolationGraph.GraphPane.YAxis.Title.Text = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_Cycle;
            zgIsolationGraph.GraphPane.IsFontsScaled = false;
            zgIsolationGraph.GraphPane.YAxis.Scale.IsReverse = true;
            zgIsolationGraph.GraphPane.YAxisList[0].MajorTic.IsOpposite = false;
            zgIsolationGraph.GraphPane.YAxisList[0].MinorTic.IsOpposite = false;
            zgIsolationGraph.GraphPane.XAxis.MajorTic.IsOpposite = false;
            zgIsolationGraph.GraphPane.XAxis.MinorTic.IsOpposite = false;
            zgIsolationGraph.MasterPane.Border.IsVisible = false;
            zgIsolationGraph.GraphPane.YAxis.MajorGrid.IsZeroLine = false;
            zgIsolationGraph.GraphPane.Border.IsVisible = false;
            zgIsolationGraph.GraphPane.Chart.Border.IsVisible = false;

            //Draw Lines and rectangles
            _windows = new List<BoxObj>(20);
            _leftMargins = new List<BoxObj>(20);
            _rightMargins = new List<BoxObj>(20);
            _smallesMz = Double.MaxValue;
            _largestMz = 0;
            var isolationWindowArray = isolationWindows.ToArray();  // ReSharper
            int windowCount = isolationWindowArray.Length;

            for (int cycle = 0; cycle < TOTAL_CYCLES_SHOWN; cycle ++)
            {
                int firstIndex = overlap && cycle%2 == 1 ? windowCount/2 : 0;
                int stopIndex = overlap && cycle%2 == 0 ? windowCount/2 : windowCount;
                for (int i = firstIndex; i < stopIndex; i++)
                {
                    IsolationWindow window = isolationWindowArray[i];
                    double windowY = cycle + (double) (i - firstIndex)/(stopIndex - firstIndex);
                    double windowX = window.Start;
                    double windowWidth = window.End - window.Start;
                    double windowHeight = 1.0/(stopIndex - firstIndex);
                    BoxObj windowBox = new BoxObj(windowX,windowY,windowWidth,windowHeight,_windowColor,_windowColor)
                    {
                        IsClippedToChartRect = true
                    };
                    zgIsolationGraph.GraphPane.GraphObjList.Add(windowBox);
                    _windows.Add(windowBox);
                    if (usesMargins)
                    {
                        double marginLeftX = windowX - window.StartMargin ?? 0;
                        double marginLeftWidth = window.StartMargin ?? 0;
                        BoxObj marginLeftBox = new BoxObj(marginLeftX,windowY,marginLeftWidth,windowHeight,_marginColor,_marginColor)
                        {
                            IsClippedToChartRect = true
                        };
                        zgIsolationGraph.GraphPane.GraphObjList.Add(marginLeftBox);
                        _leftMargins.Add(marginLeftBox);

                        double marginRightX = windowX + windowWidth;
                        double marginRightWidth = window.EndMargin ?? window.StartMargin ?? 0;
                        BoxObj marginRightBox = new BoxObj(marginRightX, windowY, marginRightWidth, windowHeight, _marginColor, _marginColor)
                        {
                            IsClippedToChartRect = true
                        };
                        zgIsolationGraph.GraphPane.GraphObjList.Add(marginRightBox);
                        _rightMargins.Add(marginRightBox);
                        _largestMz = Math.Max(marginRightX + marginRightWidth, _largestMz);
                        _smallesMz = Math.Min(marginLeftX,_smallesMz);
                    }
                    _largestMz = Math.Max(_largestMz, windowX + windowWidth);
                    _smallesMz = Math.Min(_smallesMz, windowX);
                }
            }

            _overlapRayBoxes = overlap ? new List<BoxObj>() : null;
            _gapBoxes= new List<BoxObj>();
            _overlapBoxes = new List<BoxObj>();

            for (int cycle = 0; cycle < TOTAL_CYCLES_SHOWN; cycle ++)
            {
                int currentCycleStart;
                int currentCycleCount;
                int nextCycleStart;
                int nextCycleCount;
                if (overlap)
                {
                    currentCycleStart = cycle * windowCount/2;
                    currentCycleCount = windowCount/2;
                    nextCycleStart = currentCycleStart + currentCycleCount;
                    nextCycleCount = windowCount/2;
                }
                else
                {
                    currentCycleStart = cycle * windowCount;
                    currentCycleCount = windowCount;
                    nextCycleStart = currentCycleStart + windowCount;
                    nextCycleCount = windowCount;
                }
                List<BoxObj> currentCycleWindows =
                    _windows.GetRange(currentCycleStart, currentCycleCount).OrderBy(o => Location.X).ToList();
                List<BoxObj> nextCycleWindows = cycle < TOTAL_CYCLES_SHOWN - 1
                    ? _windows.GetRange(nextCycleStart, nextCycleCount).OrderBy(o => Location.X).ToList()
                    : null;

                for (int i = 0; i < currentCycleWindows.Count; i++)
                {
                    BoxObj currentCycleCurrentBox = currentCycleWindows.ElementAt(i);
                    BoxObj currentCycleNextBox = i < currentCycleWindows.Count - 1 ? currentCycleWindows.ElementAt(i+1) : null;

                    if (currentCycleNextBox != null)
                    {
                        checkGaps(currentCycleCurrentBox,currentCycleNextBox);
                        checkOverlaps(currentCycleCurrentBox,currentCycleNextBox);
                    }

                    if (overlap && i%2 == 0 && nextCycleWindows != null)
                    {
                        int leftBoxIndex = cycle % 2 == 0 ? i : i - 1;
                        BoxObj nextCycleLeftBox = leftBoxIndex >= 0 ? nextCycleWindows.ElementAt(leftBoxIndex) : null;
                        int rightBoxIndex = cycle % 2 == 0 ? i + 1 : i;
                        BoxObj nextCycleRightBox = rightBoxIndex < nextCycleWindows.Count
                            ? nextCycleWindows.ElementAt(rightBoxIndex)
                            : null;
                        BoxObj rayBoxLeft = null;
                        BoxObj rayBoxRight = null;
                        if (nextCycleLeftBox != null)
                        {
                            rayBoxLeft = GetOverLapRay(currentCycleCurrentBox, nextCycleLeftBox);
                            if (rayBoxLeft != null)
                            {
                                zgIsolationGraph.GraphPane.GraphObjList.Add(rayBoxLeft);
                                _overlapRayBoxes.Add(rayBoxLeft);
                            }
                        }
                        if (nextCycleRightBox != null)
                        {
                            rayBoxRight = GetOverLapRay(currentCycleCurrentBox, nextCycleRightBox);
                            if (rayBoxRight != null)
                            {
                                zgIsolationGraph.GraphPane.GraphObjList.Add(rayBoxRight);
                                _overlapRayBoxes.Add(rayBoxRight);
                            }
                        }
                        if (rayBoxLeft != null && rayBoxRight == null)
                        {
                            rayBoxLeft.Location.X1 = currentCycleCurrentBox.Location.X1;
                            rayBoxLeft.Location.Width = currentCycleCurrentBox.Location.Width;
                        }
                        else if (rayBoxRight != null && rayBoxLeft == null)
                        {
                            rayBoxRight.Location.X1 = currentCycleCurrentBox.Location.X1;
                            rayBoxRight.Location.Width = currentCycleCurrentBox.Location.Width;
                        }

                    }
                }
            }

            zgIsolationGraph.GraphPane.XAxis.Scale.Min = _smallesMz;
            zgIsolationGraph.GraphPane.XAxis.Scale.Max = _largestMz;
            zgIsolationGraph.GraphPane.YAxis.Scale.Min = Y_SCALE_MIN;
            zgIsolationGraph.GraphPane.YAxis.Scale.Max = Y_SCALE_MAX;
            zgIsolationGraph.AxisChange();
            zgIsolationGraph.Invalidate();

            //Setup check boxes and color labels
            if (usesMargins)
            {
                cbMargin.Checked = true;
            }
            else
            {
                cbMargin.Hide();
                labelMarginColor.Hide();
                int width = cbMargin.Width;
                cbShowOverlapRays.Left -= width;
                labelOverlapColor.Left -= width;
                cbShowOverlapsSingle.Left -= width;
                labelSingleOverlapColor.Left -= width;
                cbShowGaps.Left -= width;
                labelGapColor.Left -= width;
            }
            cbShowGaps.Checked = true;
            cbShowOverlapsSingle.Checked = true;
            if (overlap)
            {
                cbShowOverlapRays.Checked = true;
                labelOverlapColor.Visible = true;
            }
            else
            {
                cbShowOverlapRays.Hide();
                labelOverlapColor.Hide();
            }
            labelMarginColor.BackColor = _marginColor;
            labelWindowColor.BackColor = _windowColor;
            labelGapColor.BackColor = _gapColor;
            labelSingleOverlapColor.BackColor = _overlapColor;
            labelOverlapColor.BackColor = _overlapRayColor;
        }
Пример #12
0
        /// <summary>
        /// Create the heat map or single scan graph.
        /// </summary>
        private void CreateGraph()
        {
            if (_msDataFileScanHelper.MsDataSpectra == null)
                return;

            GraphPane.CurveList.Clear();
            GraphPane.GraphObjList.Clear();

            bool hasDriftDimension = _msDataFileScanHelper.MsDataSpectra.Length > 1;
            bool useHeatMap = hasDriftDimension && !Settings.Default.SumScansFullScan;

            filterBtn.Visible = spectrumBtn.Visible = hasDriftDimension;
            graphControl.IsEnableVPan = graphControl.IsEnableVZoom = useHeatMap;
            GraphPane.Legend.IsVisible = useHeatMap;

            if (hasDriftDimension)
            {
                // Is there actually any drift time filtering available?
                double minDriftTime, maxDriftTime;
                _msDataFileScanHelper.GetDriftRange(out minDriftTime, out maxDriftTime, ChromSource.unknown); // Get range of drift times for all products and precursors
                if ((minDriftTime == double.MinValue) && (maxDriftTime == double.MaxValue))
                {
                    filterBtn.Visible = false;
                    filterBtn.Checked = false;
                }
            }

            if (useHeatMap)
            {
                ZoomYAxis(); // Call this again now that cues are there to indicate need for drift scale
                CreateDriftTimeHeatmap();
            }
            else
            {
                CreateSingleScan();
            }

            // Add extraction boxes.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                    continue;
                var color1 = Blend(transition.Color, Color.White, 0.60);
                var color2 = Blend(transition.Color, Color.White, 0.95);
                var extractionBox = new BoxObj(
                    transition.ProductMz - transition.ExtractionWidth.Value / 2,
                    0.0,
                    transition.ExtractionWidth.Value,
                    1.0,
                    Color.Transparent,
                    transition.Color,
                    Color.White)
                {
                    Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                    ZOrder = ZOrder.F_BehindGrid,
                    Fill = new Fill(color1, color2, 90),
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(extractionBox);
            }

            // Add labels.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                    continue;
                var label = new TextObj(transition.Name, transition.ProductMz, 0.02, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Top)
                {
                    ZOrder = ZOrder.D_BehindAxis,
                    IsClippedToChartRect = true,
                    Tag = i
                };
                label.FontSpec.Border.IsVisible = false;
                label.FontSpec.FontColor = Blend(transition.Color, Color.Black, 0.30);
                label.FontSpec.IsBold = true;
                label.FontSpec.Fill = new Fill(Color.FromArgb(180, Color.White));
                GraphPane.GraphObjList.Add(label);
            }

            double retentionTime = _msDataFileScanHelper.MsDataSpectra[0].RetentionTime ?? _msDataFileScanHelper.ScanProvider.Times[_msDataFileScanHelper.ScanIndex];
            GraphPane.Title.Text = string.Format(Resources.GraphFullScan_CreateGraph__0_____1_F2__min_, _msDataFileScanHelper.FileName, retentionTime);

            FireSelectedScanChanged(retentionTime);
        }
Пример #13
0
        /// <summary>
        /// Renders the demo graph with one call.
        /// </summary>
        /// <param name="g">A <see cref="Graphics"/> object for which the drawing will be done.</param>
        /// <param name="pane">A reference to the <see cref="GraphPane"/></param>
        public static void RenderDemo( Graphics g, GraphPane pane )
        {
            // Set the titles and axis labels
            pane.Title.Text = "Wacky Widget Company\nProduction Report";
            pane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            pane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            // Use green, with circle symbols
            curve = pane.AddCurve( "Larry", x, y, Color.Green, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50 ), 90F );
            // Make it a smooth line
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            // Use a red color with triangle symbols
            curve = pane.AddCurve( "Moe", x3, y3, Color.FromArgb( 200, 55, 135 ), SymbolType.Triangle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 160, 230, 145, 205 ), 90F );
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4 = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 };
            BarItem bar = pane.AddBar( "Wheezy", x4, y4, Color.SteelBlue );
            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill( Color.RosyBrown, Color.White, Color.RosyBrown );

            // Fourth curve is a bar
            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 };
            bar = pane.AddBar( "Curly", x2, y2, Color.RoyalBlue );
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill( Color.RoyalBlue, Color.White, Color.RoyalBlue );

            // Fill the pane background with a gradient
            pane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            // Fill the axis background with a gradient
            pane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ),
                Color.FromArgb( 255, 255, 190 ), 90F );

            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            pane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            pane.BarSettings.Type = BarType.Stack;

            // Enable the X and Y axis grids
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            // Manually set the scale maximums according to user preference
            pane.XAxis.Scale.Max = 1200;
            pane.YAxis.Scale.Max = 120;

            // Add a text item to decorate the graph
            TextObj text = new TextObj( "First Prod\n21-Oct-93", 175F, 80.0F );
            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.FontSpec.StringAlignment = StringAlignment.Near;
            pane.GraphObjList.Add( text );

            // Add an arrow pointer for the above text item
            ArrowObj arrow = new ArrowObj( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            pane.GraphObjList.Add( arrow );

            // Add a another text item to to point out a graph feature
            text = new TextObj( "Upgrade", 700F, 50.0F );
            // rotate the text 90 degrees
            text.FontSpec.Angle = 90;
            // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            // Disable the border and background fill options for the text
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add( text );

            // Add an arrow pointer for the above text item
            arrow = new ArrowObj( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            pane.GraphObjList.Add( arrow );

            // Add a text "Confidential" stamp to the graph
            text = new TextObj( "Confidential", 0.85F, -0.03F );
            // use ChartFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.ChartFraction;
            // rotate the text 15 degrees
            text.FontSpec.Angle = 15.0F;
            // Text will be red, bold, and 16 point
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            // Disable the border and background fill options for the text
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;
            // Align the text such the the Left-Bottom corner is at the specified coordinates
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            pane.GraphObjList.Add( text );

            // Add a BoxObj to show a colored band behind the graph data
            BoxObj box = new BoxObj( 0, 110, 1200, 10,
                Color.Empty, Color.FromArgb( 225, 245, 225 ) );
            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            // Align the left-top of the box to (0, 110)
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            // place the box behind the axis items, so the grid is drawn on top of it
            box.ZOrder = ZOrder.D_BehindAxis;
            pane.GraphObjList.Add( box );

            // Add some text inside the above box to indicate "Peak Range"
            TextObj myText = new TextObj( "Peak Range", 1170, 105 );
            myText.Location.CoordinateFrame = CoordType.AxisXYScale;
            myText.Location.AlignH = AlignH.Right;
            myText.Location.AlignV = AlignV.Center;
            myText.FontSpec.IsItalic = true;
            myText.FontSpec.IsBold = false;
            myText.FontSpec.Fill.IsVisible = false;
            myText.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add( myText );

            pane.AxisChange( g );
        }
Пример #14
0
        private void Form2_Load(object sender, EventArgs e)
        {
            this.splitContainer2.Panel2.Enabled = false;
            this.button1.Visible = false;
            this.comboBox_CollectId.Visible = false;
            this.button_ShowHidden.Visible = false;
            GraphPane myPane = this.zedGraphControl1.GraphPane;

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 1.5;
            // Set the titles
            myPane.Title.Text = "阴极电位采集系统";
            myPane.Title.IsVisible = false;
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;
            myPane.XAxis.Title.FontSpec.Size = 12;
            myPane.YAxis.Title.FontSpec.Size = 9;

            myPane.Title.FontSpec.IsDropShadow = true;
            myPane.Title.FontSpec.DropShadowColor = Color.FromArgb(50, 0, 0, 0);
            myPane.Title.FontSpec.DropShadowOffset = 0.2f;
            myPane.XAxis.Title.Text = "采集时间";
            myPane.XAxis.Title.FontSpec.IsDropShadow = true;
            myPane.XAxis.Title.FontSpec.DropShadowColor = Color.FromArgb(50, 0, 0, 0);
            myPane.XAxis.Title.FontSpec.DropShadowOffset = 0.2f;
            myPane.YAxis.Title.Text = "采集电压";
            myPane.YAxis.Title.FontSpec.IsDropShadow = true;
            myPane.YAxis.Title.FontSpec.DropShadowColor = Color.FromArgb(50, 0, 0, 0);
            myPane.YAxis.Title.FontSpec.DropShadowOffset = 0.2f;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            // Fill the pane background with a gradient
            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Draw a box item to highlight a value range
            BoxObj box = new BoxObj(0, 1.2, 1.4, 0.4, Color.Empty,
                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.FromArgb(100, Color.FromArgb(88, 88, 88)), Color.FromArgb(200, Color.FromArgb(88, 88, 88)), 45.0F);
            // Use the BehindAxis zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.E_BehindCurves;
            // Make sure that the boxObj does not extend outside the chart rect if the chart is zoomed
            box.IsClippedToChartRect = true;
            // Use a hybrid coordinate system so the X axis always covers the full x range
            // from chart fraction 0.0 to 1.0
            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);
        }
Пример #15
0
        public PieChartDemo()
            : base("A demo showing some pie chart features of ZedGraph",
										"Pie Chart Demo", DemoType.Pie)
        {
            GraphPane myPane = base.GraphPane;

            // Set the pane title
            myPane.Title.Text = "2004 ZedGraph Sales by Region\n ($M)";

            // Enter some data values
            double [] values =   { 15, 15, 40, 20 } ;
            double [] values2 =   { 250, 50, 400, 50 } ;
            Color [] colors = { Color.Red, Color.Blue, Color.Green, Color.Yellow } ;
            double [] displacement = {	.0,.0,.0,.0 } ;
            string [] labels = { "Europe", "Pac Rim", "South America", "Africa" } ;

            // Fill the pane and axis background with solid color
            myPane.Fill = new Fill( Color.Cornsilk );
            myPane.Chart.Fill = new Fill( Color.Cornsilk );
            myPane.Legend.Position = LegendPos.Right ;

            // Create some pie slices
            PieItem segment1 = myPane.AddPieSlice ( 20, Color.Navy, .20, "North") ;
            PieItem segment2 = myPane.AddPieSlice ( 40, Color.Salmon, 0, "South") ;
            PieItem segment3 = myPane.AddPieSlice ( 30, Color.Yellow,.0, "East") ;
            PieItem segment4 = myPane.AddPieSlice ( 10.21, Color.LimeGreen, 0, "West") ;
            PieItem segment5 = myPane.AddPieSlice ( 10.5, Color.Aquamarine, .3, "Canada") ;

            // Add some more slices as an array
            PieItem [] slices = new PieItem[values2.Length] ;
            slices = myPane.AddPieSlices ( values2, labels ) ;

            // Modify the slice label types
            ((PieItem)slices[0]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[1]).LabelType = PieLabelType.Name_Value_Percent ;
            ((PieItem)slices[2]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[3]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[1]).Displacement = .2 ;
            segment1.LabelType = PieLabelType.Name_Percent ;
            segment2.LabelType = PieLabelType.Name_Value ;
            segment3.LabelType = PieLabelType.Percent ;
            segment4.LabelType = PieLabelType.Value ;
            segment5.LabelType = PieLabelType.Name_Value ;
            segment2.LabelDetail.FontSpec.FontColor = Color.Red ;

            // Sum up the values
            CurveList curves = myPane.CurveList ;
            double total = 0 ;
            for ( int x = 0 ; x <  curves.Count ; x++ )
                total += ((PieItem)curves[x]).Value ;

            // Add a text item to highlight total sales
            TextObj text = new TextObj("Total 2004 Sales - " + "$" + total.ToString () + "M", 0.85F, 0.80F,CoordType.PaneFraction );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Border.IsVisible = false ;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.FontSpec.StringAlignment = StringAlignment.Center ;
            myPane.GraphObjList.Add( text );

            // Add a colored background behind the pie
            BoxObj box = new BoxObj( 0, 0, 1, 1, Color.Empty, Color.PeachPuff );
            box.Location.CoordinateFrame = CoordType.ChartFraction;
            box.Border.IsVisible = false;
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            box.ZOrder = ZOrder.E_BehindCurves;
            myPane.GraphObjList.Add( box );

            base.ZedGraphControl.AxisChange();
        }
Пример #16
0
        /// <summary>
        /// Update vertical line the marks current import time for progressively loaded files.
        /// </summary>
        private void UpdateProgressLine(double time)
        {
            // Remove old progressive loading indicators.
            if (_unfinishedBox != null)
            {
                _graphPane.GraphObjList.Remove(_unfinishedBox);
                _graphPane.GraphObjList.Remove(_unfinishedLine);
                _unfinishedBox = null;
            }

            // If we're still loading, create a white rectangle which blocks the fill background, indicating data yet to be loaded.
            if (time < _status.Transitions.MaxRetentionTime)
            {
                _graphPane.Chart.Fill = new Fill(_backgroundGradientColor1, _backgroundGradientColor2, 45.0f);
                _unfinishedBox = new BoxObj(
                    time,
                    _graphPane.YAxis.Scale.Max,
                    _graphPane.XAxis.Scale.Max - time,
                    _graphPane.YAxis.Scale.Max - _graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder = ZOrder.F_BehindGrid
                };
                _graphPane.GraphObjList.Add(_unfinishedBox);

                // Place a vertical line after the last loaded data.
                _unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    time,
                    _graphPane.YAxis.Scale.Max,
                    time,
                    _graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder = ZOrder.D_BehindAxis
                };
                _graphPane.GraphObjList.Add(_unfinishedLine);
            }
        }
Пример #17
0
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g,
            MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
                return;

            // Calculate maximum y for potential retention time indicators
            PointF ptTop = new PointF(0, graphPane.Chart.Rect.Top);

            if (GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                if (RetentionMsMs != null)
                {
                    foreach (double retentionTime in RetentionMsMs)
                    {
                        Color color = COLOR_MSMSID_TIME;
                        if (SelectedRetentionMsMs.HasValue && Equals((float) retentionTime, (float) SelectedRetentionMsMs))
                        {
                            color = ColorSelected;
                        }
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop,
                            Resources.ChromGraphItem_AddAnnotations_ID, GraphObjType.ms_ms_id, color,
                            ScaleRetentionTime(retentionTime));
                    }
                }
                if (AlignedRetentionMsMs != null)
                {
                    foreach (var time in AlignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line = new LineObj(COLOR_ALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                               scaledTime.DisplayTime, 1)
                        {
                            ZOrder = ZOrder.F_BehindGrid,
                            Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.aligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
                if (UnalignedRetentionMsMs != null)
                {
                    foreach (var time in UnalignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line = new LineObj(COLOR_UNALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                               scaledTime.DisplayTime, 1)
                        {
                            ZOrder = ZOrder.F_BehindGrid,
                            Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.unaligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
            }

            // Draw retention time indicator, if set
            if (RetentionPrediction.HasValue)
            {
                double time = RetentionPrediction.Value;

                // Create temporary label to calculate positions
                if (GraphChromatogram.ShowRT != ShowRTChrom.none)
                {
                    AddRetentionTimeAnnotation(graphPane,
                                               g,
                                               annotations,
                                               ptTop,
                                               Resources.ChromGraphItem_AddAnnotations_Predicted,
                                               GraphObjType.predicted_rt_window,
                                               COLOR_RETENTION_TIME,
                                               ScaleRetentionTime(time));
                }

                // Draw background for retention time window
                if (RetentionWindow > 0)
                {
                    double x1 = ScaleRetentionTime(time - RetentionWindow/2).DisplayTime;
                    double x2 = ScaleRetentionTime(time + RetentionWindow/2).DisplayTime;
                    BoxObj box = new BoxObj(x1, 0, x2-x1, 1,
                                            COLOR_RETENTION_WINDOW, COLOR_RETENTION_WINDOW)
                                     {
                                         Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                                         IsClippedToChartRect = true,
                                         ZOrder = ZOrder.F_BehindGrid
                                     };
                    annotations.Add(box);
                }
            }

            if (RetentionExplicit != null && GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                // Create temporary label to calculate positions
                AddRetentionTimeAnnotation(graphPane,
                                            g,
                                            annotations,
                                            ptTop,
                                            Resources.ChromGraphItem_AddAnnotations_Explicit,
                                            GraphObjType.predicted_rt_window,
                                            COLOR_RETENTION_TIME,
                                            ScaleRetentionTime(RetentionExplicit.RetentionTime));
            }

            for (int i = 0, len = Chromatogram.NumPeaks; i < len; i++)
            {
                if (_arrayLabelIndexes[i] == -1)
                    continue;

                double maxIntensity = _intensities[_arrayLabelIndexes[i]];

                // Show peak extent indicators, if they are far enough apart
                ChromPeak peak = Chromatogram.GetPeak(i);
                AddPeakBoundaries(graphPane, annotations, false,
                                  ScaleRetentionTime(peak.StartTime), ScaleRetentionTime(peak.EndTime), maxIntensity);
            }
        }
Пример #18
0
        public void MakeWindRose(List<int> nValues)
        {
            _nValues = nValues;
            GraphPane pane = mainChart.GraphPane;
            pane.Title.Text = "Роза ветров";
            pane.IsFontsScaled = false;

            pane.CurveList.Clear();

            pane.XAxis.IsVisible = false;
            pane.YAxis.IsVisible = false;

            pane.XAxis.MajorGrid.IsVisible = false;
            pane.YAxis.MajorGrid.IsVisible = false;

            pane.YAxis.MajorGrid.IsZeroLine = false;

            // Создаем список точек
            var points = new RadarPointList {Clockwise = true};

            var text = new TextObj[8];
            var axText = new TextObj[8];
            for (int i = 0; i < 8; i++)
                points.Add(_nValues[i], 1);

            int nMax = _nValues.Concat(new[] {0}).Max();
            nMax += 1;

            for (int i = 0; i < points.Count - 1; i++)
            {
                text[i] = new TextObj(_nValues[i].ToString(), points[i].X, points[i].Y);
                text[i].FontSpec.Border.IsVisible = false;
                Color color;
                if (_nValues[i] < nMax / 3)
                    color = Color.GreenYellow;
                else
                    if (_nValues[i] < (nMax / 3) * 2)
                        color = Color.Yellow;
                    else
                        color = Color.OrangeRed;
                text[i].FontSpec.Fill = new Fill(color);
                text[i].FontSpec.IsBold = true;
                pane.GraphObjList.Add(text[i]);
            }

            // Добавляем кривую по этим четырем точкам
            LineItem myCurve = pane.AddCurve("", points, Color.Blue, SymbolType.Triangle);
            myCurve.Line.Width = 2.5F;

            // Для наглядности нарисуем расстояния от начала координат до каждой из точек
            var arrow = new LineObj[8];
            arrow[0] = new LineObj(0, 0, 0, nMax);
            arrow[1] = new LineObj(0, 0, -nMax, 0);
            arrow[2] = new LineObj(0, 0, 0, -nMax);
            arrow[3] = new LineObj(0, 0, nMax, 0);
            arrow[4] = new LineObj(0, 0, nMax, nMax);
            arrow[5] = new LineObj(0, 0, -nMax, nMax);
            arrow[6] = new LineObj(0, 0, nMax, -nMax);
            arrow[7] = new LineObj(0, 0, -nMax, -nMax);

            axText[0] = new TextObj("с", 0, nMax);
            axText[1] = new TextObj("з", -nMax, 0);
            axText[2] = new TextObj("ю", 0, -nMax);
            axText[3] = new TextObj("в", nMax, 0);
            axText[4] = new TextObj("с/в", nMax, nMax);
            axText[5] = new TextObj("с/з", -nMax, nMax);
            axText[6] = new TextObj("ю/в", nMax, -nMax);
            axText[7] = new TextObj("ю/з", -nMax, -nMax);

            for (int i = 0; i < 8; i++)
            {
                pane.GraphObjList.Add(axText[i]);
                pane.GraphObjList.Add(arrow[i]);
            }

            // Отметим начало координат черным квадратиком
            var box = new BoxObj(-0.05, 0.05, 0.1, 0.1, Color.Black, Color.Black);
            pane.GraphObjList.Add(box);

            // Устанавливаем интересующий нас интервал по оси X
            pane.XAxis.Scale.Min = -nMax;
            pane.XAxis.Scale.Max = nMax;

            // Устанавливаем интересующий нас интервал по оси Y
            pane.YAxis.Scale.Min = -nMax;
            pane.YAxis.Scale.Max = nMax;

            mainChart.AxisChange();
            mainChart.Invalidate();
        }
Пример #19
0
        /// <summary>
        /// Using ZedGraph, create a stripchart
        /// More info on Zedgraph can be found at: http://zedgraph.sourceforge.net/index.html
        /// </summary>
        void CreateStripChart()
        {
            // This is to remove all plots
            graph_.GraphPane.CurveList.Clear();

            // GraphPane object holds one or more Curve objects (or plots)
            GraphPane myPane = graph_.GraphPane;

            // Draw a box item to highlight the valid range
            BoxObj box = new BoxObj(0, 512, 30, 512, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.FromArgb(200, Color.LightGreen),
                                Color.FromArgb(200, Color.LightGreen), 45.0F);
            // Use the BehindGrid zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.F_BehindGrid;
            myPane.GraphObjList.Add(box);

            //Lables
            myPane.XAxis.Title.Text = "Time (s)";
            myPane.YAxis.Title.Text = "Output (511 = Full Scale Range)";
            myPane.Title.IsVisible = false;
            myPane.Legend.IsVisible = false;

            //Set scale
            myPane.XAxis.Scale.Max = 20; //Show 30s of data
            myPane.XAxis.Scale.Min = -10;

            //Set scale
            myPane.YAxis.Scale.Max = 768; //Valid range
            myPane.YAxis.Scale.Min = -255;

            //Make grid visible
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;

            // Refeshes the plot.
            graph_.AxisChange();
            graph_.Invalidate();
            graph_.Refresh();
        }
Пример #20
0
        private void UpdateGraph(List<Pair> PairList)
        {
            if (PairList.Count < hScrollBar.Value) return;

            list.Clear();

            double StartScan = 0;
            double StartMask = 0;
            double StartRetrigger = 0;
            double StartAWin = 0.0;
            double MaxReading = 0;

            zedGraphControl.GraphPane.GraphObjList.Clear();
            for (int i = hScrollBar.Value; i < hScrollBar.Value + WindowsSize; i++)
            {
                list.Add(PairList[i].X, PairList[i].Y);

                if (StartAWin == 0 && PairList[i].AWindow > 0)
                {
                    StartAWin = PairList[i].X;
                }

                if (StartAWin > 0 && (PairList[i].AWindow == 0 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartAWin, 50, PairList[i].X - StartAWin, 50.0, Color.Black, Color.FromArgb(64, Color.Black));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartAWin = 0;
                }

                if (PairList[i].AWindow == 2)
                {
                    ZedGraph.LineObj line = new LineObj(Color.Green, PairList[i].X, 1023, PairList[i].X, 0);
                    line.ZOrder = ZOrder.D_BehindAxis;
                    line.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(line);
                }

                if (StartScan == 0 && PairList[i].Status == 1)
                {
                    StartScan = PairList[i].X;
                }
                if (StartScan > 0 && PairList[i].Y > MaxReading) MaxReading = PairList[i].Y;
                if (StartScan > 0 && (PairList[i].Status != 1 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartScan, /*PairList[i - 1].*/MaxReading, PairList[i].X - StartScan, MaxReading, Color.Black, Color.FromArgb(64, Color.Yellow));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartScan = 0;
                    MaxReading = 0;
                }
                if (StartMask == 0 && PairList[i].Status == 2)
                {
                    StartMask = PairList[i].X;
                }

                if (StartMask > 0 && (PairList[i].Status != 2 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartMask, 100, PairList[i].X - StartMask, 100.0, Color.Black, Color.FromArgb(64, Color.Red));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartMask = 0;
                }

                if (StartRetrigger == 0 && PairList[i].Status == 3)
                {
                    StartRetrigger = PairList[i].X;
                }

                if (StartRetrigger > 0 && (PairList[i].Status != 3 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartRetrigger, 100, PairList[i].X - StartRetrigger, 100.0, Color.Black, Color.FromArgb(64, Color.Blue));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartRetrigger = 0;
                }
            }
            if ((hScrollBar.Value + WindowsSize) < PairList.Count)
            {
                zedGraphControl.GraphPane.XAxis.Scale.Max = PairList[hScrollBar.Value + WindowsSize].X;
                zedGraphControl.GraphPane.XAxis.Scale.Min = PairList[hScrollBar.Value].X;

                zedGraphControl.Invoke(new EventHandler(delegate { zedGraphControl.AxisChange(); zedGraphControl.Refresh(); }));

            }
        }
Пример #21
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="EllipseObj"/> object from
 /// which to copy</param>
 public EllipseObj(BoxObj rhs) : base(rhs)
 {
 }
Пример #22
0
        // Basic curve test - Linear Axis
        private void CreateGraph_BasicLinear( ZedGraphControl z1 )
        {
            //			Color rgb = Color.FromArgb( 123, 240, 098 );
            //			HSBColor hsb = HSBColor.FromRGB( rgb );
            //			Color rgb2 = hsb.ToRGB();

            GraphPane myPane = z1.GraphPane;
            z1.IsEnableSelection = true;
            z1.IsZoomOnMouseCenter = true;
            z1.IsEnableWheelZoom = false;

            Selection.Fill = new Fill( Color.Red );
            Selection.Line.Color = Color.Red;
            Selection.Line.DashOn = 1;
            Selection.Line.DashOff = 1;
            Selection.Line.Width = 3;

            //myTimer = new Timer();
            //myTimer.Enabled = true;
            //myTimer.Tick += new EventHandler( MyTimer_Tick );
            //myTimer.Interval = 500;
            //myTimer.Start();

            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();
            const int count = 10;

            for ( int i = 0; i < count; i++ )
            {
                double x = XDate.CalendarDateToXLDate( 2006, 4, 15, 3 + i, 0, 0 );

                double y = 300.0 * ( 1.0 + Math.Sin( (double) i * 0.2 ) );

                string tag;
                tag = "Point #" + i.ToString() + "\n" + XDate.ToString( x, "g" ) + "\n" + y.ToString() +
                    "Line 4\nLine 5\nLine 6";

                if ( i == 10 )
                    y = PointPair.Missing;
                list.Add( x, y, i / 36.0, tag );
                list2.Add( x, y + 50, ( count - i ) * 70.0 );
                list3.Add( x, y + 150, i / 36.0 );
            }
            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            LineItem myCurve2 = myPane.AddCurve( "curve2", list2, Color.Red, SymbolType.Circle );
            Fill fill = new Fill( Color.Red, Color.Yellow, Color.Blue );
            fill.RangeMin = 300;
            fill.RangeMax = 700;
            fill.Type = FillType.GradientByColorValue;
            myCurve2.Line.GradientFill = fill;
            LineItem myCurve3 = myPane.AddCurve( "curve3", list3, Color.Green, SymbolType.Square );

            myPane.IsIgnoreMissing = true;
            //myPane.XAxis.Type = AxisType.Ordinal;

            myPane.XAxis.Type = AxisType.Date;
            myPane.XAxis.Scale.BaseTic = XDate.CalendarDateToXLDate( 2006, 4, 15, 3, 0, 0 );
            myPane.XAxis.Scale.MajorStep = 1;
            myPane.XAxis.Scale.MajorUnit = DateUnit.Hour;
            //myPane.XAxis.Scale.Format

            myPane.XAxis.Scale.Min = XDate.CalendarDateToXLDate( 2006, 4, 15, 0, 0, 0 );

            //The first tic that appears on the x axis is not on the first x value with
            //Minute == 0 and Second == 0, but on the first x value at midnight (i.e.
            //Hour == 0 and Minute == 0 and Second == 0).

            //When using other values for MajorStep, the first tic is always at the fist
            //x value at midnight.

            myCurve.Symbol.Fill = new Fill( Color.White, Color.Red );
            myCurve.Symbol.Fill.Type = FillType.GradientByZ;
            myCurve.Symbol.Fill.RangeMin = 0;
            myCurve.Symbol.Fill.RangeMax = 4;
            myCurve.Symbol.Fill.RangeDefault = 0;
            myCurve.Symbol.Fill.SecondaryValueGradientColor = Color.Empty;

            for ( int i = 0; i < count; i++ )
            {
                PointPair pt = myCurve.Points[i];

                TextObj text = new TextObj( pt.Y.ToString( "f2" ), pt.X, pt.Y,
                    CoordType.AxisXYScale, AlignH.Right, AlignV.Bottom );
                text.ZOrder = ZOrder.A_InFront;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible = false;

                myPane.GraphObjList.Add( text );
            }

            foreach ( GraphObj obj in myPane.GraphObjList )
            {
                if ( obj is TextObj )
                    ( obj as TextObj ).FontSpec.Angle = 90;
            }

            z1.GraphPane.IsBoundedRanges = false;
            z1.AxisChange();

            z1.PointValueEvent += new ZedGraphControl.PointValueHandler( z1_PointValueEvent );

            box = new BoxObj( 0, 0, 1, 10, Color.Empty, Color.FromArgb( 200, Color.LightGreen ) );
            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            box.IsVisible = false;
            myPane.GraphObjList.Add( box );
        }
Пример #23
0
        /// <summary>
        /// Create a drift time heat map graph.
        /// </summary>
        private void CreateDriftTimeHeatmap()
        {
            GraphPane.YAxis.Title.Text = Resources.GraphFullScan_CreateDriftTimeHeatmap_Drift_Time__ms_;
            graphControl.IsEnableVZoom = graphControl.IsEnableVPan = true;

            if (_heatMapData == null)
            {
                var points = new List<Point3D>(5000);
                foreach (var scan in _msDataFileScanHelper.MsDataSpectra)
                {
                    if (!scan.DriftTimeMsec.HasValue)
                        continue;
                    for (int j = 0; j < scan.Mzs.Length; j++)
                        points.Add(new Point3D(scan.Mzs[j], scan.DriftTimeMsec.Value, scan.Intensities[j]));
                }
                _heatMapData = new HeatMapData(points);
            }

            double minDrift;
            double maxDrift;
            _msDataFileScanHelper.GetDriftRange(out minDrift, out maxDrift, _msDataFileScanHelper.Source);  // There may be a different drift time filter for products in Waters

            if (minDrift > 0 && maxDrift < double.MaxValue)
            {
                // Add gray shaded box behind heat points.
                var driftTimeBox = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.Transparent,
                    Color.FromArgb(50, Color.Gray))
                {
                    Location = {CoordinateFrame = CoordType.XChartFractionYScale},
                    ZOrder = ZOrder.F_BehindGrid,
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(driftTimeBox);

                // Add outline in front of heat points, so you can tell where the limits are in a dense graph.
                var driftTimeOutline = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.FromArgb(50, Color.DarkViolet),
                    Color.Transparent)
                {
                    Location = {CoordinateFrame = CoordType.XChartFractionYScale},
                    ZOrder = ZOrder.C_BehindChartBorder,
                    IsClippedToChartRect = true,
                    Border = new Border(Color.FromArgb(100, Color.DarkViolet), 2)
                };
                GraphPane.GraphObjList.Add(driftTimeOutline);
            }

            if (!Settings.Default.FilterDriftTimesFullScan)
            {
                minDrift = 0;
                maxDrift = double.MaxValue;
            }
            var heatMapGraphPane = (HeatMapGraphPane)GraphPane;
            heatMapGraphPane.SetPoints(_heatMapData, minDrift, maxDrift);
        }
Пример #24
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            PaneBase tmpPane = myPane;
            if ( master != null )
                tmpPane = master;
            tmpPane.GetImage( 400, 300, 72 ).Save( myPane.Title.Text + ".png", ImageFormat.Png );

            //image.Save( @"c:\zedgraph.png", ImageFormat.Png );
            //master.Image.Save( @"c:\zedgraph.png", ImageFormat.Png );
            return;

            Serialize( myPane, @"c:\temp\myZedGraphFile" );
            //DeSerialize( out master );
            return;

            object obj;
            int index;
            PointF mousePt = new PointF( e.X, e.Y );
            //if ( myPane.FindNearestObject( mousePt, this.CreateGraphics(), out obj, out index ) &&
            //		obj is GraphPane )
            {
                if ( isFirst )
                {
                    startPt = mousePt;
                    isFirst = false;
                }
                else
                {
                    double x1, x2, x3, x4, y1, y2, y3, y4;
                    myPane.ReverseTransform( startPt, out x1, out x3, out y1, out y3 );
                    myPane.ReverseTransform( mousePt, out x2, out x4, out y2, out y4 );
                    double width = Math.Abs( x1 - x2 );
                    double height = Math.Abs( y1 - y2 );
                    x1 = Math.Min( x1, x2 );
                    y1 = Math.Max( y1, y2 );

                    BoxObj box = new BoxObj( x1, y1, width, height, Color.Red, Color.Red );
                    myPane.GraphObjList.Add( box );
                    isFirst = true;
                    Invalidate();
                }
            }
            //DoAddPoints();
            return;

            //DoPrint();
            //DoPageSetup();
            //DoPrintPreview();
            //return;

            //Serialize( master );
            //DeSerialize( out master );

            if ( myPane.FindNearestObject( new PointF( e.X, e.Y ), this.CreateGraphics(), out obj, out index ) )
                MessageBox.Show( obj.ToString() + " index=" + index );
            else
                MessageBox.Show( "No Object Found" );

            return;

            //myPane.XAxis.PickScale( 250, 900, myPane, this.CreateGraphics(), myPane.CalcScaleFactor() );
            //Invalidate();

            //showTicks = true;
            //Invalidate();

            CurveItem curve;
            int		iPt;
            if ( myPane.FindNearestPoint( new PointF( e.X, e.Y ), out curve, out iPt ) )
            {
                MessageBox.Show( curve.Label + ": " + curve[iPt].ToString() );
            }
            /*
                myText.Text = String.Format( "_label = {0}  X = {1}",
                    curve.Label, curve.Points[iPt].ToString("e2") );
            else
                myText.Text = "none";
            */
            //DoPrint();
            CopyToPNG( master );

            //Bitmap image = myPane.ScaledImage( 3000, 2400, 600 );
            //image.Save( @"c:\zedgraph.jpg", ImageFormat.Jpeg );

            //MultiImage( myPane, myPane2 );

            /*
            myPane.Legend.Position = LegendPos.Float;
            myPane.Legend.Location.CoordinateFrame = CoordType.PaneFraction;
            myPane.Legend.Location.AlignH = AlignH.Right;
            myPane.Legend.Location.AlignV = AlignV.Bottom;
            myPane.AxisChange( this.CreateGraphics() );

            this.Refresh();
            for ( float j=0; j<100; j++ )
            {
                for ( int k=0; k<1000000; k++ );
                myPane.Legend.Location.X = j / 100F;
                myPane.Legend.Location.Y = j / 100F;
                this.Refresh();
            }
            */

            /*
            const int NUMITER = 100;
            long junk = Environment.TickCount;
            for ( int i=0; i<NUMITER; i++ )
                this.Refresh();
            junk = Environment.TickCount - junk;

            MessageBox.Show( "Time = " + (double) junk / (double) NUMITER + " ms/refresh" );
            */

            //myPane.XAxis.TitleFontSpec.Angle += 90;
            //myPane.YAxis.TitleFontSpec.Angle += 90;
            //myPane.Y2Axis.TitleFontSpec.Angle += 90;
            //myPane.AxisChange( this.CreateGraphics() );
            //Invalidate();

            //myPane.IsIgnoreMissing = !myPane.IsIgnoreMissing;
            //			Invalidate();

            //myPane.Image.Save( @"c:\zedgraph.gif", ImageFormat.Gif );

            //myPane.XAxis.Min = 5;
            //myPane.XAxis.Max = 20;

            CopyToPNG( myPane );

            /*
                        RectangleF tmpRect = myPane.ChartRect;
                        tmpRect.Inflate( -50, -50 );
                        myPane.ChartRect = tmpRect;
                        myPane.AxisChange();
                        Invalidate();
            */

            /*
                                    CurveItem curve;
                                    int	iPt;

                                    if ( myPane.FindNearestPoint( new PointF( e.X, e.Y ), out curve, out iPt ) )
                                        MessageBox.Show( String.Format( "_label = {0}  X = {1}",
                                            curve.Label, curve.Points[iPt].ToString("e2") ) );
                                    else
                                        MessageBox.Show( "No Point Found" );
            */

            /*
                        double x, y, y2;

                        if ( nPts < 100 && myPane.ChartRect.Contains( e.X, e.Y ) )
                        {
                            this.myPane.ReverseTransform( new PointF( e.X, e.Y ), out x, out y, out y2 );
                            gx[nPts] = x;
                            gy[nPts] = y;
                            nPts++;
                            this.myPane.CurveList[0].X = gx;
                            this.myPane.CurveList[0].Y = gy;
                            this.myPane.AxisChange();
                            Invalidate();
                        }
                        //MessageBox.Show( "x=" + x.ToString() + "  y=" + y.ToString() + " y2=" + y2.ToString() );
            */

            //CopyToGif( myPane );
            //CopyToEMF( myPane );
        }
Пример #25
0
 /// <summary>
 /// Add the <see cref="ZedGraphWebGraphObj" /> objects defined in the webcontrol to
 /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects.
 /// </summary>
 /// <param name="g">The <see cref="Graphics" /> instance of interest.</param>
 /// <param name="pane">The <see cref="GraphPane" /> object to receive the
 /// <see cref="GraphObj" /> objects.</param>
 protected void AddWebGraphItems( Graphics g, GraphPane pane )
 {
     try
     {
         ZedGraphWebGraphObj draw;
         for ( int i = 0; i < GraphObjList.Count; i++ )
         {
             draw = GraphObjList[i];
             if ( draw is ZedGraphWebTextObj )
             {
                 ZedGraphWebTextObj item = (ZedGraphWebTextObj)draw;
                 TextObj x = new TextObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebArrowObj )
             {
                 ZedGraphWebArrowObj item = (ZedGraphWebArrowObj)draw;
                 ArrowObj x = new ArrowObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebImageObj )
             {
                 ZedGraphWebImageObj item = (ZedGraphWebImageObj)draw;
                 ImageObj x = new ImageObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebBoxObj )
             {
                 ZedGraphWebBoxObj item = (ZedGraphWebBoxObj)draw;
                 BoxObj x = new BoxObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebEllipseObj )
             {
                 ZedGraphWebEllipseObj item = (ZedGraphWebEllipseObj)draw;
                 EllipseObj x = new EllipseObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
         }
     }
     catch ( Exception )
     {
     }
 }
Пример #26
0
 // Call this method from the Form_Load method, passing your ZedGraphControl
 public void CreateGraph_LineWithBandDemo( ZedGraphControl zgc )
 {
     GraphPane myPane = zgc.GraphPane;
     // Set the title and axis labels
     myPane.Title.Text = "Line Graph with Band Demo";
     myPane.XAxis.Title.Text = "Sequence";
     myPane.YAxis.Title.Text = "Temperature, C";
     // Enter some random data values
     double[] y = { 100, 115, 75, 22, 98, 40, 10 };
     double[] y2 = { 90, 100, 95, 35, 80, 35, 35 };
     double[] y3 = { 80, 110, 65, 15, 54, 67, 18 };
     double[] x = { 100, 200, 300, 400, 500, 600, 700 };
     // Fill the axis background with a color gradient
     myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ), Color.FromArgb( 255, 255, 190 ), 90F );
     // Generate a red curve with "Curve 1" in the legend
     LineItem myCurve = myPane.AddCurve( "Curve 1", x, y, Color.Red );
     // Make the symbols opaque by filling them with white
     myCurve.Symbol.Fill = new Fill( Color.White );
     // Generate a blue curve with "Curve 2" in the legend
     myCurve = myPane.AddCurve( "Curve 2", x, y2, Color.Blue );
     // Make the symbols opaque by filling them with white
     myCurve.Symbol.Fill = new Fill( Color.White );
     // Generate a green curve with "Curve 3" in the legend
     myCurve = myPane.AddCurve( "Curve 3", x, y3, Color.Green );
     // Make the symbols opaque by filling them with white
     myCurve.Symbol.Fill = new Fill( Color.White );
     // Manually set the x axis range
     myPane.XAxis.Scale.Min = 0;
     myPane.XAxis.Scale.Max = 800;
     // Display the Y axis grid lines
     myPane.YAxis.MajorGrid.IsVisible = true;
     myPane.YAxis.MinorGrid.IsVisible = true;
     // Draw a box item to highlight a value range
     BoxObj box = new BoxObj( 0, 100, 1, 30, Color.Empty,
             Color.FromArgb( 150, Color.LightGreen ) );
     box.Fill = new Fill( Color.White, Color.FromArgb( 200, Color.LightGreen ), 45.0F );
     // Use the BehindAxis zorder to draw the highlight beneath the grid lines
     box.ZOrder = ZOrder.E_BehindCurves;
     // Make sure that the boxObj does not extend outside the chart rect if the chart is zoomed
     box.IsClippedToChartRect = true;
     // Use a hybrid coordinate system so the X axis always covers the full x range
     // from chart fraction 0.0 to 1.0
     box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
     myPane.GraphObjList.Add( box );
     // Add a text item to label the highlighted range
     TextObj text = new TextObj( "Optimal\nRange", 0.95f, 85, CoordType.AxisXYScale,
                             AlignH.Right, AlignV.Center );
     text.FontSpec.Fill.IsVisible = false;
     text.FontSpec.Border.IsVisible = false;
     text.FontSpec.IsBold = true;
     text.FontSpec.IsItalic = true;
     text.Location.CoordinateFrame = CoordType.XChartFractionYScale;
     text.IsClippedToChartRect = true;
     myPane.GraphObjList.Add( text );
     // Fill the pane background with a gradient
     myPane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
     zgc.IsAntiAlias = true;
     // Calculate the Axis Scale Ranges
     zgc.AxisChange();
     zgc.GraphPane = new GraphPane( zgc.GraphPane );
     zgc.AxisChange();
 }
Пример #27
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="BoxObj"/> object from which to copy</param>
 public BoxObj(BoxObj rhs) : base(rhs)
 {
     this.Border = rhs.Border.Clone();
     this.Fill   = rhs.Fill.Clone();
 }
Пример #28
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="EllipseObj"/> object from
 /// which to copy</param>
 public EllipseObj( BoxObj rhs )
     : base(rhs)
 {
 }
 private void checkOverlaps(GraphObj current, GraphObj next)
 {
     if (current.Location.X2 > next.Location.X1)
     {
         double overlapWidth = current.Location.X2 - next.Location.X1;
         BoxObj overlapBox1 = new BoxObj(next.Location.X1, Math.Floor(current.Location.Y), overlapWidth, 1, _overlapColor, _overlapColor)
         {
             IsClippedToChartRect = true
         };
         zgIsolationGraph.GraphPane.GraphObjList.Add(overlapBox1);
         _overlapBoxes.Add(overlapBox1);
     }
 }
Пример #30
0
        private void HighlightGraphs(double x, double z)
        {
            if (_doesShowHover)
            {
                for (int i = 0; i < zedGraphControl1.MasterPane.PaneList.Count; i++)
                {
                    GraphPane gp = zedGraphControl1.MasterPane.PaneList[i];
                    if (_htBoxes.Contains(gp.Title.Text))
                    {
                        BoxObj boxForLabel = (BoxObj)_htBoxes[gp.Title];
                        gp.GraphObjList.Clear();

                        boxForLabel = new BoxObj(x, gp.YAxis.Scale.Max, z, gp.YAxis.Scale.Max - gp.YAxis.Scale.Min, Color.Black, Color.PapayaWhip);
                        boxForLabel.Location.CoordinateFrame = CoordType.AxisXYScale;
                        boxForLabel.Border.Style = System.Drawing.Drawing2D.DashStyle.DashDot;

                        //// place the box behind the axis items, so the grid is drawn on top of it
                        boxForLabel.ZOrder = ZOrder.F_BehindGrid;
                        _htBoxes[gp.Title] = boxForLabel;
                        gp.GraphObjList.Add(boxForLabel);
                    }
                }
                zedGraphControl1.AxisChange();
                this.Refresh();
            }
        }
Пример #31
0
        private void CreateGraph_LineColorGradient2( ZedGraphControl zgc )
        {
            GraphPane myPane = zgc.GraphPane;

            PointPairList list = new PointPairList();
            const int count = 30;

            for ( int i = 0; i < count; i++ )
            {
                // Use an ordinary sine function to generate the curve
                double x = i + 1;
                double y = 5 * Math.Sin( (double) i * Math.PI * 3 / count ) + 5.0;

                // Set the Z value to be 2.0 if y is between 4 and 6, otherwise, it's 1.0
                list.Add( x, y, y > 4 && y < 6 ? 2.0 : 1.0 );
            }

            // Create a curve with symbols only
            LineItem myCurve = myPane.AddCurve( "Test Curve", list, Color.Red, SymbolType.Diamond );
            myCurve.Line.IsVisible = false;
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Create a second curve, with lots of extra points
            const int count2 = 1000;
            PointPairList list2 = new PointPairList();
            // Points are equal-spaced, across all the X range
            double dx = ( list[list.Count - 1].X - list[0].X ) / (double) count2;

            // Calculate the extra points values using linear interpolation
            for ( int i = 0; i <= count2; i++ )
            {
                double x2 = list[0].X + dx * (double) i;
                double y2 = list.InterpolateX( x2 );

                list2.Add( x2, y2, y2 > 4 && y2 < 6 ? 2.0 : 1.0 );
            }

            // Add the second curve with no symbols
            LineItem myCurve2 = myPane.AddCurve( "Curve2", list2, Color.Blue, SymbolType.None );

            // use a gradient fill to color the each line segment according to its Z value
            // Color will be blue for Z = 2, and red for Z = 1
            Fill fill = new Fill( Color.Red, Color.Blue );
            fill.RangeMin = 1;
            fill.RangeMax = 2;
            fill.Type = FillType.GradientByZ;
            myCurve2.Line.GradientFill = fill;
            // make the line fat
            myCurve2.Line.Width = 2.0f;

            // Create a band of green to show the highlighted region
            BoxObj box = new BoxObj( 0.0, 6.0, 1.0, 2.0, Color.Empty,
                    Color.FromArgb( 150, Color.LightGreen ) );
            // Use CoordType.XChartFractionYScale, so that Y values are regular scale values, and
            // X values are chart fraction, ranging from 0 to 1
            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            box.Fill = new Fill( Color.White, Color.FromArgb( 200, Color.LightGreen ), 45.0F );
            box.ZOrder = ZOrder.F_BehindGrid;
            box.IsClippedToChartRect = true;
            myPane.GraphObjList.Add( box );

            // Pretty it up
            myPane.Title.Text = "Line Segments Colored by Value\nExtra Points Are Interpolated";
            myPane.Title.FontSpec.Size = 18;
            myPane.XAxis.Title.Text = "Time, seconds";
            myPane.YAxis.Title.Text = "Potential, volts";
            myPane.Legend.IsVisible = false;
            myPane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ),
               Color.FromArgb( 255, 255, 190 ), 90F );
            zgc.IsAntiAlias = true;

            zgc.AxisChange();
        }
Пример #32
0
        private void Form2_Load(object sender, EventArgs e)
        {
            GraphPane myPane = this.zedGraphControl1.GraphPane;
            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 1.5;
            // Set the titles
            myPane.Title.Text = "阴极电位保护系统";
            myPane.XAxis.Title.Text = "里程";
            myPane.YAxis.Title.Text = "电压";
            myPane.Title.IsVisible = false;
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;
            myPane.Title.FontSpec.GetFont(1111);
            myPane.XAxis.Title.FontSpec.Size = 12;
            myPane.YAxis.Title.FontSpec.Size = 12;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            // Fill the pane background with a gradient
            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Draw a box item to highlight a value range
            BoxObj box = new BoxObj(0, 1.2, 1.4, 0.4, Color.Empty,
                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.FromArgb(100, Color.FromArgb(88,88, 88)), Color.FromArgb(200, Color.FromArgb(88, 88, 88)), 45.0F);
            // Use the BehindAxis zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.E_BehindCurves;
            // Make sure that the boxObj does not extend outside the chart rect if the chart is zoomed
            box.IsClippedToChartRect = true;
            // Use a hybrid coordinate system so the X axis always covers the full x range
            // from chart fraction 0.0 to 1.0
            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);
               //GraphPane myPane=this.zedGraphControl1.GraphPane;
               //myPane.Title.Text = "阴极保护";
               //myPane.XAxis.Title.Text = "X轴";

               //LineItem item= myPane.AddCurve("line",null, new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, Color.Black,SymbolType.Circle);
               ////item.Line.Width = 1;
               ////item.Line.Fill = new Fill(Color.White, Color.Red, 45F);
               ////item.Symbol.Size = 20;
               ////item.Symbol.Fill = new Fill(Color.Red);
               //myPane.Chart.Fill = new Fill(Color.Blue);

               //this.zedGraphControl1.AxisChange();

               // Get a reference to the GraphPane
               //GraphPane myPane = this.zedGraphControl1.GraphPane;

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

               //// Make up some random data points
               //double x, y;
               //PointPairList list = new PointPairList();
               //for (int i = 0; i < 360; i++)
               //{
               //    x = (double)new XDate(1995, 5,5,1,1, i + 11);
               //    y = Math.Sin((double)i * Math.PI / 15.0+1.5);
               //    list.Add(x, y);
               //}

               //// Generate a red curve with diamond
               //// symbols, and "My Curve" in the legend
               //CurveItem myCurve = myPane.AddCurve("My Curve",
               //      list, Color.Red, SymbolType.Diamond);

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

               //// Tell ZedGraph to refigure the axes since the data
               //// have changed
               //this.zedGraphControl1.AxisChange();
        }