You have a duplicate google.load call, so delete this:
<script type="text/javascript">
google.load('visualization', '1', {packages: ['gauge']});
</script>
I don't think that is the cause of your problem though. If it doesn't fix
the problem, comment out this line and see what happens:
json = JSON.parse(json);
On Thursday, January 9, 2014 2:09:04 PM UTC-5, Hystrix wrote:
>
> Full code:
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
> <title>
> Current Weather
> </title>
> <script type="text/javascript" src="//www.google.com/jsapi"></script>
>
> <script type="text/javascript" src="
> http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
> <script type="text/javascript">
> google.load('visualization', '1', {packages: ['gauge']});
> </script>
> <script type="text/javascript">
>
> function drawChart() {
> var data;
> var options = {
> width: 400,
> height: 120,
> };
>
> var chart = new
> google.visualization.Gauge(document.getElementById('chart_div'));
>
> function refreshData () {
> var json = $.ajax({
> url: 'http://mywebsite/weather/JSON.txt',
> dataType: 'json',
> async: false
> }).responseText;
>
>
> var rows = [['Label', 'Value']];
> json = JSON.parse(json);
> rows.push(['TempOut', json.TempOut]);
> rows.push(['FeelsLike', json.FeelsLike]);
> rows.push(['HumidityOut', json.HumidityOut]);
> rows.push(['WindAvg', json.WindAvg]);
> rows.push(['WindGust', json.WindGust]);
> rows.push(['Rain', json.Rain]);
> rows.push(['AbsPressure', json.AbsPressure]);
> var data = google.visualization.arrayToDataTable(rows);
>
> chart.draw(data, options);
> }
>
> refreshData();
> setInterval(refreshData, 1000);
> }
> google.load('visualization', '1', {packages: ['gauge'], callback:
> drawChart});
> </script>
> </head>
> <body>
> <div id="chart_div"></div>
> </body>
> </html>
>
> On Thursday, January 9, 2014 7:03:35 PM UTC, asgallant wrote:
>>
>> Post the full code you are using.
>>
>> On Thursday, January 9, 2014 2:00:36 PM UTC-5, Hystrix wrote:
>>>
>>> Here is my JSON, which I have checked is valid:
>>>
>>> {
>>> "TempOut": 10.1,
>>> "FeelsLike": 8.2,
>>> "HumidityOut": 93,
>>> "WindAvg": 2,
>>> "WindGust": 4,
>>> "Rain": 1016.1,
>>> "AbsPressure": 998.6
>>> }
>>>
>>> As far as I can tell, this data is not being retrieved.
>>>
>>>
>>> On Thursday, January 9, 2014 6:26:06 PM UTC, asgallant wrote:
>>>>
>>>> Post your JSON here or run it through http://jsonlint.com/ to test its
>>>> validity.
>>>>
>>>> On Thursday, January 9, 2014 7:47:25 AM UTC-5, Hystrix wrote:
>>>>>
>>>>> After some googling, I have added:
>>>>>
>>>>>
>>>>> <script type="text/javascript" src="
>>>>> http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
>>>>> "></script>
>>>>>
>>>>> Now I get an error: JSON.parse: Unexpected end of data
>>>>>
>>>>> I must be getting close now. Any ideas on what is wrong now?
>>>>>
>>>>>
>>>>> On Thursday, 9 January 2014 12:26:34 UTC, Hystrix wrote:
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> I have added the callback, now I get "ReferenceError: $ is not
>>>>>> defined"
>>>>>>
>>>>>>
>>>>>> On Wednesday, 8 January 2014 22:26:56 UTC, asgallant wrote:
>>>>>>>
>>>>>>> Your drawChart function is not being called; you need to set it as
>>>>>>> the callback from the google loader:
>>>>>>>
>>>>>>> google.load('visualization', '1', {packages: ['gauge'], callback:
>>>>>>> drawChart});
>>>>>>>
>>>>>>> On Wednesday, January 8, 2014 3:23:22 PM UTC-5, Hystrix wrote:
>>>>>>>>
>>>>>>>> Many thanks for your reply. This is how I have implemented it, and
>>>>>>>> unfortunately, I still see no gauges. Firebug doesn't show any errors.
>>>>>>>>
>>>>>>>>
>>>>>>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>>>>>>> <head>
>>>>>>>> <meta http-equiv="content-type" content="text/html;
>>>>>>>> charset=utf-8"/>
>>>>>>>> <title>
>>>>>>>> Current Weather
>>>>>>>> </title>
>>>>>>>> <script type="text/javascript" src="//www.google.com/jsapi"></
>>>>>>>> script>
>>>>>>>> <script type="text/javascript">
>>>>>>>> google.load('visualization', '1', {packages: ['gauge']});
>>>>>>>> </script>
>>>>>>>> <script type="text/javascript">
>>>>>>>>
>>>>>>>> function drawChart() {
>>>>>>>> var data;
>>>>>>>> var options = {
>>>>>>>> width: 400,
>>>>>>>> height: 120,
>>>>>>>> };
>>>>>>>>
>>>>>>>> var chart = new google.visualization.Gauge(document.
>>>>>>>> getElementById('chart_div'));
>>>>>>>>
>>>>>>>> function refreshData () {
>>>>>>>> var json = $.ajax({
>>>>>>>> url: 'http://mywebsite/weather/JSON.txt',
>>>>>>>> dataType: 'json',
>>>>>>>> async: false
>>>>>>>> }).responseText;
>>>>>>>>
>>>>>>>>
>>>>>>>> var rows = [['Label', 'Value']];
>>>>>>>> json = JSON.parse(json);
>>>>>>>> rows.push(['TempOut', json.TempOut]);
>>>>>>>> rows.push(['FeelsLike', json.FeelsLike]);
>>>>>>>> rows.push(['HumidityOut', json.HumidityOut]);
>>>>>>>> rows.push(['WindAvg', json.WindAvg]);
>>>>>>>> rows.push(['WindGust', json.WindGust]);
>>>>>>>> rows.push(['Rain', json.Rain]);
>>>>>>>> rows.push(['AbsPressure', json.AbsPressure]);
>>>>>>>> var data = google.visualization.arrayToDataTable(rows);
>>>>>>>>
>>>>>>>> chart.draw(data, options);
>>>>>>>> }
>>>>>>>>
>>>>>>>> refreshData();
>>>>>>>> setInterval(refreshData, 1000);
>>>>>>>> }
>>>>>>>> </script>
>>>>>>>> </head>
>>>>>>>> <body>
>>>>>>>> <div id="chart_div"></div>
>>>>>>>> </body>
>>>>>>>> </html>
>>>>>>>>
>>>>>>>> On Wednesday, 8 January 2014 19:53:59 UTC, asgallant wrote:
>>>>>>>>>
>>>>>>>>> Your JSON isn't in the correct format for the arrayToDataTable
>>>>>>>>> method to use. Try this:
>>>>>>>>>
>>>>>>>>> var rows = [['Label', 'Value']];
>>>>>>>>> json = JSON.parse(json);
>>>>>>>>> rows.push(['TempOut', json.TempOut]);
>>>>>>>>> rows.push(['FeelsLike', json.FeelsLike]);
>>>>>>>>> rows.push(['HumidityOut', json.HumidityOut]);
>>>>>>>>> rows.push(['WindAvg', json.WindAvg]);
>>>>>>>>> rows.push(['WindGust', json.WindGust]);
>>>>>>>>> rows.push(['Rain', json.Rain]);
>>>>>>>>> rows.push(['AbsPressure', json.AbsPressure]);
>>>>>>>>> var data = google.visualization.arrayToDataTable(rows);
>>>>>>>>>
>>>>>>>>> On Wednesday, January 8, 2014 1:38:17 PM UTC-5, Hystrix wrote:
>>>>>>>>>>
>>>>>>>>>> I have weather data on my website in the following JSON format,
>>>>>>>>>> in a file called JSON.txt:
>>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>> "TempOut": 10.1,
>>>>>>>>>> "FeelsLike": 8.2,
>>>>>>>>>> "HumidityOut": 93,
>>>>>>>>>> "WindAvg": 2,
>>>>>>>>>> "WindGust": 4,
>>>>>>>>>> "Rain": 9.3,
>>>>>>>>>> "AbsPressure": 998.6
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> I have been trying for days trying to get a simple webpage to
>>>>>>>>>> display gauges for each of these values. My code looks like this:
>>>>>>>>>>
>>>>>>>>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>>>>>>>>> <head>
>>>>>>>>>> <meta http-equiv="content-type" content="text/html;
>>>>>>>>>> charset=utf-8"/>
>>>>>>>>>> <title>
>>>>>>>>>> Current Weather
>>>>>>>>>> </title>
>>>>>>>>>> <script type="text/javascript" src="//www.google.com/jsapi">
>>>>>>>>>> </script>
>>>>>>>>>> <script type="text/javascript">
>>>>>>>>>> google.load('visualization', '1', {packages: ['gauge']});
>>>>>>>>>> </script>
>>>>>>>>>> <script type="text/javascript">
>>>>>>>>>>
>>>>>>>>>> function drawChart() {
>>>>>>>>>> var data;
>>>>>>>>>> var options = {
>>>>>>>>>> width: 400,
>>>>>>>>>> height: 120,
>>>>>>>>>> };
>>>>>>>>>>
>>>>>>>>>> var chart = new google.visualization.Gauge(document.
>>>>>>>>>> getElementById('chart_div'));
>>>>>>>>>>
>>>>>>>>>> function refreshData () {
>>>>>>>>>> var json = $.ajax({
>>>>>>>>>> url: 'http://mywebsite/weather/JSON.txt',
>>>>>>>>>> dataType: 'json',
>>>>>>>>>> async: false
>>>>>>>>>> }).responseText;
>>>>>>>>>>
>>>>>>>>>> data = google.visualization.arrayToDataTable(json);
>>>>>>>>>>
>>>>>>>>>> chart.draw(data, options);
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> refreshData();
>>>>>>>>>> setInterval(refreshData, 1000);
>>>>>>>>>> }
>>>>>>>>>> </script>
>>>>>>>>>> </head>
>>>>>>>>>> <body>
>>>>>>>>>> <div id="chart_div"></div>
>>>>>>>>>> </body>
>>>>>>>>>> </html>
>>>>>>>>>>
>>>>>>>>>> I would be really grateful if someone could point me in the right
>>>>>>>>>> direction. No matter what I try in the Google Code Playground, I
>>>>>>>>>> cant even
>>>>>>>>>> get a single gauge to display.
>>>>>>>>>>
>>>>>>>>>> Many thanks.
>>>>>>>>>>
>>>>>>>>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.