CanvasJS ASP.NET MVC Charts support multiple axes. Given example shows Range Spline Area & Spline Chart with multiple axes along with ASP.NET MVC 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: "light1", animationEnabled: true, title: { text: "Blood Pressure & Body Temperature Readings over a Day" }, axisY: { title: "Pressure (in mmHg)", maximum: 190, includeZero: true, gridThickness: 0 }, axisY2: { title: "Body Temperature (in °C)", suffix: " °C", gridThickness: 0 }, toolTip: { shared: true }, data: [{ type: "rangeSplineArea", xValueFormatString: "hh:MM TT", yValueFormatString: "# mmHg", toolTipContent: "{x}<br><b>Systolic:</b> {y[0]}<br><b>Diastolic:</b> {y[1]}", xValueType: "dateTime", dataPoints: @Html.Raw(ViewBag.DataPoints1) }, { type: "spline", axisYType: "secondary", name: "Body Temperature", yValueFormatString: "#.0 °C", toolTipContent: "<b>{name}:</b> {y}", xValueType: "dateTime", dataPoints: @Html.Raw(ViewBag.DataPoints2) }] }); chart.render(); } </script> </head> <body> <div id="chartContainer" style="height: 370px; width: 100%;"></div> <script 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.DataPoints1 = JsonConvert.SerializeObject(dataPoints); dataPoints = new List<DataPoint>(); dataPoints.Add(new DataPoint(1512441720000, 36.2)); dataPoints.Add(new DataPoint(1512447240000, 36.5)); dataPoints.Add(new DataPoint(1512453960000, 36.5)); dataPoints.Add(new DataPoint(1512461700000, 36.4)); dataPoints.Add(new DataPoint(1512466320000, 36.7)); dataPoints.Add(new DataPoint(1512472020000, 36.8)); dataPoints.Add(new DataPoint(1512475440000, 36.7)); dataPoints.Add(new DataPoint(1512477540000, 36.9)); dataPoints.Add(new DataPoint(1512482280000, 37.1)); dataPoints.Add(new DataPoint(1512486900000, 37.2)); dataPoints.Add(new DataPoint(1512490800000, 37.2)); dataPoints.Add(new DataPoint(1512494160000, 37)); ViewBag.DataPoints2 = 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, dynamic 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 dynamic Y = null; } }
axisXType / axisYType can be used to change the axis used for plotting a data-series. Some other commonly used customization options include axisXIndex, axisYIndex, showInLegend, etc.
Note For step by step instructions, follow our ASP.NET MVC Integration Tutorial