public void plotBox(int colorIndex) { GraphPane myPane = zedGraphControl1.GraphPane; int index = 0; foreach (SummaryData summary in m_data.SummaryData) { //Plot the items, first the median values CurveItem meadian = myPane.AddCurve("", masterList[index][0], Color.Black, SymbolType.HDash); LineItem myLine = (LineItem)meadian; myLine.Line.IsVisible = false; myLine.Symbol.Size = 25; myLine.Symbol.Fill.Type = FillType.Solid; //Box HiLowBarItem myCurve = myPane.AddHiLowBar(summary.SeriesName, masterList[index][1], GetNextColor()); myCurve.Bar.Fill.Type = FillType.Solid; //Wiskers ErrorBarItem myerror = myPane.AddErrorBar("", masterList[index][2], Color.Black); //Outliers CurveItem upper = myPane.AddCurve("", masterList[index][3], Color.Black, SymbolType.Circle); LineItem bLine = (LineItem)upper; bLine.Symbol.Size = 3; bLine.Line.IsVisible = false; index++; } }
public HiLowBarDemo() : base("A demo demonstrating HiLow Bars.\n" + "These are bars in which the top and the bottom of the bar is defined with user data", "Hi-Low Bar", DemoType.Bar) { GraphPane myPane = base.GraphPane; // Set the title and axis labels myPane.Title.Text = "Hi-Low Bar Graph Demo"; myPane.XAxis.Title.Text = "Event"; myPane.YAxis.Title.Text = "Range of Values"; // Make up some data points based on the Sine function PointPairList list = new PointPairList(); for (int i = 1; i < 45; i++) { double y = Math.Sin((double)i * Math.PI / 15.0); double yBase = y - 0.4; list.Add((double)i, y, yBase); } // Generate a red bar with "Curve 1" in the legend HiLowBarItem myCurve = myPane.AddHiLowBar("Curve 1", list, Color.Red); // Fill the bar with a red-white-red gradient for a 3d look myCurve.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red, 0); // Make the bar width based on the available space, rather than a size in points // myCurve.Bar.IsAutoSize = true; // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F); base.ZedGraphControl.AxisChange(); }
/// <summary> /// a hacked mess to show box-wisker plot for outlier manipulation /// </summary> /// <param name="iv">double array of independent variable values</param> /// <param name="tags">string array of what should be date/time tags</param> /// <returns>a graph pane to display in the master</returns> private GraphPane addPlotBW(double[] iv, string[] tags) { //http://www.sharpstatistics.co.uk/index.php?option=com_content&view=article&id=12&Itemid=13 //and hacked by mog 4/1/11 //For each set of data for the boxplot calculate the median and the inter quartile (IQR) range //which is just the value of the 75th percentile minus the 25th percentile. The median is where //the horizontal bar goes. Using the 25th and 75th percentile a HiLowBarIten can be set which is //just a bar where the top and base are specified. //An error bar that has upper and lower values of the 25th percentile minus 1.5 times the IQR and //the 75th percentile plus 1.5 times the IQR is set to give the whiskers. As with the HiLowItem //barList is a PointPairList with the high and low values. //All that is left to do is add any points that are above or below the end of the whiskers. SortedList <string, double> datevalue = getlist(tags, iv); GraphPane gp = new GraphPane(); // "Median designated within box.\n" + // "Whiskers are +- 1.5 * IQR (IQR = 75th percentile - 25th percentile)\n" + // "Points above/below whiskers are designated as outliers."; //median of each array PointPairList medians = new PointPairList(); //75th and 25th percentile, defines the box PointPairList hiLowList = new PointPairList(); //+/- 1.5*Interquartile range, extentent of wiskers PointPairList barList = new PointPairList(); //outliers PointPairList outs = new PointPairList(); //Add the values DescriptiveStats ds = new DescriptiveStats(); ds.getStats(iv); double median = ds.Median; medians.Add(0, median); double hivalue = percentile(iv, 75); double lovalue = percentile(iv, 25); hiLowList.Add(0, hivalue, lovalue); double iqr = 1.5 * (hivalue - lovalue); double upperLimit = hivalue + iqr; double lowerLimit = lovalue - iqr; //The wiskers must end on an actual data point double wiskerlo = ValueNearestButGreater(iv, lowerLimit); double wiskerhi = ValueNearestButLess(iv, upperLimit); barList.Add(0, wiskerlo, wiskerhi); var upperouts = (from kv in datevalue where kv.Value > upperLimit select kv); foreach (var v in upperouts) { outs.Add(0, v.Value, v.Key); } var lowerouts = (from kv in datevalue where kv.Value < lowerLimit select kv); foreach (var v in lowerouts) { outs.Add(0, v.Value, v.Key); } //Plot the items, first the median values CurveItem meadian = gp.AddCurve("", medians, Color.Black, SymbolType.HDash); LineItem myLine = (LineItem)meadian; myLine.Line.IsVisible = false; myLine.Symbol.Fill.Type = FillType.Solid; //Box HiLowBarItem myCurve = gp.AddHiLowBar("", hiLowList, Color.Black); myCurve.Bar.Fill.Type = FillType.None; //Wiskers ErrorBarItem myerror = gp.AddErrorBar("", barList, Color.Black); //Outliers CurveItem upper = gp.AddCurve(_dt.Columns[intSelectedcol].ColumnName + " outliers", outs, Color.Green, SymbolType.Circle); LineItem bLine = (LineItem)upper; bLine.Line.IsVisible = false; gp.YAxis.Title.Text = _dt.Columns[intSelectedcol].ColumnName; gp.BarSettings.Type = BarType.Overlay; gp.XAxis.IsVisible = false; gp.Legend.IsVisible = true; gp.Tag = "BWPlot"; gp.Title.Text = "BoxWhisker Plot"; return(gp); }
/// <summary> /// Draws a sequence statistic chart for the FastqComponent_Details handle within this class /// </summary> public void DrawSequenceStatistics() { Console.WriteLine("Drawing new sequence length distribution!"); FqPerBaseSatistics[] perBaseStatistics = componentDetails.perBaseStatistics; double[] x = new double[perBaseStatistics.Length]; PointPairList boxList = new PointPairList(); PointPairList lowerWhisker = new PointPairList(); PointPairList upperWhisker = new PointPairList(); PointPairList medians = new PointPairList(); int count = 1; for (int i = 0; i < x.Length; i++) { x[i] = count; boxList.Add((double)x[i], (double)perBaseStatistics[i].ThirdQuartile, (double)perBaseStatistics[i].FirstQuartile); medians.Add((double)x[i], (double)perBaseStatistics[i].Median); upperWhisker.Add((double)x[i], (double)perBaseStatistics[i].UpperThreshold); lowerWhisker.Add((double)x[i], (double)perBaseStatistics[i].LowerThreshold); count++; } Size size = graphControl.ClientSize; Rectangle rect = new Rectangle(); rect.Size = size; graphControl.GraphPane = new GraphPane(); graphControl.GraphPane.CurveList.Clear(); graphControl.GraphPane.Rect = rect; GraphPane myPane = graphControl.GraphPane; myPane.Title.Text = "Per Base Statistics " + componentDetails.getGraphName(); // set X and Y axis titles myPane.XAxis.Title.Text = "Base Position"; myPane.YAxis.Title.Text = "Qualities"; CurveItem median = myPane.AddCurve("Median", medians, Color.Green, SymbolType.None); LineItem myLine = (LineItem)median; myLine.Line.IsVisible = true; myLine.Line.IsAntiAlias = true; myLine.Symbol.Fill.Type = FillType.Solid; myLine.Symbol.Size = 1; HiLowBarItem myCurve = myPane.AddHiLowBar("Quartiles", boxList, Color.Black); myCurve.Bar.Fill.Type = FillType.Solid; myCurve.Bar.Fill.Color = Color.Yellow; myCurve.Bar.Border.Color = Color.Yellow; CurveItem lthresholds = myPane.AddCurve("Lower Threshold", lowerWhisker, Color.Red, SymbolType.HDash); LineItem lthreshline = (LineItem)lthresholds; lthreshline.Line.IsVisible = false; lthreshline.Symbol.Fill.Type = FillType.Solid; lthreshline.Symbol.Size = 1; lthreshline.Symbol.Fill.Color = Color.Red; CurveItem uppthesh = myPane.AddCurve("Upper Threshold", upperWhisker, Color.Red, SymbolType.HDash); LineItem uthreshline = (LineItem)uppthesh; uthreshline.Line.IsVisible = false; uthreshline.Symbol.Fill.Type = FillType.Solid; uthreshline.Symbol.Size = 1; uthreshline.Symbol.Fill.Color = Color.Red; graphControl.Focus(); graphControl.AxisChange(); graphControl.Invalidate(); graphControl.Refresh(); }
//IN PROGRESS #region ANNOTATION GRAPH private void CreateDiaryGraph(GraphPane gp, string filepath, string dirpath_colors, string title, int yoffset, string type) { gp.BarSettings.Base = BarBase.Y; gp.BarSettings.ClusterScaleWidth = 200.0; gp.BarSettings.Type = BarType.Overlay; PointPairList labelList = new PointPairList(); if (filepath.Contains(".csv")) { string[] values = FileReadWrite.ReadLinesFromFile(filepath); for (int i = 1; i < values.Length; i++) { try { string[] split = values[i].Split(','); DateTime dtStart = DateTime.MinValue; DateTime dtEnd = DateTime.MaxValue; double startx = 0; double endx = 0; if (split.Length > 0 && split[0].Length > 0) { dtStart = DateTimeParse(split[0]); startx = (double)new XDate(dtStart); } if (split.Length > 1 && split[1].Length > 0) { dtEnd = DateTimeParse(split[1]); endx = (double)new XDate(dtEnd); } Color color = Color.White; bool isSolid = false; string clabel = ""; if (startx >= startX && endx >= endX) { if (split.Length > 2 && split[2].Length > 0) { clabel = split[2]; if (!DataViewForm.annotationColorMap.ContainsKey(clabel)) { DataViewForm.annotationColorMap.Add(clabel, DataViewForm._annotationColorPalette[DataViewForm.annotationColorMap.Count]); } color = DataViewForm.annotationColorMap[clabel]; isSolid = true; labelList = new PointPairList(); labelList.Add(endx, yoffset, startx, String.Format("{3}: {0} - {1}\n {2}", dtStart.ToLongTimeString(), dtEnd.ToLongTimeString(), clabel, title)); HiLowBarItem myBar = gp.AddHiLowBar(title, labelList, color); myBar.Bar.Border.IsVisible = false; if (isSolid) { myBar.Bar.Fill.Type = FillType.Solid; } else { myBar.Bar.Fill.Type = FillType.None; } } } } catch { } } } else if (filepath.Contains(".xml")) { XmlDocument doc = new XmlDocument(); doc.Load(filepath); XmlNodeList nodes = doc.GetElementsByTagName("ANNOTATION"); foreach (XmlNode xn in nodes) { try { DateTime dtStart = DateTimeParse(xn["START_DT"].InnerText); DateTime dtEnd = DateTimeParse(xn["STOP_DT"].InnerText); double startx = (double)new XDate(dtStart); double endx = (double)new XDate(dtEnd); Color color = Color.White; bool isSolid = false; string clabel = xn["LABEL"].InnerText; if (startx >= (double)startX && endx >= (double)endX) { if (!DataViewForm.annotationColorMap.ContainsKey(clabel)) { DataViewForm.annotationColorMap.Add(clabel, DataViewForm._annotationColorPalette[DataViewForm.annotationColorMap.Count]); } color = DataViewForm.annotationColorMap[clabel]; isSolid = true; labelList = new PointPairList(); labelList.Add(endx, yoffset, startx, String.Format("{3}: {0} - {1}\n {2}", dtStart.ToLongTimeString(), dtEnd.ToLongTimeString(), clabel, title)); HiLowBarItem myBar = gp.AddHiLowBar(title, labelList, color); myBar.Bar.Border.IsVisible = false; if (isSolid) { myBar.Bar.Fill.Type = FillType.Solid; } else { myBar.Bar.Fill.Type = FillType.None; } } } catch { } } } }
private void initializeGraphControl(ZedGraphControl zedGraphControl) { zedGraphControl.MasterPane.PaneList.Clear(); zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), 1, (int)IonSeries.Count + 1); zedGraphControl.MasterPane.InnerPaneGap = 0; zedGraphControl.MasterPane.Border.IsVisible = true; zedGraphControl.IsEnableHPan = false; zedGraphControl.IsEnableHZoom = false; zedGraphControl.IsSynchronizeYAxes = true; zedGraphControl.IsZoomOnMouseCenter = true; var axisPane = new GraphPane(); axisPane.Legend.IsVisible = false; axisPane.IsFontsScaled = false; axisPane.XAxis.IsVisible = false; axisPane.YAxis.Scale.Min = 0; axisPane.YAxis.Scale.Max = 100; axisPane.YAxis.Title.Text = zedGraphControl.Text; axisPane.YAxis.Title.Gap = 0.05f; axisPane.YAxis.MajorTic.IsOpposite = false; axisPane.YAxis.MinorTic.IsOpposite = false; axisPane.Chart.Border.IsVisible = false; axisPane.Border.IsVisible = false; axisPane.Margin.Left = 1; axisPane.Margin.Right = 0; axisPane.Title.Text = "Series:"; zedGraphControl.MasterPane.Add(axisPane); var csr = new ColorSymbolRotator(); for (int i = 0; i < (int)IonSeries.Count; ++i) { var graphPane = new GraphPane(); graphPane.Title.Text = IonSeriesLabels[i]; graphPane.Legend.IsVisible = false; graphPane.IsFontsScaled = false; graphPane.Chart.Border.IsVisible = false; graphPane.Border.IsVisible = false; graphPane.XAxis.Scale.Min = -1; graphPane.XAxis.Scale.Max = 1; graphPane.XAxis.IsVisible = false; graphPane.YAxis.Scale.Min = 0; graphPane.YAxis.Scale.Max = 100; graphPane.YAxis.IsVisible = false; zedGraphControl.MasterPane.Add(graphPane); graphPane.BarSettings.Type = BarType.Overlay; graphPane.BarSettings.ClusterScaleWidth = 1; var mean = graphPane.AddCurve(IonSeriesLabels[i], new PointPairList(), Color.Black, SymbolType.Circle); mean.Line.IsVisible = false; mean.Symbol.Border.IsVisible = false; mean.Symbol.Fill.Type = FillType.Solid; var errorBar = graphPane.AddErrorBar(IonSeriesLabels[i], new PointPairList(), Color.Black); errorBar.Bar.IsVisible = true; errorBar.Bar.PenWidth = .1f; errorBar.Bar.Symbol.IsVisible = true; errorBar.Bar.Symbol.Type = SymbolType.HDash; errorBar.Bar.Symbol.Border.Width = .1f; errorBar.Bar.Symbol.Size = 4; var hiLowBar = graphPane.AddHiLowBar(IonSeriesLabels[i], new PointPairList(), Color.Black); hiLowBar.Bar.Fill.Type = FillType.None; var scatter = graphPane.AddCurve(IonSeriesLabels[i], new PointPairList(), csr.NextColor, SymbolType.Circle); scatter.Line.IsVisible = false; scatter.Symbol.IsAntiAlias = true; scatter.Symbol.Border.IsVisible = false; scatter.Symbol.Fill.Type = FillType.Solid; scatter.Symbol.Size = 3f; } zedGraphControl.MasterPane.AxisChange(); zedGraphControl.Refresh(); }
private void DrawCurveGraph() { GraphPane myPane = zedGraphControl1.GraphPane; myPane.CurveList.Clear(); myPane.GraphObjList.Clear(); zedGraphControl1.RestoreScale(zedGraphControl1.GraphPane); m_dBaseAlt = System.Convert.ToDouble(textBoxBaseAlt.Text); myPane.Legend.IsVisible = false; PointPairList listHLAbove = new PointPairList(); PointPairList listAbove = new PointPairList(); PointPairList listHLBelow = new PointPairList(); PointPairList listBelow = new PointPairList(); PointPairList listEqual = new PointPairList(); PointPairList listBase = new PointPairList(); ArrayList arryHLAbove = new ArrayList(); ArrayList arryHLBelow = new ArrayList(); ArrayList arryAbove = new ArrayList(); ArrayList arryBelow = new ArrayList(); int nPointCount = m_pnt3ds.Count; double dOneSegLen = m_dXTotalLength / (nPointCount - 1); int nSegmentType = -1; //0=m_dBaseAlt,1=above,2=below for (int i = 0; i < m_pnt3ds.Count; i++) { double x = i * dOneSegLen; double y = (int)(Math.Round(m_pnt3ds[i].Z * 100)) / 100.0; // 精确到厘米就行了 if (y > m_dBaseAlt) { // 如果当前段是基准线下面的段 if (nSegmentType == 2) { arryHLBelow.Add(listHLBelow); arryBelow.Add(listBelow); listHLBelow = new PointPairList(); listBelow = new PointPairList(); } nSegmentType = 1; listAbove.Add(x, y); listHLAbove.Add(x, y, m_dBaseAlt); } else if (y < m_dBaseAlt) { if (nSegmentType == 1) { arryHLAbove.Add(listHLAbove); arryAbove.Add(listAbove); listHLAbove = new PointPairList(); listAbove = new PointPairList(); } nSegmentType = 2; listBelow.Add(x, y); listHLBelow.Add(x, m_dBaseAlt, y); } else { if (nSegmentType == 2) { arryHLBelow.Add(listHLBelow); arryBelow.Add(listBelow); listHLBelow = new PointPairList(); listBelow = new PointPairList(); } else if (nSegmentType == 1) { arryHLAbove.Add(listHLAbove); arryAbove.Add(listAbove); listHLAbove = new PointPairList(); listAbove = new PointPairList(); } nSegmentType = 0; listEqual.Add(x, y, m_dBaseAlt); } } if (nSegmentType == 2) { arryHLBelow.Add(listHLBelow); arryBelow.Add(listBelow); } else if (nSegmentType == 1) { arryHLAbove.Add(listHLAbove); arryAbove.Add(listAbove); } listBase.Add(0, m_dBaseAlt); listBase.Add(m_dXTotalLength, m_dBaseAlt); LineItem myCurveBase = myPane.AddCurve("基线剖面", listBase, Color.Blue, SymbolType.None); myCurveBase.Line.IsAntiAlias = true; myCurveBase.Line.Width = 2; int k = 0; for (k = 0; k < arryHLAbove.Count; k++) { LineItem myCurveAbove = myPane.AddCurve("高于基线剖面", (PointPairList)arryAbove[k], Color.Red, SymbolType.None); myCurveAbove.Line.IsAntiAlias = true; myCurveAbove.Line.Width = 2; myCurveAbove.Line.IsSmooth = true; HiLowBarItem hlAboveItem = myPane.AddHiLowBar("高于基线", (PointPairList)arryHLAbove[k], Color.Red); hlAboveItem.Bar.Border.Color = Color.Red; } for (k = 0; k < arryHLBelow.Count; k++) { LineItem myCurveBelow = myPane.AddCurve("低于基线剖面", (PointPairList)arryBelow[k], Color.Green, SymbolType.None); myCurveBelow.Line.IsAntiAlias = true; myCurveBelow.Line.Width = 2; myCurveBelow.Line.IsSmooth = true; HiLowBarItem hlBolowItem = myPane.AddHiLowBar("低于基线", (PointPairList)arryHLBelow[k], Color.Green); hlBolowItem.Bar.Border.Color = Color.Green; } /* * * LineItem myCurveAbove = myPane.AddCurve("高于基线剖面", listAbove, Color.Red, SymbolType.None); * //myCurve.Symbol.Fill = new Fill(Color.White); * myCurveAbove.Line.IsAntiAlias = true; * myCurveAbove.Line.Width = 2; * myCurveAbove.Line.IsSmooth = true; * * * * * // myCurveAbove.Line.Fill = new Fill(Color.Yellow, Color.LightGray, 45.0f); * * * LineItem myCurveBelow = myPane.AddCurve("低于基线剖面", listBelow, Color.Blue, SymbolType.None); * //myCurve.Symbol.Fill = new Fill(Color.White); * myCurveBelow.Line.IsAntiAlias = true; * myCurveBelow.Line.Width = 2; * myCurveBelow.Line.IsSmooth = true; * * * //myCurveBelow.Line.Fill = new Fill(Color.Yellow, Color.LightGray, 45.0f); * * * LineItem myCurveEqual = myPane.AddCurve("等于基线剖面", listEqual, Color.DarkOrange, SymbolType.None); * //myCurve.Symbol.Fill = new Fill(Color.White); * myCurveEqual.Line.IsAntiAlias = true; * myCurveEqual.Line.Width = 2; * //myCurveEqual.Line.Fill = new Fill(Color.Yellow, Color.LightGray, 45.0f); * * * // LineItem myCurveBase = myPane.AddCurve("基线剖面", listBase, Color.Green, SymbolType.None); * //myCurveBase.Line.IsAntiAlias = true; * //myCurveBase.Line.Width = 2; * */ // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.IsAxisSegmentVisible = true; if (m_bSetMinX) { myPane.XAxis.Scale.Min = 0; } if (m_bSetMinY) { myPane.YAxis.Scale.Min = m_pntMin.Z; } //myPane.XAxis.Scale.Min = 0; 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; // Manually set the axis range //myPane.YAxis.Scale.Min = -1000; // myPane.YAxis.Scale.Max = 1000; // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // Enable scrollbars if needed //zedGraphControl1.IsShowHScrollBar = true; //zedGraphControl1.IsShowVScrollBar = true; zedGraphControl1.IsAutoScrollRange = true; // OPTIONAL: Show tooltips when the mouse hovers over a point zedGraphControl1.IsShowPointValues = true; zedGraphControl1.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); // OPTIONAL: Handle the Zoom Event zedGraphControl1.ZoomEvent += new ZedGraphControl.ZoomEventHandler(MyZoomEvent); zedGraphControl1.AxisChange(); if (m_bXYSameScale) { graphPane_AxisChangeEvent(); } // Make sure the Graph gets redrawn zedGraphControl1.Invalidate(); }
/// <summary> /// Creates a new CurveItem using the PointPairList and add it the the given pane. /// </summary> /// <param name="pane">the GraphPane object to which to add the new curve</param> /// <param name="points">a PointPairList collection defining the points for this curve</param> /// <returns>the newly created CurveItem added to the given GraphPane</returns> /// <remarks>This method must be overriden by childs</remarks> public override CurveItem CreateInPane( GraphPane pane, PointPairList points ) { HiLowBarItem x = pane.AddHiLowBar( this.Label, points, this.Color ); this.CopyTo( x ); return x; }
private void UpdateGraph() { var _graphData = new DataTable(); var con = new SqlConnection(Exacta.Menu.connectionString); SqlCommand cmd = new SqlCommand("getMinutesBetween", con); cmd.CommandType = CommandType.StoredProcedure; int.TryParse(selectedRow.Cells[0].Value.ToString(), out var machineID); DateTime stDate = new DateTime(Exacta.Menu.dateFrom.Year, Exacta.Menu.dateFrom.Month, Exacta.Menu.dateFrom.Day); cmd.Parameters.Add("@IDM", SqlDbType.Int).Value = machineID; cmd.Parameters.Add("@startDate", SqlDbType.Date).Value = stDate; cmd.Parameters.Add("@endDate", SqlDbType.Date).Value = stDate; con.Open(); var dr = cmd.ExecuteReader(); _graphData.Load(dr); dr.Close(); con.Close(); if (_graphData.Rows.Count <= 0) { return; } var myPane = new GraphPane(); myPane = zedGraphControl1.GraphPane; myPane.CurveList.Clear(); myPane.GraphObjList.Clear(); myPane.Fill = new Fill(); //legend myPane.Legend.Position = LegendPos.Bottom; myPane.Legend.FontSpec.Size = 20; myPane.Legend.Border.IsVisible = false; myPane.Title.Text = "Intervals between cuts"; //myPane.BarSettings.Type = BarType.Cluster; myPane.Title.FontSpec.FontColor = Color.Black; //x axis myPane.XAxis.Title.Text = "Minutes"; myPane.XAxis.Title.FontSpec.FontColor = Color.Red; myPane.XAxis.Title.FontSpec.Size = 20; myPane.XAxis.Title.FontSpec.IsBold = false; myPane.XAxis.Scale.MajorStep = 1; //myPane.XAxis.MinorTic.Size = 1; myPane.XAxis.Scale.Min = 7; myPane.XAxis.Scale.Max = 15; myPane.XAxis.MajorTic.IsInside = false; myPane.XAxis.MajorTic.IsOutside = true; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.Scale.Format = "HH:mm"; myPane.XAxis.Scale.MajorUnit = DateUnit.Minute; myPane.XAxis.Scale.MinorUnit = DateUnit.Minute; //y axis myPane.YAxis.Title.Text = "Quantity"; myPane.YAxis.Title.FontSpec.FontColor = Color.Green; myPane.YAxis.Title.FontSpec.Size = 20; myPane.YAxis.Title.FontSpec.IsBold = false; //myPane.YAxis.Scale.MajorStep = 1; //myPane.YAxis.MinorTic.Size = 0; var lstQty = new PointPairList(); var qt = new List <int>(); var xAxisVals = new List <DateTime>(); var dailyQty = _graphData.Rows.Count; foreach (DataRow row in _graphData.Rows) { int.TryParse(row[0].ToString(), out var minsBetween); DateTime.TryParse(row[1].ToString(), out var ts); XDate xScalDate = new XDate(ts); lstQty.Add(xScalDate, minsBetween); qt.Add(minsBetween); xAxisVals.Add(xScalDate); } myPane.YAxis.Scale.Max = qt.Max() + 4; myPane.XAxis.Scale.Max = xAxisVals.Max().ToOADate(); myPane.XAxis.Scale.Min = xAxisVals.Min().ToOADate(); myPane.AddHiLowBar(string.Empty, lstQty, Color.Black); var position = 0; foreach (var bar in lstQty) { if (bar.Y != 0) { var barTime = xAxisVals.ElementAt(position).ToString("H:mm"); TextObj barLabel = new TextObj(barTime, bar.X, bar.Y + 1); barLabel.FontSpec.Size = 9; barLabel.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(barLabel); } position++; } myPane.Fill = new Fill(Color.FromArgb(250, 250, 255)); zedGraphControl1.AxisChange(); zedGraphControl1.Refresh(); }