- mvc_chart1.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
- Site.css
- Controllers
- Default.aspx
- Default.aspx.cs
- Global.asax
- Global.asax.cs
- Models
- _svn
- entries
- format
- prop-base
- props
- text-base
- tmp
- prop-base
- props
- text-base
- StaticModel.cs
- Mvc_Chart.csproj
- Mvc_Chart.csproj.user
- Properties
- _svn
- entries
- format
- prop-base
- props
- text-base
- AssemblyInfo.cs.svn-base
- tmp
- prop-base
- props
- text-base
- AssemblyInfo.cs
- Scripts
- Views
- _svn
- entries
- format
- prop-base
- props
- text-base
- Web.config.svn-base
- tmp
- prop-base
- props
- text-base
- Account
- Home
- Shared
- Web.config
- Web.config
- Mvc_Chart.zip
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.IO;
using System.Web.UI.DataVisualization.Charting;
using System.Drawing;
using System.Data.OleDb;
using System.Data;
using System.Data.SqlClient;
namespace Mvc_Chart.Controllers
{
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewData["Title"] = "Home Page";
ViewData["Message"] = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
ViewData["Title"] = "About Page";
return View();
}
public ActionResult XamlOnly()
{
ViewData["Title"] = "XamlOnly";
CreateList();
return View();
}
public ActionResult XamlAndCodeBehind()
{
ViewData["Title"] = "XamlAndCodeBehind";
CreateList();
return View();
}
public ActionResult ControllerStream()
{
ViewData["Title"] = "ControllerStream";
CreateList();
return View();
}
public FileResult GetChart()
{
CreateList();
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
//Chart2.BorderSkin.SkinStyle = BorderSkinStyle.None;
Chart2.Width = 412;
Chart2.Height = 296;
Chart2.RenderType = RenderType.ImageTag;
Chart2.Palette = ChartColorPalette.BrightPastel;
Title t = new Title("IMG source streamed from Controller", 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.BorderlineWidth = 2;
Chart2.BorderColor = System.Drawing.Color.Black;
Chart2.BorderlineDashStyle = ChartDashStyle.Solid;
Chart2.BorderWidth = 2;
Chart2.Legends.Add("Legend1");
MemoryStream imageStream = new MemoryStream();
Chart2.SaveImage(imageStream, ChartImageFormat.Png);
return new FileResult("Yo.png", "image/png", imageStream.ToArray());
}
private void CreateList()
{
List<int> c_data = new List<int>();
c_data.Add(1);
c_data.Add(6);
c_data.Add(4);
c_data.Add(3);
ViewData["Chart"] = c_data;
}
}
}
|
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.
Contractor in Desktop and Web applications.
Gold Coast, Queensland.