Range Spline Area Chart is same as Range Area Chart except that it uses smooth curves for enclosing. Given example shows ASP.NET MVC Range Spline Area chart along with source code that you can try running locally.
@{ Layout = null; } <!DOCTYPE HTML> <html> <head> <script> window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { theme: "light2", // "light1", "dark1", "dark2" animationEnabled: true, title: { text: "Blood Pressure Readings over a Day" }, axisY: { title: "Pressure (in mmHg)", includeZero: true, maximum: 190 }, data: [{ type: "rangeSplineArea", xValueFormatString: "hh:MM TT", yValueFormatString: "#,##0.## mmHg", toolTipContent: "{x}<br><b>Systolic:</b> {y[0]}<br><b>Diastolic:</b> {y[1]}", xValueType: "dateTime", dataPoints: @Html.Raw(ViewBag.DataPoints) }] }); chart.render(); } </script> </head> <body> <div id="chartContainer" style="height: 370px; width: 100%;"></div> <script type="text/javascript" src="https://cdn.canvasjs.com/canvasjs.min.js"></script> </body> </html>
using ASPNET_MVC_ChartsDemo.Models; using Newtonsoft.Json; using System.Collections.Generic; using System.Web.Mvc; namespace ASPNET_MVC_ChartsDemo.Controllers { public class HomeController : Controller { // GET: Home public ActionResult Index() { List<DataPoint> dataPoints = new List<DataPoint>(); dataPoints.Add(new DataPoint(1512441720000, new double[] { 120, 78 })); dataPoints.Add(new DataPoint(1512447240000, new double[] { 139, 89 })); dataPoints.Add(new DataPoint(1512453960000, new double[] { 139, 85 })); dataPoints.Add(new DataPoint(1512461700000, new double[] { 150, 95 })); dataPoints.Add(new DataPoint(1512466320000, new double[] { 130, 84 })); dataPoints.Add(new DataPoint(1512472020000, new double[] { 138, 87 })); dataPoints.Add(new DataPoint(1512475440000, new double[] { 127, 78 })); dataPoints.Add(new DataPoint(1512477540000, new double[] { 119, 76 })); dataPoints.Add(new DataPoint(1512482280000, new double[] { 135, 82 })); dataPoints.Add(new DataPoint(1512486900000, new double[] { 122, 78 })); dataPoints.Add(new DataPoint(1512490800000, new double[] { 115, 72 })); dataPoints.Add(new DataPoint(1512494160000, new double[] { 122, 75 })); ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints); return View(); } } }
using System; using System.Runtime.Serialization; namespace ASPNET_MVC_ChartsDemo.Models { //DataContract for Serializing Data - required to serve in JSON format [DataContract] public class DataPoint { public DataPoint(double x, double[] y) { this.X = x; this.Y = y; } //Explicitly setting the name to be used while serializing to JSON. [DataMember(Name = "x")] public Nullable<double> X = null; //Explicitly setting the name to be used while serializing to JSON. [DataMember(Name = "y")] public double[] Y = null; } }
Index / Data Labels can be enabled for the data-points by using the indexLabel property. Other commonly used customization options include showInLegend, legendText, toolTipContent, etc.
Note For step by step instructions, follow our ASP.NET MVC Integration Tutorial