【问题标题】:SaveImage of ChartControl without display It in the screenChartControl 的 SaveImage 不显示它在屏幕上
【发布时间】:2015-07-10 00:45:57
【问题描述】:

我想将 ChartControl 保存到 Image 中而不显示在屏幕上。

var theChart = new Chart();
var theSeries = new Series("values");
theSeries.IsVisibleInLegend = false;
theChart.Series.Add(theSeries);
theSeries.Points.AddXY(1, 1);
theSeries.Points.AddXY(2, 2);
theSeries.Points.AddXY(3, 3);
theChart.SaveImage(@"D:\Téléchargements\HiddenChart4.png", ChartImageFormat.Png);

然后我得到一张空白图片。我认为这是因为控件不是油漆。有可能吗?

【问题讨论】:

    标签: c# image controls microsoft-chart-controls


    【解决方案1】:

    这里是缺少部分的答案

    var theChart = new Chart();
    
            //missing part
            var chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
            theChart.ChartAreas.Add(chartArea1);
    
            var theSeries = new Series("values");
            theSeries.IsVisibleInLegend = false;
            theChart.Series.Add(theSeries);
            theSeries.Points.AddXY(1, 1);
            theSeries.Points.AddXY(2, 2);
            theSeries.Points.AddXY(3, 3);
            theChart.SaveImage(@"D:\Téléchargements\HiddenChart6.png", ChartImageFormat.Png);
    

    【讨论】:

      猜你喜欢
      • 2021-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多