有没有可能在WindowsForm Chart中绘制一个圆?
如下所示的方法调用非常好!
Graph.Series["circle"].Circle.Add(centerX, centerY, radius);

发布于 2019-10-24 11:10:09
我为自己创造了一份工作。也许这对某人有帮助
public void DrawCircle(Chart Graph, double centerX, double centerY, double radius, int amountOfEdges)
{
string name = "circle_" + centerX + centerY + radius + amountOfEdges;
// Create new data series
if (Graph.Series.IndexOf(name) == -1)
Graph.Series.Add(name);
// preferences of the line
Graph.Series[name].ChartType = SeriesChartType.Spline;
Graph.Series[name].Color = Color.FromArgb(0, 0, 0);
Graph.Series[name].BorderWidth = 1;
Graph.Series[name].IsVisibleInLegend = false;
// add line segments (first one also as last one)
for (int k = 0; k <= amountOfEdges; k++)
{
double x = centerX + radius * Math.Cos(k * 2 * Math.PI / amountOfEdges);
double y = centerY + radius * Math.Sin(k * 2 * Math.PI / amountOfEdges);
Graph.Series[name].Points.AddXY(x, y);
}
}例如,您可以将其称为
DrawCircle(Graph, 5, 4, 3, 30);大约30点应该足够得到一个漂亮的圆而不是多边形,但取决于你的图表的大小。
https://stackoverflow.com/questions/58538856
复制相似问题