我目前正在使用:
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);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句