<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>!Dan Vallejo's WebLog! : ASP.NET</title><link>http://blogs.msdn.com/danvallejo/archive/tags/ASP.NET/default.aspx</link><description>Tags: ASP.NET</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Creating Charts in ASP.NET</title><link>http://blogs.msdn.com/danvallejo/archive/2003/08/04/51947.aspx</link><pubDate>Mon, 04 Aug 2003 22:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:51947</guid><dc:creator>DanVallejo</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/danvallejo/comments/51947.aspx</comments><wfw:commentRss>http://blogs.msdn.com/danvallejo/commentrss.aspx?PostID=51947</wfw:commentRss><description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;p&gt;
        I finished my first pass at the Advanced ASP.NET course. 
    &lt;/p&gt;
    &lt;p&gt;
        Here's a snippet of my section on graphics... 
    &lt;/p&gt;
    &lt;ol&gt;
        &lt;li&gt;
            &lt;p&gt;
                Add a new web form named Chart.aspx. 
            &lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;p&gt;
                Modify Page_Load as follows: 
            &lt;/p&gt;
            &lt;pre class="code"&gt;private void Page_Load(object sender, System.EventArgs e)
{
    Random r = new Random();

    // A. Create a bitmap object
    Bitmap bmp = new Bitmap(250,150);

    // B. Create a graphics object to draw on
    // based on the bitmap.
    Graphics g = Graphics.FromImage(bmp);

    // C. Draw on the graphics object
    g.FillRectangle(new SolidBrush(Color.Beige), 0,0, bmp.Width, bmp.Height);

    SolidBrush b = new SolidBrush(Color.Navy);
    Font f = new Font("Arial", 14);
    Font legend = new Font("Arial", 6);

    for (int x = 0; x &amp;lt; 10; x++)
    {
        int h = r.Next(1,100);

        // rectangles fill upside down
        g.FillRectangle(b, x*20, bmp.Height - h - 10, 15, h);

        g.DrawString((x+1).ToString(), legend, b, x*20, bmp.Height - 10);
    }

    g.DrawString("Hello World", f, new SolidBrush(Color.Red), 10, 10);

    // D. Save the bitmap to the response outputstream
    bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

    // E. Dispose of the objects
    g.Dispose();
    bmp.Dispose();
}&lt;/pre&gt;
        &lt;/li&gt;
        &lt;li&gt;
            Press F5 and navigate to the Chart.aspx page 
        &lt;/li&gt;
    &lt;/ol&gt;
    &lt;p&gt;
        Now how do you include the chart in another page?
    &lt;/p&gt;
    &lt;ol&gt;
        &lt;li&gt;
            &lt;p&gt;
                Open Default.aspx and drag an Image control on the bottom of the page.
            &lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;p&gt;
                Modify the ImageUrl property to Chart.aspx.
            &lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;p&gt;
                Press F5.
            &lt;/p&gt;
        &lt;/li&gt;
    &lt;/ol&gt;
    &lt;p&gt;
        Pretty cool!
    &lt;/p&gt;
&lt;/body&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=51947" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/danvallejo/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item></channel></rss>