谷歌是没有定义谷歌的图表

谷歌是没有定义谷歌的图表

本文介绍了未捕获的参考错误:谷歌是没有定义谷歌的图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载谷歌排行榜android应用。但是,这引发了我的错误,谷歌没有定义。下面是我的HTML文件,JavaScript文件。

I am trying to load Google charts in android application. But, it throws me error that google is not defined. Below is my HTML file and JavaScript file.

<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(临时)抛出这个错误。这个你知道吗?如何解决呢?我也试图保持google.Visulization内.js文件。但是,这也不能正常工作。如果我正在运行的浏览器相同的code,这是工作的罚款。难道问题与Android?

Here, google.visualization.arrayToDataTable(temp) throws this error. Any idea about this? how to resolve it? I also tried to keep google.Visulization inside .js file. But it also not working. If I am running the same code from Browser, it is working fine. Is it problem with android?

推荐答案

似乎有点陌生。尝试改变

Seems a bit strange. Try change

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

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

那么谷歌的对象应加载正确的。此外,你已经粘贴图表初始化从谷歌的图表,例如,

Then the google object should be loaded correct. Also, you have pasted chart initialization from a google chart-example,

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

但你唯一的HTML是

but your only HTML is

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

你错过了 chart_div ID

这篇关于未捕获的参考错误:谷歌是没有定义谷歌的图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 02:58