如何使用MSChart对角绘制带状线?

时间:2014-12-05 15:32:18

标签: c# mschart

调整MS图表。我已成功绘制动态图表但需要在图表上绘制一条线(黄色)。我将如何画(黄色)线。我有X和Y值。 enter image description here

1 个答案:

答案 0 :(得分:0)

以下是您可以使用的示例:

// we create a general LineAnnotation, ie not Vertical or Horizontal:
LineAnnotation lan = new LineAnnotation();

// we use Axis scaling, not chart scaling
lan.IsSizeAlwaysRelative = false;

lan.LineColor = Color.Yellow;
lan.LineWidth = 5;

// the coordinates of the starting point in axis measurement
lan.X = 3.5d;
lan.Y = 0d;
// the size: 
lan.Width = -3.5d;
lan.Height = 5.5d;

// looks like we need an anchor point, no matter which..
lan.AnchorDataPoint = yourSeries.Points[0];

// now we can add the LineAnnotation;
chart1.Annotations.Add(lan);