Hello,
I get the "
Table has no columns " on get json by
asp.net for
Google chart.Could you help me here please ...? Thank you all! I am stuck here.
Method (2) I use the Url asp.net public string GetChartData() =>"
Table has no columns "
{ return JsonString;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
I. sampleData.json
{
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
}
------------------------------------------------------------------------------------------------------------------------------------
II. <script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load('current', { 'packages': ['corechart'] });
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "ColumnChart.aspx/GetChartData", // how could I read it it get the right type here ?
dataType: "json",
data: '{}',
success: function (response) {
drawchart(response.d); // calling method
},
error: function () {
alert("Error loading data! Please try again.");
}
//async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, { width: 400, height: 240 });
}
</script>
----------------------------------------------------------------------------------------------------
III. Asp.net
public string GetChartData()
{
return JsonString;
}
BR
Candy