保存图像使用.NET图 [英] Save Image Using .net Chart

查看:112
本文介绍了保存图像使用.NET图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从图表图形保存图像。
我使用下面的行。

  chart.SaveImage(D:\\\\ mypic.png,System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);

但我有一个问题:

下面是我的code。

 保护无效btnBar_Click(对象发件人,EventArgs的发送)
{
    字符串degerler = txtDeger.Text;
    ArrayList的阵列=新的ArrayList();    如果(Convert.ToInt32(TextBox2.Text)GT; Convert.ToInt32(TextBox1.Text))
    {
        Label3.Text =TopNCount浏览量比于克olamaz ......;
    }
    其他
    {
        Label3.Text =;        的for(int i = 1; I< Convert.ToInt32(TextBox1.Text)+ 1;我++)
        {
            array.Add(Convert.ToInt32(degerler.Split(,)[I - 1]));
        }        chart.ChartType = myChart.ChartTypes.Bar;
        chart.TopNCount = Convert.ToInt32(TextBox2.Text);
        chart.DataSource =阵列;
        chart.DataBind();
        chart.SaveImage(D:\\\\ mypic.png,System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
        this.Controls.Add(图)
    }
}


解决方案

别人有这样的问题:

<一个href=\"http://social.msdn.microsoft.com/Forums/en/MSWinWebChart/thread/6ca0a897-4ffe-4c67-851e-6002ee4af19d\" rel=\"nofollow\">http://social.msdn.microsoft.com/Forums/en/MSWinWebChart/thread/6ca0a897-4ffe-4c67-851e-6002ee4af19d

看来,图表控件无法找到用于图表背景。

如果这就是问题所在,也许你可以举报微软连接网站上的不正确异常消息。

I want to save image from chart graphic. I'm using following line.

chart.SaveImage("D:\\mypic.png", System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);

but I have a problem:

Here is my code.

protected void btnBar_Click(object sender, EventArgs e)
{
    string degerler = txtDeger.Text;
    ArrayList array = new ArrayList();

    if (Convert.ToInt32(TextBox2.Text) > Convert.ToInt32(TextBox1.Text))
    {
        Label3.Text = "TopNCount sayısı büyük olamaz...";
    }
    else
    {
        Label3.Text = "";

        for (int i = 1; i < Convert.ToInt32(TextBox1.Text) + 1; i++)
        {
            array.Add(Convert.ToInt32(degerler.Split(',')[i - 1]));
        }

        chart.ChartType = myChart.ChartTypes.Bar;
        chart.TopNCount = Convert.ToInt32(TextBox2.Text);
        chart.DataSource = array;
        chart.DataBind();
        chart.SaveImage("D:\\mypic.png", System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
        this.Controls.Add(chart);    
    }
}

解决方案

Someone else had that problem:

http://social.msdn.microsoft.com/Forums/en/MSWinWebChart/thread/6ca0a897-4ffe-4c67-851e-6002ee4af19d

It seems that the chart control wasn't able to locate the background used for the chart.

If that's the problem, maybe you could report the incorrect exception message on the Microsoft Connect website.

这篇关于保存图像使用.NET图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆