Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

I am Jalpesh Vadgama a Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 6 years of experience in .NET Technology.
Browse by Tags · View All
#ASP.NET 88
#DOTNET 87
BRH 79
ASP.NET 72
#.NET 52
C#.NET 48
DOTNET 47
ASP.NET 4.0 31
ASP.NET MVC 29
VisualStudio 27

Archive · View All
December 2010 16
July 2011 13
April 2011 13
April 2012 12
January 2011 12
June 2011 11
May 2011 11
May 2012 8
February 2013 7
January 2013 7

Chart Helpers in ASP.NET MVC3

Aug 30 2011 4:00AM by Jalpesh   

I am exploring ASP.NET MVC3 and everyday I am learning something new. In today’s post I am going to explain how we can create chart with ASP.NET MVC3.

Chart is one of greatest way of expressing figures. We all need that functionality in any commercial application. I am still remembering old days with ASP.NET  where we have to use the third party controls for charts or we have to create it with the use of CSS and Server side controls. But now with ASP.NET MVC Helpers you can very easily create chart in few lines of code.

ASP.NET MVC Chart helper and other helpers comes inbuilt with the latest ASP.NET Tools update. If you don’t have ASP.NET MVC Chart helpers then you can find more information about it from here.

http://haacked.com/archive/2011/04/12/introducing-asp-net-mvc-3-tools-update.aspx

But still if you have not updated it then don’t worry about it. There is nuget package called “ASP.NET Webhelper Library”. You can add that package like following and still use same functionality.

ChartHelper-ASP.NET Web Helpers Library Pacakge

Now once you have all set for reference. We can start working on coding part. So draw a chart I have taken simple example like number of records vs time take chart. This Chart Helper support there types of cjart.

  1. Bar Chart
  2. Pie Chart
  3. Column Chart

In this example we are going to use Bar Chart. Following is code for that. I have create one simple action result called “DrawChart” which will return chart as PNG format.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Helpers;

namespace CodeSimplifiedTest.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult DrawChart()
        {
            var chart = new Chart(width: 400, height: 200)
                .AddSeries(
                            chartType: "bar",
                            xValue: new[] { "10 Records", "20 Records", "30 Records", "40 Records" },
                            yValues: new[] { "50", "60", "78", "80" })
                            .GetBytes("png");
            return File(chart, "image/bytes");
        }
    }
}

Here you can see that first I have included System.Web.Helper name space on top and then in DrawChart Action Result I have created chart variable where I have specified the height and width of chart and in add series method of it I have provided the chart type and x axis and y axis value. Now as we have to display it as image so for that I have used @URL.Action to point src to our Action Result DrawChart like following.

<img src="@Url.Action("DrawChart")" alt="Drawing chart with HTML Helper" />

Now let’s run this application in browser via pressing Ctrl+F5 and following is the output as expected.

Output

That’s it. You can see its very to create any kind of chart with Chart Helpers in ASP.NET MVC 3. Hope you like it. Stay tuned for more.. Till then happy programming and Namaste!!

Shout it

Tags: #DOTNET, #ASP.NET, ASP.NET, #.NET, ASP.NET MVC, WebHelper,


Jalpesh
15 · 11% · 3548
3 Readers Liked this
Sandeep Prajapati Liked this on 9/9/2011 7:30:00 AM
Profile · Blog · Facebook · Twitter
Pronojit Roy Liked this on 9/13/2011 5:34:00 AM
Profile · Facebook
jyotik Liked this on 2/8/2012 5:27:00 AM
Profile
3
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • Since long time I am working in making charts, convert these amazing figures in beautiful charts so that is can be easily understandable to everyone who need that. But yeah still ASP.NET MVC Chart helper is something very new to me and got to know certain different thing. chart library

    commented on Aug 29 2013 7:40AM
    JacobsRichard
    3047 · 0% · 2

Your Comment


Sign Up or Login to post a comment.

"Chart Helpers in ASP.NET MVC3" rated 5 out of 5 by 3 readers
Chart Helpers in ASP.NET MVC3 , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]