简体   繁体   English

你如何在本地运行谷歌图表?

[英]How do you run Google Charts locally?

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. 所有示例都具有外部依赖性,我想避免这种情况,因为这是一个没有外部Internet访问的Intranet应用程序。

<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? 我可以简单地在本地复制loader.js,还是有一些我需要担心的更复杂的问题? 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. 我问的原因是我尝试这样做而且没有用,所以我试图弄清楚我所做的事情是否存在根本缺陷,或者我可能有一个无关的问题。

No. It is not allowed per the Google agreements https://developers.google.com/chart/interactive/faq 不可以。根据Google协议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. 你应该能够在本地运行图表/ loader.js并让它工作得很好。 I just copied and pasted its contents into a new js file and my charts rendered as normal. 我只是将其内容复制并粘贴到一个新的js文件中,我的图表正常呈现。

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/ 源代码太大,我无法在答案中用作片段,但这里有一个工作小提琴,它使用来自charts / loader.js的粘贴代码来创建表: 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的屏幕截图 Google FAQ 谷歌常见问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM