我正在尝试使用jqplot库以及HTML,JS和CSS在我的ios xcode中创建一个饼图。在xcode模拟器中,我只能显示主HTML页面的警报,无法获得任何输出。在chrome borwser中运行html文件时,无法获得结果,但可以获取html文件和所有其他javascript文件的所有警报。
使用的html代码如下:
Devicepiechart.html:
<!DOCTYPE html>
<html lang="en">
<Head>
<title>Testing plots functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
<!-- BEGIN: load jquery -->
<script language="javascript" type="text/javascript" src="jquery-2.0.3.min.js"></script>
<script>
function load()
{alert("loading HTML scripts!");}
</script>
<script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
<script language="javascript" type="text/javascript" src="jqplot.pieRenderer.min.js"></script>
<!-- END: load jqplot -->
</head>
<body onload= "load()">
<div id="pie" style="margin-top:-15px; margin-left:-15px; width:335px; height:445px;"> </div> </body> </html>
其他css和js文件的代码下载并包含在项目中,devicepiechart.js文件如下:
$(document).ready(function(){
var data = [
['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
['Out of home', 16],['Commuting', 7], ['Orientation', 9]
];
var plot1 = jQuery.jqplot ('chart1', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});
所有其他js和css文件都包含在同一文件夹中。任何人都可以帮我在xcode和浏览器中创建饼图。提前谢谢。
答案 0 :(得分:0)
只需将所有.js文件加载到项目目标“构建阶段”的“复制包资源”中,而不是饼图在ios模拟器中成功运行。