C# Winform:导出带有SaveImage的图形,包括轴和标题

C# Winform:导出带有SaveImage的图形,包括轴和标题,c#,winforms,visual-studio,C#,Winforms,Visual Studio,我目前正在使用: chart.SaveImage(exportData.FileName.ToString(),System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Png); 以windows窗体将图表另存为.png文件。目前遇到的问题是图表缺少轴和标题等。图像显示的是Visual Studio中包含数据的图形和保存的图像。如您所见,我在保存的图像中缺少轴和标题。任何帮助都将不胜感激。多谢各位 visual stud

我目前正在使用:

chart.SaveImage(exportData.FileName.ToString(),System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Png);
以windows窗体将图表另存为.png文件。目前遇到的问题是图表缺少轴和标题等。图像显示的是Visual Studio中包含数据的图形和保存的图像。如您所见,我在保存的图像中缺少轴和标题。任何帮助都将不胜感激。多谢各位

visual studio中的图形:

通过SaveImage导出的图形:
我想你可以使用DrawToBitmap方法。您还可以在图表画布上添加自定义图形和文本:

using (Bitmap im = new Bitmap(chart1.Width, chart1.Height))
{                
    chart1.DrawToBitmap(im, new Rectangle(0, 0, chart1.Width, chart1.Height));
    using (Graphics gr = Graphics.FromImage(im))
    {
        gr.DrawString("Test", 
            new Font(FontFamily.GenericSerif, 10, FontStyle.Bold), 
            new SolidBrush(Color.Red), new PointF(10, 10));
    }
    im.Save(path);                                    
}
此代码正在生成该图像:

你可以试着去看一看