Home › docs › charts › integration › ASP.NET MVC › chart types › Spline Chart

ASP.NET MVC Spline Chart Sample using CanvasJS

Here is an example for adding Interactive Spline Charts into your ASP.NET MVC Application using CanvasJS. Spline Charts are much like line charts except that the dataPoints are connected using smooth curves.

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: "spline",
    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>Spline Chart</title>
</head>
<body>
    <div id="chartContainer"></div>

    <script type="text/javascript">
        window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer", {
                theme: "light2",
                title: {
                    text: "Analysis of Pepper Export"
                },
                axisX: {
                    title: "Year"
                },
                axisY: {
                    title: "In Tonnes"
                },

                data: [
                {
                    type: "spline",
                    dataPoints: [
                    { y: 17363, label: "2005-06" },
                    { y: 28726, label: "2006-07" },
                    { y: 35000, label: "2007-08" },
                    { y: 25250, label: "2008-19" },
                    { y: 19750, label: "2009-10" },
                    { y: 18850, label: "2010-11" },
                    { y: 26700, label: "2011-12" },
                    { y: 16000, label: "2012-13" },
                    { y: 19000, label: "2013-14" },
                    { y: 18000, label: "2014-15" }
                    ],

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


If you have any questions, please feel free to ask in our forums.Ask Question