6

I am looking at using Google Charts to have scatter plot. All of the examples have external dependency, and I would like to avoid that as this is an intranet application that doesn't have external Internet access.

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
 <script type="text/javascript">
   google.charts.load('current', {packages: ['corechart']});
   google.charts.setOnLoadCallback(drawChart);
...
</script>

Can I simply just copy loader.js locally or is there something more complicated that I need to worry about here? The reason I ask is that I tried doing that and it's not working so I am trying to figure out if what I am doing is fundamentally flawed or I might have an unrelated issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
leora
  • 188,729
  • 360
  • 878
  • 1,366
  • When I implement JQuery's `DatePicker` offiline,I had to check in the .css file because the file has relatives URL's to images, I say this because you can check the downloaded files _(js, css, etc)_ and check if those has other (online) references. Also, I suggest you make this test: run your example and check the navigation and console tabs (F12 developer tool) and check if there are lost requests and or errors. Hope it helps. – Mauricio Arias Olave Dec 16 '16 at 14:53
  • I would use a javascript charting library such as d3 (free), jqplot (free) or highcharts (pay) – Youn Elan Dec 17 '16 at 18:36

3 Answers3

9

No. It is not allowed per the Google agreements https://developers.google.com/chart/interactive/faq

Off line use is not allowed.

Kevin Brown
  • 8,805
  • 2
  • 20
  • 38
  • 1
    Although this is the right answer, I do find Google linking to developer terms a bit misleading since the also clearly state that this is licensed under the Creative Commons Attribution 3.0 License https://creativecommons.org/licenses/by/3.0/ which not only would allow you to load it locally but also allow you to freely change it to your liking. – Tim Wickstrom Dec 07 '18 at 22:35
  • It's interesting that Google, again, hits it's own legs. Their CSP Evaluator tool raises as high risk of allowing www.gstatic.com on script-src in Content Security Policy – qdev Mar 06 '20 at 19:18
4

You should be able to run charts/loader.js locally and have it work just fine. I just copied and pasted its contents into a new js file and my charts rendered as normal.

The source code is too large for me to use as a snippet in the answer, but here's a working fiddle that uses the pasted code from charts/loader.js to create a table: https://jsfiddle.net/q078fvw1/

If you right click on the file in your header that reads

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

This ought to work.

If not, then it's probably something on your system that's causing the interference.

Edit: While my answer might be literally correct vis a vis being able to use the source code locally, I wasn't making any recommendations with regards to whether or not this is the best thing to do.

As another poster pointed out, if it's in their service agreement not to use it locally then it's wise to comply with their terms.

Jonathan Bechtel
  • 3,497
  • 4
  • 43
  • 73
  • 1
    I'm not so sure since they also clearly state it is released under the Creative Commons Attribution 3.0 License creativecommons.org/licenses/by/3.0 which not only would allow you to load it locally but also allow you to freely change it to your liking. – Tim Wickstrom Dec 07 '18 at 22:37
  • 1
    "You should be able to run `charts/loader.js` locally and have it work just fine." is technically correct... but that Google Charts loader will _load_ a couple of other JavaScript assets - hence the name "loader". Those assets still will be requested from `https://www.gstatic.com` (if you didn't modify `loader.js`). Nevertheless, hosting Google Charts library files locally is against the ToS. – Jochem Schulenklopper Aug 26 '20 at 14:25
2

No you can not check the url and attach imageScreenshot of google faq Google FAQ