2013-12-09 50 views
0

我想在我的ios xcode中使用jqplot庫以及HTML,JS和CSS創建一個餅圖。在xcode模擬器中,我無法獲得任何輸出,只是顯示主HTML頁面的警報。在chrome borwser中運行html文件時,無法獲得結果,但可以獲取html文件和所有其他javascript文件的所有警報。問題使用jsplot與html css和js在ios xcode上創建piechart問題

的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

只需將所有的.js文件加載到項目目標「bulid階段」的「複製捆綁資源」中,現在該餅圖已在ios模擬器中成功運行。