javascript - html 文件中的动态电子表格 ID
问题描述
我正在使用 gs 显示图表,我使用的数据来自同一个电子表格:
function ruptureTraca() {
var ui = HtmlService.createHtmlOutputFromFile('ChartLine').setWidth(1350).setHeight(550);
SpreadsheetApp.getUi().showModelessDialog(ui,"Evolution Backlog");
}
ChartLine html 文件如下所示:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages: ["corechart", "line"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/[spreadSheet_ID]/edit?sheet=for%20Graph&headers=1');
...
我想将电子表格的 id 添加为变量,例如:
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/' + id + '/edit?sheet=for%20Graph&headers=1');
为了复制文件和图表功能将能够从新电子表格而不是原始电子表格中获取数据。
解决方案
您可以将 iddrawChart
作为参数添加到函数中...
function drawChart(id) {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/' + id + '/edit?sheet=for%20Graph&headers=1');
然后调用尽可能多的次数...
google.charts.load("current", {packages: ["corechart", "line"]});
google.charts.setOnLoadCallback(function () {
drawChart(id_1);
drawChart(id_2);
});
推荐阅读
- java - 使用用户输入填充 JTable
- excel - 使用 Excel 中的某些参数将值分配给列表
- amazon-sagemaker - Sagemaker 突然无法安装 python 包,缺少 python-dev
- javascript - 存储数据和组件数据不一样(vuex + 持久化状态)
- c++ - 抛出未处理的异常:写访问冲突:打印出数组元素
- python - Selenium 等到用户单击按钮
- c# - 根据c#中的给定字符串确定日期逻辑
- reactjs - UTF8 使用 AWS S3 和 Nextjs getStaticProps
- javascript - 如何在 Modal 上显示选中的单选按钮?
- c# - ASP.NET MVC 应用程序无法验证从 Azure AD 收到的令牌