CanvasJS supports Axis Scale Breaks that removes large chunks of the axis making readability of graphs, with large amplitude, easier. Given example shows Axis Scale Break 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", { animationEnabled: true, theme: "light1", title: { text: "Melting Point of Metals" }, axisY: { scaleBreaks: { autoCalculate: true, type: "wavy", lineColor: "black" }, gridThickness: 0, suffix: " °C" }, data: [{ type: "column", indexLabel: "{y} °C", dataPoints: @Html.Raw(ViewBag.DataPoints) }] }); 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("Aluminium", 600)); dataPoints.Add(new DataPoint("Antimony", 630)); dataPoints.Add(new DataPoint("Copper", 1084)); dataPoints.Add(new DataPoint("Gold", 1063)); dataPoints.Add(new DataPoint("Magnesium", 650)); dataPoints.Add(new DataPoint("Lead", 327.5)); dataPoints.Add(new DataPoint("Bismuth", 271.4)); dataPoints.Add(new DataPoint("Cadmium", 321)); dataPoints.Add(new DataPoint("Rhenium", 3186)); dataPoints.Add(new DataPoint("Selenium", 217)); dataPoints.Add(new DataPoint("Tungsten", 3400)); 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(string label, double y) { this.Label = label; this.Y = y; } //Explicitly setting the name to be used while serializing to JSON. [DataMember(Name = "label")] public string Label = ""; //Explicitly setting the name to be used while serializing to JSON. [DataMember(Name = "y")] public Nullable<double> Y = null; } }
You can add auto scale-breaks by setting autoCalculate to true. Some other commonly used customization options include collapsibleThreshold, spacing, type, color, etc.
Note For step by step instructions, follow our ASP.NET MVC Integration Tutorial