Dear Sir
I have issue when generate google Chart.
Could not shown google Chart and error: Loading Data Try again.
Please advice me.
thank you.
Maideen
<script>
var chartData_P;
google.load("visualization", "1", { packages: ["corechart"] });
$(document).ready(function () {
$.ajax({
url: "default.aspx/LoadByExecutive",
data: "",
dataType: "json",
type: "POST",
contentType: "application/json; chartset=utf-8",
success: function (data) {
chartData_P = data.d;
},
error: function () {
alert("Error loading data! Please try again.");
}
}).done(function () {
google.setOnLoadCallback(drawChart_P);
drawChart_P();
});
});
function drawChart_P() {
var data = google.visualization.arrayToDataTable(chartData_P);
var options = {
//title: "Company Revenue-Year",
pointSize: 5
};
var pieChart = new google.visualization.ColumnChart(document.getElementById('line_chart_1'));
pieChart.draw(data, options);
}
</script>
Code Bind Page
<WebMethod()>
Public Shared Function LoadByExecutive() As List(Of Object)
Dim query As String = "SELECT * FROM [JP_Core_DB].[dbo].[vw_Market_Revenue] " &
"WHERE YEARNO = '" & Date.Now.Year & "' and MarketEXE_Name ='" & Request.Cookies("username").Value & "'"
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
Dim CharData_AREA As New List(Of Object)()
CharData_AREA.Add(New Object() {"MarketExe_Name", "Value"})
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand(query)
cmd.CommandType = CommandType.Text
cmd.Connection = con
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
CharData_AREA.Add(New Object() {sdr("MarketExe_Name"), sdr("Value")})
End While
End Using
con.Close()
Return CharData_AREA
End Using
End Using
End Function