In ASP. net mvc, how does one use the Chart provided by Microsoft to build

Source: Internet
Author: User

Chart formation is a Chart formation company that Microsoft acquired in the past and then integrated into ASP. NET 4.0.

Of course, Microsoft also provides 2.0/3.5 Chart creation, but we only need to download and install it on our own. After all, it appears after the early framework.

Http://www.microsoft.com/downloads/details.aspx? FamilyId = 130F7986-BF49-4FE5-9CA8-910AE6EA442C & displaylang = en

Of course, this Chart is also set up in winForm.

ASP. NET is easy to use. A control. How can it be used in MVC ?!

Below is the basic implementation. We will explore many complicated functions later.

Ps: You can bypass it.

The following code implements MVC Action is roughly as follows:

View Code

 1      public FileResult GetChart()
2 {
3 List<int> data = Models.StaticModel.createStaticData();
4 System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
5 Chart2.Width = 412;
6 Chart2.Height = 296;
7 Chart2.RenderType = System.Web.UI.DataVisualization.Charting.RenderType.ImageTag;
8 Chart2.Palette = ChartColorPalette.BrightPastel;
9 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));
10 Chart2.Titles.Add(t);
11 Chart2.ChartAreas.Add("Series 1");
12 // create a couple of series
13 Chart2.Series.Add("Series 1");
14 Chart2.Series.Add("Series 2");
15 // add points to series 1
16 foreach (int value in data)
17 {
18 Chart2.Series["Series 1"].Points.AddY(value);
19 }
20 // add points to series 2
21 foreach (int value in data)
22 {
23 Chart2.Series["Series 2"].Points.AddY(value + 1);
24 }
25 Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
26 Chart2.BorderlineWidth = 2;
27 Chart2.BorderColor = System.Drawing.Color.Black;
28 Chart2.BorderlineDashStyle = ChartDashStyle.Solid;
29 Chart2.BorderWidth = 2;
30 Chart2.Legends.Add("Legend1");
31 MemoryStream imageStream = new MemoryStream();
32 Chart2.SaveImage(imageStream, ChartImageFormat.Png);
33 imageStream.Position = 0;
34 return new FileStreamResult(imageStream, "image/png");
35 }

There are many examples of how to use circles in ASP. NET. I searched for them. You can see:

Http://www.cnblogs.com/gaoweipeng/archive/2010/04/06/1704879.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.