I am currently attempting to generate a Google pie chart using data extracted from an Excel sheet. The string that is returned is outlined below, which I am passing into
google.visualization.arrayToDataTable();
. Here is the code snippet that I have implemented:
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
var str = '<%= JSNstring %>'; //the string returned from C#.
var res= str.replace(/""/g,"'");
res=res.replace(/"/g,"'");
//
var ss=[res];
document.write(ss); //the output of this is:
[['Solution','TOTAL'],['Check',23],['FULL',18],['POP',109]]
function drawChart() {
var data = google.visualization.arrayToDataTable(ss);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
The issue I am encountering is as follows:
JavaScript runtime error: First row is not an array.
Please advise on what mistakes I may be making and how I can address them effectively. Thank you in advance.