How to push map into dataArray?

13 views
Skip to first unread message

Nagendra Singh

unread,
Jun 18, 2017, 5:24:17 AM6/18/17
to Google Visualization API
The code is :

/**
* Created by Nagendra on 18-06-2017.
*/

google.charts.load('current', {packages: ['table']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

function drawChart() {

var jsonData = $.ajax({
url: "http://localhost:8989/getPMDResults",
dataType: "json",
crossDomain: true,
async: false
}).responseText;

var parsed = JSON.parse(jsonData);

var arr = [];

var reviewMap = {};

var dataArray = [['Class Name', 'Line Number', 'Code Review Result']];


/*for (var Key in parsed) {
//reviewMap[x] = parsed[x];
dataArray.push(['test'],['test'],['test']);
}*/


/*for (var x in parsed) {
arr.push(parsed[x]);
}
*/
/*var dataArray = [['Class Name', 'Line Number', 'Code Review Result']];
for (var i = 0; i < arr.length; i++) {
dataArray.push([arr[i]],[arr[i]],[arr[i]]);
}*/

var data = new google.visualization.arrayToDataTable(dataArray);
var chart = new google.visualization.Table(document.getElementById('pmd_reviewResult_div'));
chart.draw(data, {width: 400, height: 240});
}

I get the result from the ajax call as the following map:

Object {Test1.cls: Array(80), Test2.cls: Array(33)}

  1. Test1.cls:Array(33)
    1. 0:Object
      1. lineNumber:13
      2. reviewFeedback:" Apex classes should declare a sharing model if DML or SOQL is used"

How can I push the map object into data array with the 'Class Name 'as the map's key and the 'Line Number', 'Code Review Result' as the values from the map?
Reply all
Reply to author
Forward
0 new messages