/// <summary> /// Constructs a new instance of the HistogramView. /// </summary> /// public HistogramView() { InitializeComponent(); this.histogram = new Histogram(); graphBars = new ZedGraph.BarItem(String.Empty); graphBars.Color = Color.DarkBlue; zedGraphControl.GraphPane.Title.FontSpec.IsBold = true; zedGraphControl.GraphPane.Title.FontSpec.Size = 32f; zedGraphControl.GraphPane.Title.IsVisible = true; zedGraphControl.GraphPane.XAxis.Type = AxisType.Text; zedGraphControl.GraphPane.XAxis.Title.IsVisible = false; zedGraphControl.GraphPane.XAxis.MinSpace = 0; zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = false; zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false; zedGraphControl.GraphPane.XAxis.MajorTic.IsBetweenLabels = true; zedGraphControl.GraphPane.XAxis.MajorTic.IsInside = false; zedGraphControl.GraphPane.XAxis.MajorTic.IsOpposite = false; zedGraphControl.GraphPane.XAxis.MinorTic.IsAllTics = false; zedGraphControl.GraphPane.XAxis.Scale.FontSpec.IsBold = true; zedGraphControl.GraphPane.XAxis.Scale.FontSpec.IsAntiAlias = true; zedGraphControl.GraphPane.YAxis.MinorTic.IsAllTics = false; zedGraphControl.GraphPane.YAxis.MajorTic.IsOpposite = false; zedGraphControl.GraphPane.YAxis.Title.Text = "Frequency"; zedGraphControl.GraphPane.YAxis.Title.FontSpec.Size = 24f; zedGraphControl.GraphPane.YAxis.Title.FontSpec.IsBold = true; zedGraphControl.GraphPane.Border.IsVisible = false; zedGraphControl.GraphPane.BarSettings.MinBarGap = 0; zedGraphControl.GraphPane.BarSettings.MinClusterGap = 0; zedGraphControl.GraphPane.CurveList.Add(graphBars); }
public void CreateErrorChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the title and axis labels myPane.Title.Text = "Errors Found In the PCAP"; myPane.XAxis.Title.Text = "Stream ID"; myPane.YAxis.Title.Text = "Error Count"; // create the curves BarItem[] bars = new BarItem[_errorTotals.Length]; for(int i=0;i!=_errorTotals.Length;i++) { bars[i] = myPane.AddBar(i.ToString(), _errorTotals[i], Color.Bisque); } //BarItem myCurve = myPane.AddBar("curve 1", list, Color.Blue); //BarItem myCurve2 = myPane.AddBar("curve 2", list2, Color.Red); //BarItem myCurve3 = myPane.AddBar("curve 3", list3, Color.Green); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F); zgc.AxisChange(); // expand the range of the Y axis slightly to accommodate the labels myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep; // Create TextObj's to provide labels for each bar BarItem.CreateBarLabels(myPane, false, "f0"); }
private void CreateGraph(ZedGraphControl zgc) { GraphPane pane = zgc.GraphPane; pane.Chart.Fill = new ZedGraph.Fill(System.Drawing.Color.WhiteSmoke); pane.CurveList.Clear(); // temp -12월 , 올해 검색 DataTable get_data = Data.DB_con.GetTable(@"SELECT month,COUNT(Book_ID) AS count FROM temp_month AS A left OUTER join books_history AS B ON A.month = month(B.Rental_Date) AND YEAR(B.rental_date) >= YEAR(NOW()) AND YEAR(B.rental_date) < YEAR(NOW())+1 Group BY month"); int itemscount = get_data.Rows.Count; string[] labels = new string[itemscount]; double[] YValues1 = new double[itemscount]; double[] XValues = new double[itemscount]; for (int i = 0; i < get_data.Rows.Count; i++) { object label = grid_month.FindName($"month_{i+1}"); ((System.Windows.Controls.Label)label).Content = get_data.Rows[i]["count"]; //labels[i] = $"{System.DateTime.Now.Year.ToString()} - {get_data.Rows[i]["month"]}"; labels[i] = $"{get_data.Rows[i]["month"]}"; XValues[i] = Convert.ToDouble(get_data.Rows[i]["count"]); } pane.XAxis.Type = AxisType.Text; pane.XAxis.MajorTic.IsBetweenLabels = true; pane.XAxis.Scale.TextLabels = labels; ZedGraph.BarItem myBar = pane.AddBar("Step", null, XValues, System.Drawing.Color.AliceBlue); myBar.Bar.Fill = new ZedGraph.Fill(System.Drawing.Color.YellowGreen); pane.BarSettings.Type = ZedGraph.BarType.Cluster; pane.BarSettings.MinBarGap = 0.0f; // 옆 막대 와 거리 pane.BarSettings.MinClusterGap = 1.0f; // 각 그래프 사이 거리 zgc.AxisChange(); zgc.Invalidate(); }
private void LoadData() { DataAccess.Libs.ClearAnalysisDataCache(myData); myData.LoadData(); pricePane.myGraphObj.myOnViewportChanged += new Charts.Controls.myGraphControl.OnViewportChanged(this.Chart_OnViewportChanged); volumePanel.myGraphObj.myOnViewportChanged += new Charts.Controls.myGraphControl.OnViewportChanged(this.Chart_OnViewportChanged); pricePane.myGraphObj.myOnPointValue += new Charts.Controls.myGraphControl.OnPointValue(PointValueEventPrice); volumePanel.myGraphObj.myOnPointValue += new Charts.Controls.myGraphControl.OnPointValue(PointValueEventPrice); pricePane.myGraphObj.myGraphPane.CurveList.Clear(); pricePane.myGraphObj.SetSeriesX(myData.DateTime.Values, Charts.AxisType.DateAsOrdinal); switch (cbChartType.myValue) { case AppTypes.ChartTypes.CandleStick: candleCurve = pricePane.myGraphObj.AddCandleStick(myData.DataStockCode, myData.High.Values, myData.Low.Values, myData.Open.Values, myData.Close.Values, myData.Volume.Values, commonClass.Settings.sysChartBarUpColor, commonClass.Settings.sysChartBarDnColor, commonClass.Settings.sysChartBullCandleColor, commonClass.Settings.sysChartBearCandleColor); break; case AppTypes.ChartTypes.Line: lineCurve = pricePane.myGraphObj.AddCurveLine(myData.DataStockCode, myData.Close.Values, SymbolType.Circle, Color.Blue, 1); break; case AppTypes.ChartTypes.Bar: barCurve = pricePane.myGraphObj.AddCurveBar(myData.DataStockCode, myData.Close.Values, Color.Blue, Color.Blue, 1); break; } pricePane.myGraphObj.SetFont(14); pricePane.myGraphObj.DefaultViewport(); pricePane.myGraphObj.UpdateChart(); volumePanel.myGraphObj.myGraphPane.CurveList.Clear(); volumePanel.myGraphObj.SetSeriesX(myData.DateTime.Values, Charts.AxisType.DateAsOrdinal); barCurve = volumePanel.myGraphObj.AddCurveBar(myData.DataStockCode, myData.Volume.Values, Color.Navy, Color.Green, 1); volumePanel.myGraphObj.SetFont(14); volumePanel.myGraphObj.DefaultViewport(); volumePanel.myGraphObj.UpdateChart(); }
/// <summary> /// Add a bar type curve (<see cref="CurveItem"/> object) to the plot with /// the given data points (double arrays) and properties. /// This is simplified way to add curves without knowledge of the /// <see cref="CurveList"/> class. An alternative is to use /// the <see cref="ZedGraph.CurveList" /> Add() method. /// </summary> /// <param name="label">The text label (string) for the curve that will be /// used as a <see cref="Legend"/> entry.</param> /// <param name="x">An array of double precision X values (the /// independent values) that define the curve.</param> /// <param name="y">An array of double precision Y values (the /// dependent values) that define the curve.</param> /// <param name="color">The color to used for the bars</param> /// <returns>A <see cref="CurveItem"/> class for the newly created bar curve. /// This can then be used to access all of the curve properties that /// are not defined as arguments to the /// <see cref="AddBar(string,double[],double[],Color)"/> method.</returns> public BarItem AddBar( string label, double[] x, double[] y, Color color ) { BarItem curve = new BarItem( label, x, y, color ); _curveList.Add( curve ); return curve; }
/// <summary> /// Add a bar type curve (<see cref="CurveItem"/> object) to the plot with /// the given data points (<see cref="IPointList"/>) and properties. /// This is simplified way to add curves without knowledge of the /// <see cref="CurveList"/> class. An alternative is to use /// the <see cref="ZedGraph.CurveList" /> Add() method. /// </summary> /// <param name="label">The text label (string) for the curve that will be /// used as a <see cref="Legend"/> entry.</param> /// <param name="points">A <see cref="IPointList"/> of double precision value pairs that define /// the X and Y values for this curve</param> /// <param name="color">The color to used to fill the bars</param> /// <returns>A <see cref="CurveItem"/> class for the newly created bar curve. /// This can then be used to access all of the curve properties that /// are not defined as arguments to the /// <see cref="AddBar(string,IPointList,Color)"/> method.</returns> public BarItem AddBar( string label, IPointList points, Color color ) { BarItem curve = new BarItem( label, points, color ); _curveList.Add( curve ); return curve; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="BarItem"/> object from which to copy</param> public BarItem(BarItem rhs) : base(rhs) { //bar = new Bar( rhs.Bar ); _bar = rhs._bar.Clone(); }
/// <summary> /// Find the ordinal position of the specified <see cref="BarItem" /> within /// the <see cref="CurveList" />. This position only counts <see cef="BarItem" /> /// types, ignoring all other types. /// </summary> /// <param name="pane">The <see cref="GraphPane" /> of interest</param> /// <param name="barItem">The <see cref="BarItem" /> for which to search.</param> /// <returns>The ordinal position of the specified bar, or -1 if the bar /// was not found.</returns> public int GetBarItemPos( GraphPane pane, BarItem barItem ) { if ( pane._barSettings.Type == BarType.Overlay || pane._barSettings.Type == BarType.Stack || pane._barSettings.Type == BarType.PercentStack) return 0; int i = 0; foreach ( CurveItem curve in this ) { if ( curve == barItem ) return i; else if ( curve is BarItem ) i++; } return -1; }
private void InitializeSpectrumAnalyzerGraph() { #if CALLSTACK Console.WriteLine("CALLSTACK:InitializeSpectrumAnalyzerGraph"); #endif m_tabSpectrumAnalyzer.Controls.Add(m_GraphSpectrumAnalyzer); m_GraphSpectrumAnalyzer.EditButtons = System.Windows.Forms.MouseButtons.Left; m_GraphSpectrumAnalyzer.IsAntiAlias = true; m_GraphSpectrumAnalyzer.IsEnableSelection = true; m_GraphSpectrumAnalyzer.Location = new System.Drawing.Point(8, 257); m_GraphSpectrumAnalyzer.Name = "zedSpectrumAnalyzer"; m_GraphSpectrumAnalyzer.PanModifierKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.None))); m_GraphSpectrumAnalyzer.ScrollGrace = 0D; m_GraphSpectrumAnalyzer.ScrollMaxX = 0D; m_GraphSpectrumAnalyzer.ScrollMaxY = 0D; m_GraphSpectrumAnalyzer.ScrollMaxY2 = 0D; m_GraphSpectrumAnalyzer.ScrollMinX = 0D; m_GraphSpectrumAnalyzer.ScrollMinY = 0D; m_GraphSpectrumAnalyzer.ScrollMinY2 = 0D; m_GraphSpectrumAnalyzer.Size = new System.Drawing.Size(123, 54); m_GraphSpectrumAnalyzer.TabIndex = 49; m_GraphSpectrumAnalyzer.TabStop = false; m_GraphSpectrumAnalyzer.UseExtendedPrintDialog = true; m_GraphSpectrumAnalyzer.Visible = false; m_GraphSpectrumAnalyzer.ContextMenuBuilder += new ZedGraph.ZedGraphControl.ContextMenuBuilderEventHandler(this.objGraph_ContextMenuBuilder); m_GraphSpectrumAnalyzer.ZoomEvent += new ZedGraph.ZedGraphControl.ZoomEventHandler(this.zedSpectrumAnalyzer_ZoomEvent); // Get a reference to the GraphPane instance in the ZedGraphControl GraphPane myPane = m_GraphSpectrumAnalyzer.GraphPane; m_PointList_Realtime = new PointPairList(); m_PointList_Max = new PointPairList(); m_PointList_MaxHold = new PointPairList(); m_PointList_Min = new PointPairList(); m_PointList_Avg = new PointPairList(); m_LimitLineMax = new LimitLine(); m_LimitLineMin = new LimitLine(); m_LimitLineOverload = new LimitLine(); m_GraphLimitLineMax = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Limit Max", m_LimitLineMax, Color.Magenta, SymbolType.Circle); m_GraphLimitLineMax.Line.Width = 1; m_GraphLimitLineMin = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Limit Min", m_LimitLineMin, Color.DarkMagenta, SymbolType.Circle); m_GraphLimitLineMin.Line.Width = 1; m_GraphLimitLineOverload = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Overload", m_LimitLineOverload, Color.DarkRed, SymbolType.None); m_GraphLimitLineOverload.Line.Style=DashStyle.DashDot; m_GraphLimitLineOverload.Line.Width = 1; m_MaxBar = m_GraphSpectrumAnalyzer.GraphPane.AddHiLowBar("Max", m_PointList_Max, Color.Red); m_MaxBar.Bar.Border.Color = Color.DarkRed; m_MaxBar.Bar.Border.Width = 3; m_GraphLine_Realtime = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Realtime", m_PointList_Realtime, m_Markers.m_arrCurveColors[(int)RFExplorerSignalType.Realtime], SymbolType.None); m_GraphLine_Realtime.Line.Width = 4; m_GraphLine_Realtime.Line.SmoothTension = 0.2F; m_GraphLine_Min = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Min", m_PointList_Min, m_Markers.m_arrCurveColors[(int)RFExplorerSignalType.Min], SymbolType.None); m_GraphLine_Min.Line.Width = 3; m_GraphLine_Min.Line.SmoothTension = 0.3F; m_GraphLine_Min.Line.Fill = new Fill(Color.DarkGreen, Color.LightGreen, 90); m_GraphLine_Avg = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Avg", m_PointList_Avg, m_Markers.m_arrCurveColors[(int)RFExplorerSignalType.Average], SymbolType.None); m_GraphLine_Avg.Line.Width = 3; m_GraphLine_Avg.Line.SmoothTension = 0.3F; m_GraphLine_Avg.Line.Fill = new Fill(Color.Brown, Color.Salmon, 90); m_GraphLine_Max = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Max", m_PointList_Max, m_Markers.m_arrCurveColors[(int)RFExplorerSignalType.MaxPeak], SymbolType.None); m_GraphLine_Max.Line.Width = 3; m_GraphLine_Max.Line.SmoothTension = 0.3F; m_GraphLine_Max.Line.Fill = new Fill(Color.Red, Color.Salmon, 90); m_GraphLine_MaxHold = m_GraphSpectrumAnalyzer.GraphPane.AddCurve("Max Hold", m_PointList_MaxHold, m_Markers.m_arrCurveColors[(int)RFExplorerSignalType.MaxHold], SymbolType.None); m_GraphLine_MaxHold.Line.Width = 6; m_GraphLine_MaxHold.Line.SmoothTension = 0.3F; m_GraphLine_MaxHold.Line.Fill = new Fill(Color.Salmon, Color.LightSalmon, 90); foreach (CurveItem objCurve in m_GraphSpectrumAnalyzer.GraphPane.CurveList) { objCurve.IsVisible = false; objCurve.Label.IsVisible = false; } //Define button bar m_arrAnalyzerButtonList[0] = btnAutoscale; m_arrAnalyzerButtonList[1] = btnTop5plus; m_arrAnalyzerButtonList[2] = btnTop5minus; m_arrAnalyzerButtonList[3] = btnMoveFreqDecLarge; m_arrAnalyzerButtonList[4] = btnMoveFreqDecSmall; m_arrAnalyzerButtonList[5] = btnSpanInc; m_arrAnalyzerButtonList[6] = btnSpanMax; m_arrAnalyzerButtonList[7] = btnSpanDefault; m_arrAnalyzerButtonList[8] = btnCenterMark; m_arrAnalyzerButtonList[9] = btnSpanMin; m_arrAnalyzerButtonList[10] = btnSpanDec; m_arrAnalyzerButtonList[11] = btnMoveFreqIncLarge; m_arrAnalyzerButtonList[12] = btnMoveFreqIncSmall; m_arrAnalyzerButtonList[13] = btnBottom5plus; m_arrAnalyzerButtonList[14] = btnBottom5minus; btnCenterMark.Tag = (string)_OnlyIfConnected; btnSpanMin.Tag = (string)_OnlyIfConnected; btnSpanDefault.Tag = (string)_OnlyIfConnected; btnSpanMax.Tag = (string)_OnlyIfConnected; btnSpanDec.Tag = (string)_OnlyIfConnected; btnSpanInc.Tag = (string)_OnlyIfConnected; btnMoveFreqDecSmall.Tag = (string)_OnlyIfConnected; btnMoveFreqIncSmall.Tag = (string)_OnlyIfConnected; btnMoveFreqDecLarge.Tag = (string)_OnlyIfConnected; btnMoveFreqIncLarge.Tag = (string)_OnlyIfConnected; //Make all buttons same size, required for scaled text configurations for (int nInd = 0; nInd < m_arrAnalyzerButtonList.Length; nInd++) { m_arrAnalyzerButtonList[nInd].Width = btnBottom5plus.Width; //btnBottom5plus is currently the one with larger text m_arrAnalyzerButtonList[nInd].AutoSize = true; m_arrAnalyzerButtonList[nInd].AutoSizeMode = AutoSizeMode.GrowOnly; } CreateMarkerConfigPanel(); //MessageBox.Show(btnSend.Width.ToString()); //Define control bar m_tableLayoutControlArea.SuspendLayout(); m_tableLayoutControlArea.AutoSize = true; m_tableLayoutControlArea.ColumnCount = 10; m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); m_tableLayoutControlArea.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 10F)); m_tableLayoutControlArea.Location = new System.Drawing.Point(6, 3); m_tableLayoutControlArea.Name = "m_tableLayoutControlArea"; m_tableLayoutControlArea.RowCount = 1; m_tableLayoutControlArea.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, m_groupControl_FreqSettings.Height)); m_tableLayoutControlArea.Size = new System.Drawing.Size(10, 122); m_tableLayoutControlArea.MaximumSize = new System.Drawing.Size(Width, 122); m_tableLayoutControlArea.TabIndex = 61; m_tableLayoutControlArea.Visible = false; int nSaveBtnWidth = btnAnalyzerSend.Width; btnAnalyzerSend.AutoSize = false; btnAnalyzerSend.Dock = DockStyle.None; btnAnalyzerFreqSettingsReset.Dock = DockStyle.None; btnAnalyzerFreqSettingsReset.AutoSize = false; m_sAnalyzerCenterFreq.Width = (int)(label_sCenter.Width * 1.4); m_sAnalyzerStartFreq.Width = (int)(label_sCenter.Width * 1.4); m_sAnalyzerEndFreq.Width = (int)(label_sCenter.Width * 1.4); m_sAnalyzerBottomAmplitude.Width = (int)(label_sCenter.Width * 1.4); m_sAnalyzerTopAmplitude.Width = (int)(label_sCenter.Width * 1.4); m_sAnalyzerFreqSpan.Width = (int)(label_sCenter.Width * 1.4); btnAnalyzerSend.Width = nSaveBtnWidth; btnAnalyzerFreqSettingsReset.Width = nSaveBtnWidth; m_groupControl_DataFeed.Height = m_groupControl_FreqSettings.Height; m_groupControl_RemoteScreen.Height = m_groupControl_FreqSettings.Height; m_groupControl_Commands.Height = m_groupControl_FreqSettings.Height; m_groupControl_RFEGen_CW.Height = m_groupControl_FreqSettings.Height; m_groupControl_RFEGen_FrequencySweep.Height = m_groupControl_FreqSettings.Height; m_groupCOMPortAnalyzer.Height = m_groupControl_FreqSettings.Height; m_groupCOMPortGenerator.Height = m_groupControl_FreqSettings.Height; m_groupControl_RFEGen_Tracking.Height = m_groupControl_FreqSettings.Height; m_tableLayoutControlArea.Controls.Clear(); Controls.Remove(m_groupControl_DataFeed); Controls.Remove(m_groupControl_FreqSettings); Controls.Remove(m_groupControl_RemoteScreen); Controls.Remove(m_groupControl_Commands); Controls.Remove(m_groupControl_RFEGen_CW); Controls.Remove(m_groupControl_RFEGen_FrequencySweep); Controls.Remove(m_groupControl_RFEGen_Tracking); m_tableLayoutControlArea.Controls.Add(m_groupCOMPortAnalyzer, 0, 0); m_tableLayoutControlArea.Controls.Add(m_groupCOMPortGenerator, 1, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_DataFeed, 2, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_FreqSettings, 3, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_RemoteScreen, 4, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_Commands, 5, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_RFEGen_CW, 6, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_RFEGen_FrequencySweep, 7, 0); m_tableLayoutControlArea.Controls.Add(m_groupControl_RFEGen_Tracking, 8, 0); m_groupControl_FreqSettings.Dock = DockStyle.Fill; m_groupControl_RemoteScreen.Dock = DockStyle.Fill; //m_tableLayoutControlArea.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; m_tableLayoutControlArea.ResumeLayout(); // Set the titles and axis labels //myPane.Title.FontSpec.Size = 10; myPane.XAxis.Title.IsVisible = menuShowAxisLabels.Checked; myPane.XAxis.Title.Text = "Frequency (MHZ)"; myPane.XAxis.Scale.MajorStep = 1.0; myPane.XAxis.Scale.MinorStep = 0.2; myPane.Margin.Left = 20; myPane.Margin.Right = -5; // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.Type = AxisType.Linear; myPane.YAxis.Title.IsVisible = menuShowAxisLabels.Checked; // turn off the opposite tics so the Y tics don't show up on the Y2 axis myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorGrid.IsVisible = true; // Don't display the Y zero line myPane.YAxis.MajorGrid.IsZeroLine = false; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; m_GraphSpectrumAnalyzer.IsShowPointValues = true; m_GraphSpectrumAnalyzer.PointValueEvent += new ZedGraphControl.PointValueHandler(GraphPointValueHandler); myPane.BarSettings.Type = BarType.Overlay; myPane.BarSettings.MinBarGap = 0.1f; myPane.BarSettings.MinClusterGap = 0.1f; myPane.BarSettings.ClusterScaleWidthAuto = false; myPane.BarSettings.ClusterScaleWidth = 5.0f; m_StatusGraphText_Analyzer = new TextObj("RF Explorer DISCONNECTED", 0.01, 0.02, CoordType.ChartFraction); m_StatusGraphText_Analyzer.IsClippedToChartRect = true; //m_RFEConfig.ZOrder = 0; m_StatusGraphText_Analyzer.FontSpec.FontColor = Color.DarkGray; m_StatusGraphText_Analyzer.Location.AlignH = AlignH.Left; m_StatusGraphText_Analyzer.Location.AlignV = AlignV.Top; m_StatusGraphText_Analyzer.FontSpec.IsBold = false; m_StatusGraphText_Analyzer.FontSpec.Size = 10f; m_StatusGraphText_Analyzer.FontSpec.Border.IsVisible = false; m_StatusGraphText_Analyzer.FontSpec.Fill.IsVisible = false; m_StatusGraphText_Analyzer.FontSpec.StringAlignment = StringAlignment.Near; m_StatusGraphText_Analyzer.FontSpec.IsDropShadow = true; m_StatusGraphText_Analyzer.FontSpec.DropShadowOffset = 0.1f; m_StatusGraphText_Analyzer.FontSpec.Family = "Tahoma"; myPane.GraphObjList.Add(m_StatusGraphText_Analyzer); m_OverloadText = new TextObj("RF LEVEL OVERLOAD - COMPRESSION", 0.5, 0.05, CoordType.ChartFraction); m_OverloadText.IsClippedToChartRect = true; //m_RFEConfig.ZOrder = 0; m_OverloadText.FontSpec.FontColor = Color.DarkRed; m_OverloadText.Location.AlignH = AlignH.Center; m_OverloadText.Location.AlignV = AlignV.Top; m_OverloadText.FontSpec.IsBold = true; m_OverloadText.FontSpec.Size = 12f; m_OverloadText.FontSpec.Border.IsVisible = false; m_OverloadText.FontSpec.Fill.IsVisible = false; m_OverloadText.FontSpec.StringAlignment = StringAlignment.Center; m_OverloadText.FontSpec.IsDropShadow = false; m_OverloadText.FontSpec.Family = "Tahoma"; m_OverloadText.IsVisible = false; myPane.GraphObjList.Add(m_OverloadText); m_arrWiFiBarText = new TextObj[13]; m_arrWiFiBarText.Initialize(); for (int nInd = 0; nInd < m_arrWiFiBarText.Length; nInd++) { m_arrWiFiBarText[nInd] = new TextObj("", 0, 0, CoordType.AxisXYScale); m_arrWiFiBarText[nInd].IsClippedToChartRect = true; m_arrWiFiBarText[nInd].Location.AlignH = AlignH.Center; m_arrWiFiBarText[nInd].Location.AlignV = AlignV.Bottom; m_arrWiFiBarText[nInd].FontSpec.Size = 7; m_arrWiFiBarText[nInd].FontSpec.Border.IsVisible = false; m_arrWiFiBarText[nInd].FontSpec.FontColor = Color.Red; m_arrWiFiBarText[nInd].FontSpec.StringAlignment = StringAlignment.Center; m_arrWiFiBarText[nInd].FontSpec.Fill.IsVisible = false; myPane.GraphObjList.Add(m_arrWiFiBarText[nInd]); } m_Markers.ConnectToGraph(myPane); DefineGraphColors(); }
private void WriteValueLabels( GraphPane pane, BarItem bar, string fontFamily, float fontSize, bool isNegative ) { //shrink the bar font just a little fontSize -= 1; double xMin, xMax; double yMin, yMax; bar.GetRange( out xMin, out xMax, out yMin, out yMax, false, false, pane ); //adjust singular values so that the label doesn't bleed into the bar if( isNegative ) yMax = Math.Max( yMax, 0 ); else yMin = Math.Min( yMin, 0 ); double difference = Math.Abs( yMax - yMin ); double offset = bar.Points.Count == 1 ? 0.05 * difference : 0.1 * difference; for( int i = 0; i < bar.Points.Count; i++ ) { PointPair pt = bar.Points[ i ]; if( pt.Y == 0.0 ) continue; double myOffset = pt.Y > 0 ? offset : -offset; double myShift = pt.Y > 0 ? 0.75 : 0.65; string label = pt.Y.ToString( "f2" ) + "%"; // Create a text label from the Y data value TextObj text = new TextObj( label, ( i + myShift ), pt.Y + myOffset, CoordType.AxisXYScale, AlignH.Left, AlignV.Center ); text.FontSpec.Family = fontFamily; text.FontSpec.Size = fontSize; text.FontSpec.Angle = 0; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.Location.AlignH = AlignH.Left; text.Location.AlignV = AlignV.Center; text.Location.CoordinateFrame = CoordType.AxisXYScale; text.ZOrder = ZOrder.A_InFront; pane.GraphObjList.Add( text ); } }
public override void UpdateGraph(bool checkData) { _dotpLabels = new GraphObjList(); SrmDocument document = GraphSummary.DocumentUIContainer.DocumentUI; var results = document.Settings.MeasuredResults; bool resultsAvailable = results != null; Clear(); if (!resultsAvailable) { Title.Text = Resources.AreaReplicateGraphPane_UpdateGraph_No_results_available; EmptyGraph(document); return; } var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode; if (selectedTreeNode == null || document.FindNode(selectedTreeNode.Path) == null) { EmptyGraph(document); return; } BarSettings.Type = BarType; Title.Text = null; DisplayTypeChrom displayType; if (Equals(PaneKey, PaneKey.PRECURSORS)) { displayType = DisplayTypeChrom.precursors; } else if (Equals(PaneKey, PaneKey.PRODUCTS)) { displayType = DisplayTypeChrom.products; } else { displayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode); } DocNode selectedNode = selectedTreeNode.Model; DocNode parentNode = selectedNode; IdentityPath identityPath = selectedTreeNode.Path; bool optimizationPresent = results.Chromatograms.Contains( chrom => chrom.OptimizationFunction != null); // If the selected tree node is a transition, then its siblings are displayed. if (selectedTreeNode is TransitionTreeNode) { if (displayType == DisplayTypeChrom.single) { BarSettings.Type = BarType.Cluster; } else { SrmTreeNode parentTreeNode = selectedTreeNode.SrmParent; parentNode = parentTreeNode.Model; identityPath = parentTreeNode.Path; } } // If the selected node is a peptide with one child, then show the children, // unless chromatogram display type is total else if (selectedTreeNode is PeptideTreeNode) { var children = ((PeptideDocNode) selectedNode).TransitionGroups .Where(PaneKey.IncludesTransitionGroup) .ToArray(); if (children.Length == 1 && displayType != DisplayTypeChrom.total) { selectedNode = parentNode = children[0]; identityPath = new IdentityPath(identityPath, parentNode.Id); } else { BarSettings.Type = BarType.Cluster; } } else if (!(selectedTreeNode is TransitionGroupTreeNode)) { Title.Text = Resources.AreaReplicateGraphPane_UpdateGraph_Select_a_peptide_to_see_the_peak_area_graph; CanShowPeakAreaLegend = false; CanShowDotProduct = false; return; } var parentGroupNode = parentNode as TransitionGroupDocNode; // If a precursor is going to be displayed with display type single if (parentGroupNode != null && displayType == DisplayTypeChrom.single) { // If no optimization data, then show all the transitions if (!optimizationPresent) displayType = DisplayTypeChrom.all; // Otherwise, do not stack the bars else BarSettings.Type = BarType.Cluster; } int ratioIndex = AreaGraphData.RATIO_INDEX_NONE; var standardType = IsotopeLabelType.light; var areaView = AreaGraphController.AreaView; if (areaView == AreaNormalizeToView.area_ratio_view) { ratioIndex = GraphSummary.RatioIndex; standardType = document.Settings.PeptideSettings.Modifications.RatioInternalStandardTypes[ratioIndex]; } else if (areaView == AreaNormalizeToView.area_global_standard_view) { if (document.Settings.HasGlobalStandardArea) ratioIndex = ChromInfo.RATIO_INDEX_GLOBAL_STANDARDS; else areaView = AreaNormalizeToView.none; } // Sets normalizeData to optimization, maximum_stack, maximum, total, or none AreaNormalizeToData normalizeData; if (optimizationPresent && displayType == DisplayTypeChrom.single && areaView == AreaNormalizeToView.area_percent_view) { normalizeData = AreaNormalizeToData.optimization; } else if (areaView == AreaNormalizeToView.area_maximum_view) { normalizeData = BarSettings.Type == BarType.Stack ? AreaNormalizeToData.maximum_stack : AreaNormalizeToData.maximum; } else if (BarSettings.Type == BarType.PercentStack) { normalizeData = AreaNormalizeToData.total; } else { normalizeData = AreaNormalizeToData.none; } // Calculate graph data points // IsExpectedVisible depends on ExpectedVisible ExpectedVisible = AreaExpectedValue.none; if (parentGroupNode != null && displayType != DisplayTypeChrom.total && areaView != AreaNormalizeToView.area_ratio_view && !(optimizationPresent && displayType == DisplayTypeChrom.single)) { var displayTrans = GraphChromatogram.GetDisplayTransitions(parentGroupNode, displayType).ToArray(); bool isShowingMs = displayTrans.Any(nodeTran => nodeTran.IsMs1); bool isShowingMsMs = displayTrans.Any(nodeTran => !nodeTran.IsMs1); bool isFullScanMs = document.Settings.TransitionSettings.FullScan.IsEnabledMs && isShowingMs; if (isFullScanMs) { if (!isShowingMsMs && parentGroupNode.HasIsotopeDist) ExpectedVisible = AreaExpectedValue.isotope_dist; } else { if (parentGroupNode.HasLibInfo) ExpectedVisible = AreaExpectedValue.library; } } var expectedValue = IsExpectedVisible ? ExpectedVisible : AreaExpectedValue.none; var replicateGroupOp = GraphValues.ReplicateGroupOp.FromCurrentSettings(document.Settings); var graphData = new AreaGraphData(document, parentNode, displayType, replicateGroupOp, ratioIndex, normalizeData, expectedValue, PaneKey); var aggregateOp = replicateGroupOp.AggregateOp; // Avoid stacking CVs if (aggregateOp.Cv || aggregateOp.CvDecimal) BarSettings.Type = BarType.Cluster; int countNodes = graphData.DocNodes.Count; if (countNodes == 0) ExpectedVisible = AreaExpectedValue.none; CanShowDotProduct = ExpectedVisible != AreaExpectedValue.none && areaView != AreaNormalizeToView.area_percent_view; CanShowPeakAreaLegend = countNodes != 0; InitFromData(graphData); // Add data to the graph int selectedReplicateIndex = SelectedIndex; if (IsExpectedVisible) { if (GraphSummary.ActiveLibrary) selectedReplicateIndex = 0; } double maxArea = -double.MaxValue; double sumArea = 0; // An array to keep track of height of all bars to determine // where each dot product annotation (if showing) should be placed var sumAreas = new double[graphData.ReplicateGroups.Count]; // If only one bar to show, then use cluster instead of stack bar type, since nothing to stack // Important for mean error bar checking below if (BarSettings.Type == BarType.Stack && countNodes == 1 && graphData.PointPairLists[0].Count == 1) BarSettings.Type = BarType.Cluster; int colorOffset = 0; if(parentGroupNode != null) { // We want the product ion colors to stay the same whether they are displayed: // 1. In a single pane with the precursor ions (Transitions -> All) // 2. In a separate pane of the split graph (Transitions -> All AND Transitions -> Split Graph) // 3. In a single pane by themselves (Transition -> Products) // We will use an offset in the colors array for cases 2 and 3 so that we do not reuse the precursor ion colors. var nodeDisplayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode); if (displayType == DisplayTypeChrom.products && (nodeDisplayType != DisplayTypeChrom.single || (nodeDisplayType == DisplayTypeChrom.single && !optimizationPresent))) { colorOffset = GraphChromatogram.GetDisplayTransitions(parentGroupNode, DisplayTypeChrom.precursors).Count(); } } int iColor = 0, iCharge = -1; int? charge = null; int countLabelTypes = document.Settings.PeptideSettings.Modifications.CountLabelTypes; for (int i = 0; i < countNodes; i++) { var docNode = graphData.DocNodes[i]; var pointPairLists = graphData.PointPairLists[i]; int numSteps = pointPairLists.Count/2; for (int iStep = 0; iStep < pointPairLists.Count; iStep++) { int step = iStep - numSteps; var pointPairList = pointPairLists[iStep]; Color color; var nodeGroup = docNode as TransitionGroupDocNode; if (parentNode is PeptideDocNode) { int iColorGroup = GetColorIndex(nodeGroup, countLabelTypes, ref charge, ref iCharge); color = COLORS_GROUPS[iColorGroup % COLORS_GROUPS.Length]; } else if (displayType == DisplayTypeChrom.total) { color = COLORS_GROUPS[iColor%COLORS_GROUPS.Length]; } else if (docNode.Equals(selectedNode) && step == 0) { color = ChromGraphItem.ColorSelected; } else { color = COLORS_TRANSITION[(iColor + colorOffset) % COLORS_TRANSITION.Length]; } iColor++; // If showing ratios, do not add the standard type to the graph, // since it will always be empty, but make sure the colors still // correspond with the other graphs. if (nodeGroup != null && ratioIndex >= 0) { var labelType = nodeGroup.TransitionGroup.LabelType; if (ReferenceEquals(labelType, standardType)) continue; } string label = graphData.DocNodeLabels[i]; if (step != 0) label = string.Format(Resources.AreaReplicateGraphPane_UpdateGraph_Step__0_, step); BarItem curveItem; // Only use a MeanErrorBarItem if bars are not going to be stacked. // TODO(nicksh): AreaGraphData.NormalizeTo does not know about MeanErrorBarItem if (BarSettings.Type != BarType.Stack && BarSettings.Type != BarType.PercentStack && normalizeData == AreaNormalizeToData.none) { curveItem = new MeanErrorBarItem(label, pointPairList, color, Color.Black); } else { curveItem = new BarItem(label, pointPairList, color); } if (0 <= selectedReplicateIndex && selectedReplicateIndex < pointPairList.Count) { PointPair pointPair = pointPairList[selectedReplicateIndex]; if (!pointPair.IsInvalid) { sumArea += pointPair.Y; maxArea = Math.Max(maxArea, pointPair.Y); } } // Add area for this transition to each area entry AddAreasToSums(pointPairList, sumAreas); curveItem.Bar.Border.IsVisible = false; curveItem.Bar.Fill.Brush = new SolidBrush(color); curveItem.Tag = new IdentityPath(identityPath, docNode.Id); CurveList.Add(curveItem); } } ParentGroupNode = parentGroupNode; SumAreas = sumAreas; // Draw a box around the currently selected replicate if (ShowSelection && maxArea > -double.MaxValue) { double yValue; switch (BarSettings.Type) { case BarType.Stack: // The Math.Min(sumArea, .999) makes sure that if graph is in normalized view // height of the selection rectangle does not exceed 1, so that top of the rectangle // can be viewed when y-axis scale maximum is at 1 yValue = (areaView == AreaNormalizeToView.area_maximum_view ? Math.Min(sumArea, .999) : sumArea); break; case BarType.PercentStack: yValue = 99.99; break; default: // Scale the selection box to fit exactly the bar height yValue = (areaView == AreaNormalizeToView.area_maximum_view ? Math.Min(maxArea, .999) : maxArea); break; } GraphObjList.Add(new BoxObj(selectedReplicateIndex + .5, yValue, 0.99, yValue, Color.Black, Color.Empty) { IsClippedToChartRect = true, }); } // Reset the scale when the parent node changes bool resetAxes = (_parentNode == null || !ReferenceEquals(_parentNode.Id, parentNode.Id)); _parentNode = parentNode; UpdateAxes(resetAxes, aggregateOp, normalizeData, areaView, standardType); }
public static void GetRangeY(BarItem curve, int fromId, int toId, ref ValueRange yRange) { for (int idx = fromId; idx <= toId; idx++) { PointPair item = (PointPair)curve.Points[idx]; if (item.Y < yRange.Min) yRange.Min = item.Y; if (item.Y > yRange.Max) yRange.Max = item.Y; } }
/// <summary> /// Add a bar type curve (<see cref="CurveItem"/> object) to the plot with /// the given data points (<see cref="PointPairList"/>) and properties. /// This is simplified way to add curves without knowledge of the /// <see cref="CurveList"/> class. An alternative is to use /// the <see cref="ZedGraph.CurveList.Add"/> method. /// </summary> /// <param name="label">The text label (string) for the curve that will be /// used as a <see cref="Legend"/> entry.</param> /// <param name="points">A <see cref="PointPairList"/> of double precision value pairs that define /// the X and Y values for this curve</param> /// <param name="color">The color to used to fill the bars</param> /// <returns>A <see cref="CurveItem"/> class for the newly created bar curve. /// This can then be used to access all of the curve properties that /// are not defined as arguments to the /// <see cref="AddBar(string,PointPairList,Color)"/> method.</returns> public BarItem AddBar( string label, PointPairList points, Color color ) { BarItem curve = new BarItem( label, points, color ); this.curveList.Add( curve ); return curve; }
public static void GetRangeY(BarItem curve, int fromId, int toId, ref ValueRange yRange) { fromId = Math.Max(fromId, 0); toId = Math.Min(toId, curve.Points.Count - 1); for (int idx = fromId; idx <= toId; idx++) { if (idx < 0 || idx >= curve.Points.Count) continue; PointPair item = (PointPair)curve.Points[idx]; if (item.Y < yRange.Min) yRange.Min = item.Y; if (item.Y > yRange.Max) yRange.Max = item.Y; } }
/// <summary> /// Create a <see cref="TextObj" /> for each bar in the <see cref="GraphPane" />. /// </summary> /// <remarks> /// This method will go through the bars, create a label that corresponds to the bar value, /// and place it on the graph depending on user preferences. This works for horizontal or /// vertical bars in clusters or stacks, but only for <see cref="BarItem" /> types. This method /// does not apply to <see cref="ErrorBarItem" /> or <see cref="HiLowBarItem" /> objects. /// Call this method only after calling <see cref="GraphPane.AxisChange()" />. /// </remarks> /// <param name="pane">The GraphPane in which to place the text labels.</param> /// <param name="isBarCenter">true to center the labels inside the bars, false to /// place the labels just above the top of the bar.</param> /// <param name="valueFormat">The double.ToString string format to use for creating /// the labels. /// </param> /// <param name="fontColor">The color in which to draw the labels</param> /// <param name="fontFamily">The string name of the font family to use for the labels</param> /// <param name="fontSize">The floating point size of the font, in scaled points</param> /// <param name="isBold">true for a bold font type, false otherwise</param> /// <param name="isItalic">true for an italic font type, false otherwise</param> /// <param name="isUnderline">true for an underline font type, false otherwise</param> public static void CreateBarLabels(GraphPane pane, bool isBarCenter, string valueFormat, string fontFamily, float fontSize, Color fontColor, bool isBold, bool isItalic, bool isUnderline) { bool isVertical = pane.BarSettings.Base == BarBase.X; // keep a count of the number of BarItems int curveIndex = 0; // Get a valuehandler to do some calculations for us ValueHandler valueHandler = new ValueHandler(pane, true); // Loop through each curve in the list foreach (CurveItem curve in pane.CurveList) { // work with BarItems only BarItem bar = curve as BarItem; if (bar != null) { IPointList points = curve.Points; // ADD JKB 9/21/07 // The labelOffset should depend on whether the curve is YAxis or Y2Axis. // JHC - Generalize to any value axis // Make the gap between the bars and the labels = 1.5% of the axis range float labelOffset; Scale scale = curve.ValueAxis(pane).Scale; labelOffset = (float)(scale._max - scale._min) * 0.015f; // Loop through each point in the BarItem for (int i = 0; i < points.Count; i++) { // Get the high, low and base values for the current bar // note that this method will automatically calculate the "effective" // values if the bar is stacked double baseVal, lowVal, hiVal; valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal); // Get the value that corresponds to the center of the bar base // This method figures out how the bars are positioned within a cluster float centerVal = (float)valueHandler.BarCenterValue(bar, bar.GetBarWidth(pane), i, baseVal, curveIndex); // Create a text label -- note that we have to go back to the original point // data for this, since hiVal and lowVal could be "effective" values from a bar stack string barLabelText = (isVertical ? points[i].Y : points[i].X).ToString(valueFormat); // Calculate the position of the label -- this is either the X or the Y coordinate // depending on whether they are horizontal or vertical bars, respectively float position; if (isBarCenter) { position = (float)(hiVal + lowVal) / 2.0f; } else if (hiVal >= 0) { position = (float)hiVal + labelOffset; } else { position = (float)hiVal - labelOffset; } // Create the new TextObj TextObj label; if (isVertical) { label = new TextObj(barLabelText, centerVal, position); } else { label = new TextObj(barLabelText, position, centerVal); } label.FontSpec.Family = fontFamily; // Configure the TextObj // CHANGE JKB 9/21/07 // CoordinateFrame should depend on whether curve is YAxis or Y2Axis. label.Location.CoordinateFrame = (isVertical && curve.IsY2Axis) ? CoordType.AxisXY2Scale : CoordType.AxisXYScale; label.FontSpec.Size = fontSize; label.FontSpec.FontColor = fontColor; label.FontSpec.IsItalic = isItalic; label.FontSpec.IsBold = isBold; label.FontSpec.IsUnderline = isUnderline; label.FontSpec.Angle = isVertical ? 90 : 0; label.Location.AlignH = isBarCenter ? AlignH.Center : (hiVal >= 0 ? AlignH.Left : AlignH.Right); label.Location.AlignV = AlignV.Center; label.FontSpec.Border.IsVisible = false; label.FontSpec.Fill.IsVisible = false; // Add the TextObj to the GraphPane pane.GraphObjList.Add(label); } curveIndex++; } } }