我正在尝试在我的.NET 6 WinForm应用程序中创建图表,但在我的工具箱中找不到图表选项。 有人知道为什么会这样吗? .NET 6中是否删除了图表? 如果是这样,我该如何创建一个图表呢?谢谢。
我正在尝试在我的.NET 6 WinForm应用程序中创建图表,但在我的工具箱中找不到图表选项。 有人知道为什么会这样吗? .NET 6中是否删除了图表? 如果是这样,我该如何创建一个图表呢?谢谢。
private void PlotCoordinates(List<Coordinates> coordinateList, Pen pen)
{
List<Rectangle> boundingBoxes = GenerateBoundingBoxes(coordinateList);
using (Graphics g = Graphics.FromImage(image))
{
foreach (Rectangle boundingBox in boundingBoxes)
{
g.DrawEllipse(pen, boundingBox);
}
}
}
private List<Rectangle> GenerateBoundingBoxes(List<Coordinates> coordinateList)
{
var boundingBoxes = new List<Rectangle>(coordinateList.Count);
//dataPointDiameterPixels is the diameter you want your ellipse to be on the plot
//it needs to be an odd to be accurate
int dataPointCetralisingOffset = dataPointDiameterPixels / 2;
int rectLength = dataPointDiameterPixels;
foreach (Coordinates coordinates in coordinateList)
{
int topLeftX = Maths.Max(coordinates.X - dataPointCetralisingOffset, 0);
int topLeftY = Maths.Max(coordinates.Y - dataPointCetralisingOffset, 0);
var box = new Rectangle(topLeftX, topLeftY, rectLength, rectLength);
boundingBoxes.Add(box);
}
return boundingBoxes;
}
WinForms已经被弃用,其很多功能没有被包含在.NET 6中。目前没有改变这一决定的计划。如果您找到了替代方案,请分享。