Google 将用于 Google 可视化的文件保存在哪里?我可以将其设置为我网站的本地文件吗?另外,有没有让仪表在 IE 中工作的代码示例?

发布于 2024-10-17 23:18:25 字数 1586 浏览 3 评论 0原文

编辑
请在此处查看生成的 html 和 Javascript:
http://jsfiddle.net/GregMcNulty/K6Vrb/1/

根据此评论 4 - 开头的评论文件 导致问题。

我的问题是,这是哪个文件以及何时加载?

我加载的唯一文件是:https://www.google.com/jsapi,如< href="http://code.google.com/apis/visualization/documentation/gallery/gauge.html#Example" rel="nofollow">示例。

因此,如果我能弄清楚它的调用时间和方式,我可以将其作为我网站上的本地文件,而不是从谷歌调用它......并编辑它以删除注释,这样我就可以让谷歌仪表正常工作在IE中?

谢谢。

不确定为什么将元数据放入头部对我也不起作用?这应该在所有情况下都有效吗?

任何人都有一个具体的例子可以展示他们如何让谷歌可视化/图表与 IE 一起使用?

没有任何文档类型的头部,但是,它使身体的其余部分(未显示)变得非常糟糕......

<html>
<head><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />  
<title>
    Your Levels
</title>

     <!-- Google JavaScript for gauges -->
       <script src='http://www.google.com/jsapi' type='text/javascript' ></script>   
    <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>



</head>


<body>

    <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  

等等......

EDIT
Please see the produced html and Javascript here:
http://jsfiddle.net/GregMcNulty/K6Vrb/1/

According to this Comment 4 - the comment at the beginning of the file is causing issues.

My question is, which file is this and when does it get loaded?

The only file I load is: https://www.google.com/jsapi as shown in the example.

So if I can figure out when and how it is called, can I make this a local file on my site instead of calling it from google.... and edit it to remove the comments, so i can get the google gauges to work in IE?

Thanks.

Not sure why putting the meta data in the head is not working for me either? Should that work in all cases?

Anyone have a specific example they can show how they got the google visualization/charts working with IE?

The head without any doc type, however, it renders the rest of the body (not shown) terribly...

<html>
<head><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />  
<title>
    Your Levels
</title>

     <!-- Google JavaScript for gauges -->
       <script src='http://www.google.com/jsapi' type='text/javascript' ></script>   
    <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>



</head>


<body>

    <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  

...etc...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开柳相依 2024-10-24 23:18:25

解决办法很简单。

注释中的 DOCTYPE 是您的网页中的 DOCTYPE。调用 Google Visualization javascript 的那个。

证明:

  1. 以 Google Visualization 页面上的 Gauge 为例。
  2. 将其剪切并粘贴到桌面上的文件 g.html 中,
  3. 添加任何 DTD 位于 HTML 标记顶部。
  4. 在IE8中打开=>工程
  5. 添加如图3所示的DTD =>破碎的。

因此,基本上,要使其正常工作,请在 IE8 中省略 html 开始标记之前的 DTD。

我尝试过其他 DTD,尤其是 xhtml 1 strict,已知它可以使 IE 表现良好。还没有运气。

更新

顺便说一句,当我添加由 Visual Studio(古董 4.01)插入的 dtd 时,它仍然有效。
我还添加了您的标题。下面的文件对我来说在 IE8 中运行良好。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>
    Your Levels
</title>
     <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
        google.load('visualization', '1', { packages: ['gauge'] });
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Label');
            data.addColumn('number', 'Value');
            data.addRows(3);
            data.setValue(0, 0, 'Memory');
            data.setValue(0, 1, 80);
            data.setValue(1, 0, 'CPU');
            data.setValue(1, 1, 55);
            data.setValue(2, 0, 'Network');
            data.setValue(2, 1, 68);

            var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
            var options = { width: 400, height: 120, redFrom: 90, redTo: 100,
                yellowFrom: 75, yellowTo: 90, minorTicks: 5
            };
            chart.draw(data, options);
        }
    </script>
  </head>
  <body>
    <div id='chart_div'></div>
       <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  
       </form>
  </body>
</html>

The solution is easy.

The DOCTYPE in the comment is the DOCTYPE in your web page. The one that calls the Google Visualization javascript.

Proof:

  1. Take the Gauge example on the Google Visualization page.
  2. Cut and paste it in a file g.html on your desktop
  3. do not add any DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> on top of the HTML tag.
  4. Open it in IE8 => works
  5. add the DTD shown in 3 => broken.

So basically, to make it work, in IE8, omit the DTD before the html opening tag.

I've tried other DTDs, especially the xhtml 1 strict, known to make IE behave. No luck yet.

Update

By the way, when I add the dtd inserted by visual studio (antique 4.01) it still works.
I've also added your header. The file below works fine in IE8 for me.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>
    Your Levels
</title>
     <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
        google.load('visualization', '1', { packages: ['gauge'] });
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Label');
            data.addColumn('number', 'Value');
            data.addRows(3);
            data.setValue(0, 0, 'Memory');
            data.setValue(0, 1, 80);
            data.setValue(1, 0, 'CPU');
            data.setValue(1, 1, 55);
            data.setValue(2, 0, 'Network');
            data.setValue(2, 1, 68);

            var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
            var options = { width: 400, height: 120, redFrom: 90, redTo: 100,
                yellowFrom: 75, yellowTo: 90, minorTicks: 5
            };
            chart.draw(data, options);
        }
    </script>
  </head>
  <body>
    <div id='chart_div'></div>
       <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  
       </form>
  </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文