Can you show your Gauge.php?
and this is my animated gauge code:
*google.load('visualization', '1', {'packages':['gauge']});*
*google.setOnLoadCallback(drawGauge);*
*var url = 'http://194.126.182.78:8080/web/abi';*
*var data;*
*var ww = (screen.availWidth)*0.7;*
*var wh = (screen.availHeight)*0.3;*
*var options = {width: ww, height: wh, redFrom: 50, redTo: 80, greenFrom:
0, greenTo: 30, min: 0, max: 80,*
* yellowFrom:30, yellowTo: 50, minorTicks: 5, animation: { duration:
1000, easing: 'out'}*
* }*
*function drawGauge() {*
* var data = new google.visualization.arrayToDataTable([['Label',
'Value'],['S1', 0],*
* ['S2', 0],['S3', 0],['S4', 0],['MiD', 0]]);*
* gauge = new
google.visualization.Gauge(document.getElementById('chart1_div'));*
* gauge.draw(data, options);*
*}*
*function Requestdata(){*
* var xmlhttp; *
* if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}*
* else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}*
* xmlhttp.onreadystatechange = function() {*
* if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {*
* var data = JSON.parse(xmlhttp.responseText);*
* Load(data)*
* } else {}*
* };*
* xmlhttp.open('GET','http://194.126.182.78:8080/web/abi',true);*
* xmlhttp.send(null);*
*}*
*function Load(Webdata){*
* var data = new google.visualization.arrayToDataTable([['Label',
'Value'],['S1', Webdata.A],*
* ['S2', Webdata.B],*
* ['S3', Webdata.C],*
* ['S4', Webdata.D],*
* ['MiD', Webdata.middle]]);*
* gauge.draw(data, options); *
*}*
*setInterval(function() {*
* Requestdata();*
* },5000*
*);*
среда, 28 августа 2013 г., 23:15:07 UTC+4 пользователь Nallacheruvu STP
написал:
>
> Hi,
>
> I am new to any of this area and trying to get a gauge chart i.e., updated
> dynamically with latest entry on my database. I have a php script file
> which can return the latest single plain float value like "30.25". I have
> a html file with gauge chart code & want to get thechart updated with that
> value every 5 sec but struck at following.
>
> The working code with random value is like this
>
> *setInterval(function() {*
> * var flow = 40.65 + Math.round(60 * Math.random());*
> * data.setValue(0, 1, flow);*
> * chart.draw(data, options);*
> * }, 5000);*
>
> But when i try to get the variable from php file its not working like
> following.
>
> *setInterval(function() {*
> * var flow = $.ajax({url: 'Gauge.php', dataType: 'text', async:
> false}).responseText;*
> * data.setValue(0, 1, flow);*
> * chart.draw(data, options);*
> * }, 5000);*
>
> Please help me to correct the code. Thank you!
>
--
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/d/optout.