[英]How to draw rectangle over a plot?
是否可以使用OxyPlot绘制矩形? 就像是 :
还是OxyPlot不支持此功能?
的确可以。
有两种方法可以做到。 我希望使用注释,因为这还将为您提供突出显示的背景,并为您提供在此区域添加点击事件的选项。 如果您想使突出显示看起来像您提供的图像,则可能有一种方法来删除突出显示。
var Event = new PolygonAnnotation();
Event.Layer = AnnotationLayer.BelowAxes;
Event.StrokeThickness = 5;
Event.Stroke = OxyColor.FromRgb(0, 0, 255);
Event.LineStyle = LineStyle.Automatic;
Event.Points.Add(new DataPoint(X, Y));
Event.Points.Add(new DataPoint(X, Y));
Event.Points.Add(new DataPoint(X, Y));
Event.Points.Add(new DataPoint(X, Y));
另一种更简单的方法是创建线系列并将其赋予矩形的角。
为什么不只使用已经存在的RectangleAnnotation? 它提供填充,笔划,单击检测,文本。 范例:
model.Annotations.Add(new RectangleAnnotation { MinimumX = 20, MaximumX = 70, MinimumY = 10, MaximumY = 40, TextRotation = 10, Text = "RectangleAnnotation", Fill = OxyColor.FromAColor(99, OxyColors.Blue), Stroke = OxyColors.Black, StrokeThickness = 2 });
如果现有的注释不够好,您始终可以创建自己的自定义注释。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.