I have a Google Pie Chart being populated by data from a List. This all works great with the exception that the chart legend is displaying NaN (not a number ???) rather than the intended Machine name as shown.
NaN.jpg
The javascript for building the array for the chart is shown in the code below.
Does anyone know why I'm getting NaN instead of the machine name? If I hard code the data, then it displays correctly, so I'm guessing it might be something to do with how the array is built in javascript,
NaN.jpg
The javascript for building the array for the chart is shown in the code below.
Code:
function doClinicalDowntime() { //Get data from List instead of xbasic call back //Initialize array header in string variable strdata. var strdata = "['Machine','Clinical Downtime']," var lObj = {dialog.object}.getControl('list1'); //number of rows in list. var count = lObj._rData.length; if (count == 0) { {dialog.Object}.setValue('PLACEHOLDER_1','No data found in your list. Check your data or filter settings' ); {dialog.Object}.setControlDisplay('STATICTEXT_1',false) return;} {dialog.Object}.setControlDisplay('STATICTEXT_1',false) //Loop through all rows of the list (selected and unselected) and build the array string. for (i=0;i<count;i++) { strdata = strdata + "['" + + lObj.getData(i).MachineDisplayName + "'," + + lObj.getData(i).SumClinicaldowntime + "]," ; } //remove last comma from bottom row. strdata = strdata.substring(0, strdata.length - 1); //enclose in brackets strdata="[" + strdata + "]"; {dialog.Object}.setValue('PLACEHOLDER_1',strdata); //Converts the string variable to a javascript object that google can consume as a parameter //Without this command, you will get "not an array error" var chartdataObj = eval ("(" + strdata + ")"); //PLACEHOLDER_1 used for no records found message. Clear any value {dialog.Object}.setValue('PLACEHOLDER_1',''); var data = google.visualization.arrayToDataTable(chartdataObj); {dialog.Object}.setControlDisplay('STATICTEXT_1',true); var options = { title: 'Clinical Downtime By Machine', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('QAChart')); chart.draw(data, options); }
Comment