Here is an example for adding Interactive Column Charts into your ASP.NET MVC Application using CanvasJS. Column Charts can have one or more Data Series. In case of more than one series, Data Points from different Series are placed next to one another and are differentiated by their color. In case of single series, each data point has a different color and it repeats after a certain interval.
Please refer to this tutorial for step by step instruction of adding charts to your ASP.Net MVC Application. We recommend that you download the Sample Visual Studio Project and try it on your own to understand the API better.
var chart = new CanvasJS.Chart("chartContainer", { . . data: [{ type: "column", dataPoints: [ { y: 6, label: "Apple" }, { y: 4, label: "Mango" }, { y: 5, label: "Orange" }, ] }] . . }
You can further customize these charts to enable features like Zooming, Panning, Exporting, etc. To know more about the available features, please refer to our getting started section.
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <script type="text/javascript" src="https://cdn.canvasjs.com/canvasjs.min.js"></script> <title>Column Chart</title> </head> <body> <div id="chartContainer"></div> <script type="text/javascript"> window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { theme: "light2", animationEnabled: true, title: { text: "Column Chart in ASP.Net MVC using CanvasJS" }, data: [ { type: "column", dataPoints: [ { y: 6, label: "Apple" }, { y: 4, label: "Mango" }, { y: 5, label: "Orange" }, { y: 7, label: "Banana" }, { y: 4, label: "Pineapple" }, { y: 6, label: "Pears" }, { y: 7, label: "Grapes" }, { y: 5, label: "Lychee" }, { y: 4, label: "Jackfruit" } ] } ] }); chart.render(); }; </script> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace ASPNET_MVC_Samples.Controllers { public class HomeController : Controller { public ActionResult Column() { return View(); } } }