private void AddThresholdAnnotation(Charting.Chart chart, string name, double threshold, System.Drawing.Font font) { Charting.Axis axisX = chart.ChartAreas[0].AxisX; Charting.Axis axisY = chart.ChartAreas[0].AxisY2; Charting.StripLine stripLine = new Charting.StripLine (); stripLine.StripWidth = 0.0; stripLine.Interval = 0; stripLine.BorderColor = System.Drawing.Color.Red; stripLine.BorderDashStyle = Charting.ChartDashStyle.DashDotDot; stripLine.IntervalOffset = threshold * 100.0; axisY.StripLines.Add (stripLine); Charting.RectangleAnnotation ta = new Charting.RectangleAnnotation (); ta.Text = name; ta.IsSizeAlwaysRelative = false; ta.AxisX = axisX; ta.AxisY = axisY; ta.AnchorX = axisX.Maximum * (15.0 / 16.0); ta.AnchorY = threshold * 100.0; ta.Alignment = System.Drawing.ContentAlignment.MiddleCenter; ta.AnchorAlignment = System.Drawing.ContentAlignment.MiddleCenter; ta.ShadowOffset = 2; ta.Font = font; chart.Annotations.Add (ta); }
/// <summary> /// Adds an aspect ratio vertical line annotation. /// </summary> /// <param name="chart">The <see cref="Charting.Chart "/>.</param> /// <param name="name">The annotation text.</param> /// <param name="aspectRatio">The aspect ratio.</param> /// <param name="font">The font.</param> /// <param name="plotThresholds">if set to <c>true</c> plot threshold info.</param> /// <param name="isCrossover">if set to <c>true</c> is a crossover annotation.</param> private void AddARAnnotation(Charting.Chart chart, string name, double aspectRatio, System.Drawing.Font font, bool plotThresholds, bool isCrossover = false) { Charting.StripLine stripLine = new Charting.StripLine(); stripLine.StripWidth = 0.0; stripLine.Interval = 0; if (isCrossover) { stripLine.BorderColor = System.Drawing.Color.Red; stripLine.BorderDashStyle = Charting.ChartDashStyle.DashDotDot; } else { stripLine.BorderColor = System.Drawing.Color.Black; stripLine.BorderDashStyle = Charting.ChartDashStyle.Dash; } stripLine.IntervalOffset = aspectRatio; Charting.Axis axisX = chart.ChartAreas[0].AxisX; Charting.Axis axisY = chart.ChartAreas[0].AxisY; axisX.StripLines.Add (stripLine); double yRange = (axisY.Maximum - axisY.Minimum); Charting.RectangleAnnotation ta = new Charting.RectangleAnnotation(); ta.Text = name; ta.IsSizeAlwaysRelative = false; ta.AxisX = axisX; ta.AxisY = axisY; ta.AnchorX = aspectRatio; ta.AnchorY = axisY.Minimum + yRange * (15.0/16.0); ta.ShadowOffset = 2; ta.Font = font; if (isCrossover) ta.ForeColor = System.Drawing.Color.Red; chart.Annotations.Add (ta); }