Spline Area Chart

ASP.NET MVC Spline Area Chart Sample using CanvasJS

Here is an example for adding Interactive Spline Area Charts into your ASP.NET MVC Application using CanvasJS. Spline Area is much like area chart except that its envelope is a smooth curve.

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.


Download ASP.Net MVC Chart Samples

var chart = new CanvasJS.Chart("chartContainer", {
.
.
data: [{
    type: "splineArea",
    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="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
    <title>Spline Area Chart</title>
</head>
<body>
    <div id="chartContainer"></div>

    <script type="text/javascript">
        window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer", {
                title: {
                    text: "Music Album Sales by Year"
                },
                animationEnabled: true,
                axisY: {
                    title: "Units Sold",
                    valueFormatString: "#0,,.",
                    suffix: " m"
                },
                data: [{
                    toolTipContent: "{y} units",
                    type: "splineArea",
                    markerSize: 5,
                    color: "rgba(54,158,173,.7)",
                    dataPoints: [
                        { x: new Date(1992, 0), y: 2506000 },
                        { x: new Date(1993, 0), y: 2798000 },
                        { x: new Date(1994, 0), y: 3386000 },
                        { x: new Date(1995, 0), y: 6944000 },
                        { x: new Date(1996, 0), y: 6026000 },
                        { x: new Date(1997, 0), y: 2394000 },
                        { x: new Date(1998, 0), y: 1872000 },
                        { x: new Date(1999, 0), y: 2140000 },
                        { x: new Date(2000, 0), y: 7289000 },
                        { x: new Date(2001, 0), y: 4830000 },
                        { x: new Date(2002, 0), y: 2009000 },
                        { x: new Date(2003, 0), y: 2840000 },
                        { x: new Date(2004, 0), y: 2396000 },
                        { x: new Date(2005, 0), y: 1613000 },
                        { x: new Date(2006, 0), y: 2821000 },
                        { x: new Date(2007, 0), y: 2000000 },
                        { x: new Date(2008, 0), y: 1397000 }
                    ]

                    //dataPoints: @Html.Raw(ViewBag.DataPoints),
                }
                ]
            });

            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 SplineArea()
        {
            return View();
        }
    }
}			


In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.