I have a website in which I use Visual Studio's built in charts to visualize data.
I use c# methods to provide the chart with a datasource. However, google charts require the data on javascript methods. I have done some research on how to provide the data to a javascript method but I came up empty.
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable('<%=t%>');
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
In this example I tried to create a data table called "t" on the c# side. I debugged and saw that data table is filled correctly but I keep getting "Table has no columns" error.
So, Can anyone provide a walkthrough on how to supply my MSSQL data into the javascript method used by google charts?
Thanks in advance