Plot with d3.js in Google Apps Script?

2019-07-18 21:00发布

问题:

Since Google Apps Script is in javascript, I was wondering if I could somehow import it and use it instead of the charting library.

回答1:

As of 2016, it works perfectly. Here is a simple example.

D3 within GAS

You can find the code here: github-D3-GAS



回答2:

Yes, in principle you can include any Javascript library you like. However, it must comply with Google's Caja sanitization - see the "JavaScript Libraries" subheading here. You will need to build your app using the Html Service and not Ui Service.


[Update 02/09/2015] The HtmlService has moved on a little since this was originally written. This page on restrictions details more about the 3 different sandbox modes. The IFRAME mode does not use the Caja sanitization.



回答3:

Yes you can import d3 and use it in Google Apps Script. To do so, you need to include it in your script as described here: https://github.com/d3/d3

Here is a hello world GAS script in Gist