Karthik K

Karthik K

  • 1.2k
  • 479
  • 50.6k

How to pass the Json array result in google chart code ?

May 17 2024 8:57 AM

Hi All ,

        We have a taks to pass the json array value in the google chart . when we were trying to bind the database , how to assign the json array to that google chart. If anyone knows this guide us with sample . 

Sample code : 

$(function () {
    $.ajax({
        type: "POST",
        url: "InteractiveDashboard.aspx/Web_GetTotalSaleslist",
        data: '{}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess,
        failure: function (response)
        {
            //alert(response.d);
            alert("Error..1");

        },
        error: function (response)
        {
            

            alert("Error..2");
            alert(response);
        }
    });
});
function OnSuccess(response) {
  //  var jsonResult = JSON.stringify(response.d)
  //  alert(jsonResult);
    var jsonResult = JSON.parse(response.d);
    var jsonCount = jsonResult.length;

  
    for (var n = 0; n < jsonCount; n++)
        {
        var _Month = jsonResult[n].Month;
        var _TotalsalesAmt = jsonResult[n].TotalsalesAmt;

       }
    sessionStorage.setItem("JsonResult", JSON.stringify(jsonResult));
    // loop the jsonresult Here 
    drawBasic();


};
 

 Thanks in advance ,

K.Karthik.K 

 

 

 


Answers (3)