Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Código de Google App Script para crear un gráfico circular a partir de datos de hojas de cálculo que no aparecen

Es solo un proyecto de script simple que se supone que crea un gráfico circular a partir de los datos en una hoja de cálculo. Lo tenía funcionando cuando construí DataTable dentro del archivo HTML, pero traté de ajustarlo con una consulta para extraer los datos de una hoja de cálculo y hacer que el tablero sea dinámico con cambios en la hoja de cálculo.

Sin embargo, cada vez que lo implemento, solo aparece como una pantalla en blanco. ¡Cualquier ayuda/pensamiento es apreciada! al final lo conseguire...

Código de archivo HTML:

 <html> <head> <!--Load the AJAX API--> <script src="https://www.gstatic.com/charts/loader.js"></script> <script> google.charts.load('current', {packages: ['corechart']}); google.charts.setOnLoadCallback(drawChart); function initialize() { var opts = {sendMethod: 'auto'}; // Replace the data source URL on next line with your data source URL. var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1BiNoiV10xrAU8PwdJfgldneLwFuCnY5GhQRDEIzftd8/edit#gid=0', opts); } // Send the query with a callback function. function handleQueryResponse(response) { if (response.isError()) { alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } var data = response.getDataTable(); // Set chart options var options = {'title':'How Much Pizza I Ate Last Night', 'width':400, 'height':300}; // Instantiate and draw our chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); google.visualization.events.addListener(chart, 'select', selectHandler); chart.draw(data, options); } //enter alert on user screen when clicking on section of chart function selectHandler() { var selectedItem = chart.getSelection()[0]; var value = data.getValue(selectedItem.row, 0); alert('The user selected ' + value); } </script> </head> <body> <!--Div that will hold the pie chart--> <div id="chart_div" style="width:400; height:300"></div> </body> </html>

Código de archivo JS:

 function doGet() { return HtmlService.createHtmlOutputFromFile('webappchartv2'); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  • Falta query.send(handleQueryResponse);
  • setOnLoadCallback no está configurado correctamente
 google.charts.load('current', {packages: ['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var opts = {sendMethod: 'auto'}; // Replace the data source URL on next line with your data source URL. var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1BiNoiV10xrAU8PwdJfgldneLwFuCnY5GhQRDEIzftd8/edit#gid=0', opts); query.send(handleQueryResponse); } ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!