L A

L A

  • NA
  • 170
  • 171.1k

Unable to show Highcharts graph - ASP.Net MVC

Nov 2 2017 8:22 PM
Hi,
 
Trying to bind data to Highchart & display but couldn't show on webpage.
  1. <script type="text/javascript">    
  2.     $(document).ready(function () {    
  3.         $.ajax({    
  4.             url: '@Url.Action("getChartData", "Default")',    
  5.             dataType: 'json',    
  6.             type: 'GET',    
  7.             success: function (resData) {    
  8.                 debugger;    
  9.                 let dataArray = new Array();    
  10.                 for (let i in resData) {    
  11.                     let series = new Array(resData[i].ProductName, resData[i].ProductSales);    
  12.                     dataArray.push(series);    
  13.                 }    
  14.                 drawChart(dataArray);    
  15.             },    
  16.             error: function () {    
  17.                 alert('server could not process request');    
  18.             }    
  19.         });    
  20.     });    
  21.     
  22.     function drawChart(resData) {    
  23.         debugger;    
  24.         $('#highchartData').highcharts({    
  25.             chart: {    
  26.                 type: "column"    
  27.             },    
  28.             title: {    
  29.                 text: 'Product Sales for year 1997'    
  30.             },    
  31.             series: {    
  32.                 data: resData    
  33.             },    
  34.             plotOptions: {    
  35.                 column: {    
  36.                     dataLabels: { enabled: true }    
  37.                 }    
  38.             },    
  39.             xAxis: {    
  40.                 scrollbar: {    
  41.                     enabled: true    
  42.                 },    
  43.   
  44.             },    
  45.             credits: {    
  46.                 enabled: false    
  47.             },    
  48.             tooltip: {    
  49.                 pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'    
  50.             }    
  51.         });    
  52.     }    
  53. </script>
data returned from c# code as shown below.
 
 
 
graph doesn't show up
 
 
Couldn't figure out my mistake, your response is appreciated. Thanks

Answers (2)