gpt4 book ai didi

javascript - 将自定义参数传递给 query.send Google 查询语言

转载 作者:行者123 更新时间:2023-12-03 06:37:18 25 4
gpt4 key购买 nike

我正在使用谷歌的图表 API 创建一个基于网络的仪表板。我想绘制许多图表,需要从此链接将自定义参数传递给handleDataQueryResponse函数:https://developers.google.com/chart/interactive/docs/spreadsheets#sheet-name 。该函数通过 query.send(handleDataQueryResponse) 调用来调用。我本以为我可以通过调用来做到这一点: query.send(function() { handleDataQueryResponse(parameters) });但这对我不起作用。有任何想法吗?接受其他方法来使查询及其处理程序可重用!

有关 google 的 javascript 图表 API 的更多信息:https://developers.google.com/chart/interactive/docs/quick_start .

最佳答案

这样的东西对你有用吗?

google.charts.load('current', {
callback: function () {
drawChart0();
drawChart1();
},
packages:['corechart', 'table']
});

function drawChart0() {
var chart = new google.visualization.BarChart(document.getElementById('barchart'));
var query = "http://www.google.com/fusiontables/gvizdata?tq=SELECT 'Label' as beach, 'Pieces total' as Total FROM 1c-FiEDwdwMt55a4AlE8Xuu40rUBR_qeI8ENiHtPV";
var options = {
animation: {
duration: 500,
startup: true,
easing: 'out'
},
chartArea: {
width: '40%'
}
};
sendQuery(query, chart, options);
}

function drawChart1() {
var chart = new google.visualization.Table(document.getElementById('tablechart'));
var query = "https://docs.google.com/spreadsheets/d/19olM1pEF5qQvvKhwSH3d_X4w2DVfOWDwDtZKNFlMY3w/edit#gid=0&tq=select A, B where A >= date '2016-01-01'";
var options = {};
sendQuery(query, chart, options);
}

function sendQuery(query, chart, options) {
new google.visualization.Query(query).send(function (response) {
chart.draw(response.getDataTable(), options);
});
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="barchart"></div>
<div id="tablechart"></div>

关于javascript - 将自定义参数传递给 query.send Google 查询语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38135081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com