Error loading the google api chart in ASP.net

0

When I took the example from the site it worked, however when I add a new Webform and in a new project and paste the codes from the codebehind example in VB.NET and the aspx code does not work, it gives the alert message, I made some adaptations in collection of 3 points to make it easier to run the example. There are days I try. Can you help? Use visualStudio Express 2017

aspx code:

<%@ Page Title="" Language="vb" AutoEventWireup="false" 
MasterPageFile="~/Site.Master" CodeBehind="teste1.aspx.vb" 
Inherits="SIIv3.teste1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<
<script src="http://code.jquery.com/jquery-1.8.2.js"></script><scriptsrc="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
    google.load('visualization', '1', { packages: ['corechart'] });
</script>
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: 'POST',
            dataType: 'json',
            contentType: 'application/json',
            url: 'teste1.aspx/GetDadosGrafico',
            data: '{}',
            success:
            function (response) {
                drawchart(response.d);
            },
            error: function () {
                alert("Issue to load Data.");
            }
        });
    })
    function drawchart(dataValues) {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Column Name');
        data.addColumn('number', 'Column Value');
        for (var i = 0; i < dataValues.length; i++) {
            data.addRow([dataValues[i].Silos, dataValues[i].Total]);
        }
        new google.visualization.PieChart(document.getElementById('chartdiv')).
            draw(data, { title: "JcmSoft - Participação Mercado por País" });
    }
</script>



<div id="chartdiv" style="width: 590px; height: 201px;">
</div>


</asp:Content>

VB.NET codebehind

Imports System.Web.Services

Partial Class teste1
Inherits Page


<WebMethod>
Public Shared Function GetDadosGrafico() As List(Of DadosDetalhes)
    Dim listaDados As New List(Of DadosDetalhes)()

    Dim details As New DadosDetalhes With {
        .Silos = "silo",
        .Total = 13
    }
    listaDados.Add(details)

    details = New DadosDetalhes With {
        .Silos = "silo1",
        .Total = 20
    }
    listaDados.Add(details)

    details = New DadosDetalhes With {
        .Silos = "silo2",
        .Total = 5
    }
    listaDados.Add(details)

    Return listaDados
End Function

End Class

Public Class DadosDetalhes
    Public Property Silos() As String
    Public Property Total() As Integer
End Class
    
asked by anonymous 27.02.2018 / 02:03

0 answers