Well... I found a solution, but I don't like it!
If I create the Chart object each time in the update timer loop, but before
that clear the DIV, it all happens so quick that it looks right on the
screen
I hate wasting all that initing of the code, but I just couldn't get the
Chart to update correctly.
<script type="text/javascript">
google.load('visualization', '1.1', { 'packages':
['annotationchart'] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var chart = new
google.visualization.AnnotationChart(document.getElementById('chart_div'));
function updateChart() {
var jsonData = $.ajax({
url: "/ria/aceResponse.aspx?format=json",
dataType: "json",
async: false,
cache: false
}).responseText;
var interval = $.ajax({
url: "/ria/aceResponse.aspx?format=headerinterval",
dataType: "text",
async: false,
cache: false
}).responseText;
$("#interval").text(interval);
var data = new google.visualization.DataTable(jsonData);
$('#chart_div').empty();
var chart = new
google.visualization.AnnotationChart(document.getElementById('chart_div'));
chart.draw(data, {
is3D: true,
colors: ['red'],
displayZoomButtons: false,
displayRangeSelector: false,
dateFormat: 'HH:mm:ss'
});
}
updateChart();
setInterval(updateChart, 60000);
}
</script>
On Friday, May 30, 2014 1:25:06 PM UTC-4, Paul Duer wrote:
>
> Unfortunately no, nothing. The chart just never updates past the initial
> data set.
>
> I will attach a data file if anyone wants to try.
>
>
> On Friday, May 30, 2014 11:41:31 AM UTC-4, Andrew Gallant wrote:
>>
>> If you open the page in Chrome and view the developer's console, are
>> there any errors reported when the update runs?
>>
>> On Friday, May 30, 2014 10:15:46 AM UTC-4, Paul Duer wrote:
>>>
>>>
>>> Hey All,
>>>
>>> I have the code below that someone already helped me write from here.
>>>
>>> It's not refreshing/updating the table on the webpage like it should. I
>>> have validated that the data DOES update. Meaning it is a new and updated
>>> DataTable object that is being passed to the DRAW method, but the chart on
>>> the screen.
>>>
>>> But, it never updates. It stays the same as the first load. And
>>> sometimes it even crashes or shows an empty chart. My datasource can take
>>> 10 to 20 seconds to load sometime as this is a test rig, but I don't know
>>> why the chart is plain crashing.
>>>
>>> What have I done wrong?
>>>
>>> <script type="text/javascript" src="//www.google.com/jsapi
>>> "></script>
>>> <script src="//
>>> ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
>>>
>>> <title></title>
>>> <script type="text/javascript">
>>> google.load('visualization', '1.1', { 'packages':
>>> ['annotationchart'] });
>>> google.setOnLoadCallback(drawChart);
>>>
>>> function drawChart() {
>>>
>>> var chart = new
>>> google.visualization.AnnotationChart(document.getElementById('chart_div'));
>>>
>>> function updateChart() {
>>>
>>> var jsonData = $.ajax({
>>> url: "/ria/aceResponse.aspx?format=json",
>>> dataType: "json",
>>> async: false,
>>> cache: false
>>> }).responseText;
>>> var interval = $.ajax({
>>> url:
>>> "/ria/aceResponse.aspx?format=headerinterval",
>>> dataType: "text",
>>> async: false,
>>> cache: false
>>> }).responseText;
>>>
>>> $("#interval").text(interval);
>>> var data = new
>>> google.visualization.DataTable(jsonData);
>>>
>>> chart.draw(data, {
>>> is3D: true,
>>> colors: ['red'],
>>> displayZoomButtons: false,
>>> displayRangeSelector: false,
>>> dateFormat: 'HH:mm:ss'
>>> });
>>> }
>>>
>>> updateChart();
>>> setInterval(updateChart, 60000);
>>> }
>>> </script>
>>>
>>
--
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.