谷歌图表-“;快速入门Hello World;不在IE8中渲染
Google charts - "Quick Start Hello World" not rendering in IE8
你好,我正在尝试运行谷歌图表快速入门,但它不会在IE8中呈现。
我可以看到谷歌图表确实创建了一些IE时髦的标记,但什么都没有显示。
指南位于https://developers.google.com/chart/interactive/docs/quick_start
是否需要一些额外的配置才能在IE8中运行?
IE8将回退到使用VML;从他们的画廊(https://developers.google.com/chart/interactive/docs/gallery):
这些图表基于纯HTML5/SVG技术(旧IE版本采用VML)
经过一点挖掘,看起来VML不会只是工作,所以试着把它放在js的开头(或者更好的是,作为html顶部的内联脚本):
document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', "#default#VML");
这个人也有同样的问题:我如何让VML在标准模式下工作?
根据谷歌图表文档,InternetExplorer8及更早版本有时会出现问题,原因有两个:
- IE8不支持SVG,因此Charts会故障转移到VML,即更为有限
- IE8的JavaScript不允许在列表
为了让它发挥作用,您需要添加vml命名空间并添加特定的css行为
<!--[if lte IE 8 ]>
<script type="text/javascript">
document.namespaces.add('vml', 'urn:schemas-microsoft-com:vml');
document.createStyleSheet().cssText =
'vml'':fill, vml'':path, vml'':shape, vml'':stroke' +
'{ behavior:url(#default#VML); display: inline-block; } ';
</script>
<![endif]-->
我仔细检查了一下,下面的例子是在Windows7上的IE8中工作的。但是,它最初会显示警告"为了帮助保护您的安全,Internet Explorer已限制此网页运行可能访问您的计算机的脚本或ActiveX控件。"只有在允许阻止的内容后,才会呈现饼图。
<html>
<head>
<!--Load the AJAX API-->
<!--[if lte IE 8 ]>
<script type="text/javascript">
document.namespaces.add('vml', 'urn:schemas-microsoft-com:vml');
document.createStyleSheet().cssText =
'vml'':fill, vml'':path, vml'':shape, vml'':stroke' +
'{ behavior:url(#default#VML); display: inline-block; } ';
</script>
<![endif]-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {
'packages': ['corechart']
});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
// Set chart options
var options = {
'title': 'How Much Pizza I Ate Last Night',
'width': 400,
'height': 300
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
相关文章:
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- 接受不在列表中的值-引导组合框
- 通过链接重定向不;我不在jstree中工作
- gulp-if-javascript文件,但不在gulp-useref的特定目录中
- 将不在模型中的数据返回到mvc控制器
- 当查询不在displayField中时,引导Ajax Typeahead不显示结果
- 当带有渲染器的DOM元素不在屏幕顶部时,移动了场景的坐标
- 选择不在GridView-ASP.NET中激发
- 如果助手不在,如何从Grunt中的代码中调用任务
- 在输入字段上有两个函数调用,一个在Blur上,一个不在Angular中
- Javascript-在文本区域中断,但不在段落中中断
- 将字符串拆分为;只要它's不在»«
- YouTube作为弹出窗口在桌面版本上播放,但不在移动设备上播放
- 如何在不在本地下载的情况下将url中提供的文件(pdf/doc)转换为json/string/base64格式
- 为什么不在浏览器上获得JQuery效果呢
- 点击选择Div不在IE上工作
- 为什么 JS 不在滚动时调用函数
- 为什么ngModelCtrl$脏不在我的指令中更新
- 谷歌图表-“;快速入门Hello World;不在IE8中渲染
- Dropbox下载在Hello.js中不起作用