最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do you run Google Charts locally? - Stack Overflow

programmeradmin1浏览0评论

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=".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.

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.

Share Improve this question edited Apr 1, 2017 at 8:16 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Dec 16, 2016 at 14:36 leoraleora 197k367 gold badges906 silver badges1.4k bronze badges 2
  • 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 Commented Dec 16, 2016 at 14:53
  • I would use a javascript charting library such as d3 (free), jqplot (free) or highcharts (pay) – Youn Elan Commented Dec 17, 2016 at 18:36
Add a comment  | 

3 Answers 3

Reset to default 9

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

Off line use is not allowed.

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.

No you can not check the url and attach image Google FAQ

发布评论

评论列表(0)

  1. 暂无评论