I'm trying to display some data in Google Charts but get this error:
Data column(s) for axis #0 cannot be of type string..
This is my first time to use Google Chart in general and I am trying to use with ASP.NET Webforms and SQL Server. I have a WebMethod that returns the data from the database in a format of an array that is bound with Google Chart.
Here's the code of the script:
<script>
var chartData; // globar variable for hold chart data
google.load("visualization", "1", { packages: ["corechart"] });
// Here We will fill chartData
$(document).ready(function () {
$.ajax({
url: "../../Pages/Test.aspx/GetSentimentData",
data: "",
dataType: "json",
type: "POST",
contentType: "application/json; chartset=utf-8",
success: function (data) {
chartData = data.d;
},
error: function () {
alert("Error loading data! Please try again.");
}
}).done(function () {
// after complete loading data
google.setOnLoadCallback(drawChart3);
drawChart3();
});
});
function drawChart3() {
var data = google.visualization.arrayToDataTable(chartData);
var options = {
title: "Distribution of Sentiment Analysis Results",
hAxis: { title: 'University'},
vAxis: { title: 'Number of Tweets' },
pointSize: 5
};
var columnChart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
columnChart.draw(data, options);
}
</script>
So could you please tell me how I can create a Google Column Chart where each item in x-axis will have three series?