Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » Samples » Downloads
 
Add your own
alternative version

Streaming Chart Images as FileResult from MVC Controllers

, 10 Mar 2009 CPOL
Using a proper MVC pattern to stream an image from Microsoft Chart controls for the Microsoft .NET Framework 3.5.
Mvc_Chart.zip
Mvc_Chart
_svn
dir-prop-base
entries
format
prop-base
props
text-base
Default.aspx.cs.svn-base
Default.aspx.svn-base
Global.asax.cs.svn-base
Global.asax.svn-base
Mvc_Chart.csproj.svn-base
Web.config.svn-base
tmp
prop-base
props
text-base
App_Data
_svn
entries
format
prop-base
props
text-base
tmp
prop-base
props
text-base
bin
Mvc_Chart.dll
Content
_svn
entries
format
prop-base
props
text-base
Site.css.svn-base
tmp
prop-base
props
text-base
Controllers
_svn
entries
format
prop-base
props
text-base
AccountController.cs.svn-base
FileResult.cs.svn-base
HomeController.cs.svn-base
tmp
prop-base
props
text-base
Global.asax
Models
_svn
entries
format
prop-base
props
text-base
tmp
prop-base
props
text-base
Mvc_Chart.csproj.user
Properties
_svn
entries
format
prop-base
props
text-base
AssemblyInfo.cs.svn-base
tmp
prop-base
props
text-base
Scripts
_svn
entries
format
prop-base
props
text-base
jquery-1.2.6.js.svn-base
jquery-1.2.6.min.js.svn-base
MicrosoftAjax.debug.js.svn-base
MicrosoftAjax.js.svn-base
MicrosoftMvcAjax.debug.js.svn-base
MicrosoftMvcAjax.js.svn-base
tmp
prop-base
props
text-base
Views
_svn
entries
format
prop-base
props
text-base
Web.config.svn-base
tmp
prop-base
props
text-base
Account
_svn
entries
format
prop-base
props
text-base
ChangePassword.aspx.cs.svn-base
ChangePassword.aspx.designer.cs.svn-base
ChangePassword.aspx.svn-base
ChangePasswordSuccess.aspx.cs.svn-base
ChangePasswordSuccess.aspx.designer.cs.svn-base
ChangePasswordSuccess.aspx.svn-base
Login.aspx.cs.svn-base
Login.aspx.designer.cs.svn-base
Login.aspx.svn-base
Register.aspx.cs.svn-base
Register.aspx.designer.cs.svn-base
Register.aspx.svn-base
tmp
prop-base
props
text-base
Home
_svn
entries
format
prop-base
props
text-base
About.aspx.cs.svn-base
About.aspx.designer.cs.svn-base
About.aspx.svn-base
ControllerStream.aspx.cs.svn-base
ControllerStream.aspx.designer.cs.svn-base
ControllerStream.aspx.svn-base
Index.aspx.cs.svn-base
Index.aspx.designer.cs.svn-base
Index.aspx.svn-base
XamlAndCodeBehind.aspx.cs.svn-base
XamlAndCodeBehind.aspx.designer.cs.svn-base
XamlAndCodeBehind.aspx.svn-base
XamlOnly.aspx.cs.svn-base
XamlOnly.aspx.designer.cs.svn-base
XamlOnly.aspx.svn-base
tmp
prop-base
props
text-base
Shared
_svn
entries
format
prop-base
props
text-base
Error.aspx.cs.svn-base
Error.aspx.designer.cs.svn-base
Error.aspx.svn-base
LoginUserControl.ascx.cs.svn-base
LoginUserControl.ascx.designer.cs.svn-base
LoginUserControl.ascx.svn-base
Site.Master.cs.svn-base
Site.Master.designer.cs.svn-base
Site.Master.svn-base
tmp
prop-base
props
text-base
Mvc_Chart1.zip
dir-prop-base
entries
format
Default.aspx.cs.svn-base
Default.aspx.svn-base
Global.asax.cs.svn-base
Global.asax.svn-base
Mvc_Chart.csproj.svn-base
Web.config.svn-base
entries
format
Mvc_Chart.dll
entries
format
Site.css.svn-base
entries
format
AccountController.cs.svn-base
FileResult.cs.svn-base
HomeController.cs.svn-base
Global.asax
entries
format
Mvc_Chart.csproj.user
entries
format
AssemblyInfo.cs.svn-base
entries
format
jquery-1.2.6.js.svn-base
jquery-1.2.6.min.js.svn-base
MicrosoftAjax.debug.js.svn-base
MicrosoftAjax.js.svn-base
MicrosoftMvcAjax.debug.js.svn-base
MicrosoftMvcAjax.js.svn-base
entries
format
Web.config.svn-base
entries
format
ChangePassword.aspx.cs.svn-base
ChangePassword.aspx.designer.cs.svn-base
ChangePassword.aspx.svn-base
ChangePasswordSuccess.aspx.cs.svn-base
ChangePasswordSuccess.aspx.designer.cs.svn-base
ChangePasswordSuccess.aspx.svn-base
Login.aspx.cs.svn-base
Login.aspx.designer.cs.svn-base
Login.aspx.svn-base
Register.aspx.cs.svn-base
Register.aspx.designer.cs.svn-base
Register.aspx.svn-base
entries
format
About.aspx.cs.svn-base
About.aspx.designer.cs.svn-base
About.aspx.svn-base
ControllerStream.aspx.cs.svn-base
ControllerStream.aspx.designer.cs.svn-base
ControllerStream.aspx.svn-base
Index.aspx.cs.svn-base
Index.aspx.designer.cs.svn-base
Index.aspx.svn-base
XamlAndCodeBehind.aspx.cs.svn-base
XamlAndCodeBehind.aspx.designer.cs.svn-base
XamlAndCodeBehind.aspx.svn-base
XamlOnly.aspx.cs.svn-base
XamlOnly.aspx.designer.cs.svn-base
XamlOnly.aspx.svn-base
entries
format
Error.aspx.cs.svn-base
Error.aspx.designer.cs.svn-base
Error.aspx.svn-base
LoginUserControl.ascx.cs.svn-base
LoginUserControl.ascx.designer.cs.svn-base
LoginUserControl.ascx.svn-base
Site.Master.cs.svn-base
Site.Master.designer.cs.svn-base
Site.Master.svn-base
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="XamlOnly.aspx.cs" Inherits="Mvc_Chart.Views.Home.XamlOnly" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">



  <%   
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();   
                  Chart2.Width = 412;   
                  Chart2.Height = 296;   
                  Chart2.RenderType = RenderType.ImageTag;   
  
                  Chart2.Palette = ChartColorPalette.BrightPastel;   
                  Title t = new Title("XAML Only", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));   
                  Chart2.Titles.Add(t);   
                  Chart2.ChartAreas.Add("Series 1");   
  
// create a couple of series   
                  Chart2.Series.Add("Series 1");   
                  Chart2.Series.Add("Series 2");   
  
// add points to series 1   
                  foreach (int value in (List<int>)ViewData["Chart"])   
                  {   
                      Chart2.Series["Series 1"].Points.AddY(value);   
                  }   
  
                  // add points to series 2   
                  foreach (int value in (List<int>)ViewData["Chart"])   
                  {   
                      Chart2.Series["Series 2"].Points.AddY(value + 1);   
                  }   
  
                  Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;   
                  Chart2.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);   
                  Chart2.BorderlineDashStyle = ChartDashStyle.Solid;   
                  Chart2.BorderWidth = 2;   
  
                  Chart2.Legends.Add("Legend1");   
  
// Render chart control   
                  Chart2.Page = this;   
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);   
Chart2.RenderControl(writer);   
  
               %>   
</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)

Share

About the Author

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

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 10 Mar 2009
Article Copyright 2009 by Nic_Roche
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid