2013-07-08 8 views
2

Google 차트를 Android 애플리케이션에로드하려고합니다. 하지만, 그것은 구글이 정의되지 않은 오류를 throw합니다. 아래는 내 HTML 파일과 JavaScript 파일입니다.잡히지 않은 참조 오류 : google이 정의되지 않았습니다. Google 차트

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Patient Vitals</title> 

<link href="../../common/scripts/lib/css/jquery.mobile.theme-1.1.0.css" rel="stylesheet" type="text/css" /> 
<link href="../../common/scripts/lib/css/jquery.mobile-1.0.1.min.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" href="../../common/scripts/lib/css/jquery.mobile.datebox.css" /> 
<link href="../scripts/css.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 

<script src="../../common/scripts/jsapi.js" type="text/javascript"> 
    google.load('visualization', '1.0', {'packages':['corechart']}); 
</script> 
<script src="../scripts/patient_vitals.js"></script> 
</head> 
<body> 
     <div class="PT_Care_vitals_swa_ofcurv_left" onclick="getPatientVitalInfo();"</div> 
</body> 
</html> 

patient_vitals.js : 여기

getPatientVitalInfo =function() 
{ 
    logInformation("Get Patient Vital Information "); 
    alert("Get Patient Vital info"); 
    //code to retieve data from database 
    drawChart(temp); 
} 

drawChart = function(temp) 
{ 
    alert("Inside drawChart function"); 
    //Convert array int DataTable 
    var data = google.visualization.arrayToDataTable(temp); 
    rowCount = data.getNumberOfRows(); 
    // Instantiate and draw our chart, passing in some options. 
    chart = new google.visualization.LineChart(document.getElementById('chart_div')); 
    var options = {'tooltip': {'trigger':'none'}, 'year': "numeric", 'month':  "numeric",'day': "numeric", 'pointSize':5}; 
    //Function to perform select operation 

    //Drawing the chart in HTML page 
    chart.draw(data, options); 
}  

가 google.visualization.arrayToDataTable (TEMP)는이 에러를 던진다. 이것에 대한 어떤 생각? 그것을 해결하는 방법? 나는 또한 .js 파일 내에서 google.Visulization을 유지하려고 시도했다. 그러나 그것도 작동하지 않습니다. 브라우저에서 동일한 코드를 실행하고 있으면 정상적으로 작동합니다. 안드로이드에 문제가 있습니까?

답변

4

조금 이상하게 보입니다.

<script type="text/javascript" src="https://www.google.com/jsapi"></script> 
<script type="text/javascript">google.load('visualization', '1.0', {'packages':['corechart']});</script> 

<script src="../../common/scripts/jsapi.js" type="text/javascript"> 
    google.load('visualization', '1.0', {'packages':['corechart']}); 
</script> 

으로

가 그 다음 구글 객체가 올바른로드해야 변경하십시오. 또한, 당신은 구글 차트 예제 차트 초기화,

chart = new google.visualization.LineChart(document.getElementById('chart_div')); 

를 붙여 넣은하지만 단지 HTML을 사용하면 chart_div ID를 그리워

<div class="PT_Care_vitals_swa_ofcurv_left" onclick="getPatientVitalInfo();"</div> 

입니다

관련 문제