Click here to Skip to main content
15,881,204 members
Articles / Web Development / ASP.NET

Streaming Chart Images as FileResult from MVC Controllers

Rate me:
Please Sign up or sign in to vote.
4.93/5 (11 votes)
10 Mar 2009CPOL2 min read 116.6K   1.5K   45  
Using a proper MVC pattern to stream an image from Microsoft Chart controls for the Microsoft .NET Framework 3.5.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="XamlAndCodeBehind.aspx.cs" Inherits="Mvc_Chart.Views.Home.XamlAndCodeBehind" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<asp:chart id="Chart1" runat="server" Height="296px" Width="412px" Palette="BrightPastel" imagetype="Png" BorderlineDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105">   
    <Titles>   
        <asp:Title Text="Markup and code behind" />   
    </Titles>   
    <legends>   
        <asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend>   
    </legends>   
    <borderskin skinstyle="Emboss"></borderskin>   
    <series>   
        <asp:Series Name="Column" BorderColor="180, 26, 59, 105">   
        </asp:Series>   
    </series>   
    <chartareas>   
        <asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom">   
            <area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>   
            <axisy linecolor="64, 64, 64, 64">   
                <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />   
                <majorgrid linecolor="64, 64, 64, 64" />   
            </axisy>   
            <axisx linecolor="64, 64, 64, 64">   
                <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />   
                <majorgrid linecolor="64, 64, 64, 64" />   
            </axisx>   
        </asp:ChartArea>   
    </chartareas>   
</asp:chart>  


</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Encore Software
Australia Australia
Contractor in Desktop and Web applications.
Gold Coast, Queensland.

Comments and Discussions