Skip to content
Loading
Now add the following script just below the div or inside the head tag in the page. We are basically creating the chart inside window’s onload event.
  1. "text/javascript">  
  2.    
  3.     window.onload = function () {  
  4.         var chart = new CanvasJS.Chart("chartContainer", {  
  5.             theme: "light2",  
  6.             animationEnabled: true,  
  7.             title: {  
  8.                 text: "Simple Column Chart in ASP.NET MVC"  
  9.             },  
  10.             subtitles: [  
  11.                 { text: "Try Resizing the Browser" }  
  12.             ],  
  13.             data: [  
  14.             {  
  15.                 type: "column", //change type to bar, line, area, pie, etc  
  16.                 dataPoints: [  
  17.                 { x: 10, y: 71 },  
  18.                 { x: 20, y: 55 },  
  19.                 { x: 30, y: 50 },  
  20.                 { x: 40, y: 65 },  
  21.                 { x: 50, y: 95 },  
  22.                 { x: 60, y: 68 },  
  23.                 { x: 70, y: 28 },  
  24.                 { x: 80, y: 34 },  
  25.                 { x: 90, y: 14 }  
  26.                 ]  
  27.             }  
  28.             ]  
  29.         });  
  30.         chart.render();  
  31.     };  
  32.   
Build and Run the solution to see the chart
 
Resource: https://canvasjs.com/docs/charts/integration/asp-net-mvc-charts/ 
0