Hi everyone
   I'm trying to display a realtime stream of data (from some
instrument) in a way that it is a sliding window of, say, a 100 latest
datapoints. I do not care about anything older than 100 points. I've
managed to create my own datasource using python and can successfully
display the data on an annotated timeline graph (Thanks to all the
sample code on this forum)

My setRefreshInterval() on the query object is set for every 3 seconds
and the callback receives the correct data. The graph gets updated
when I call chart.draw(data, {'allowRedraw': true,
'displayAnnotations' : false}) .. however the problem seems that
internally the annotated timeline object has a copy of all previous
data received and seems to merge new data with the old one. I can
slide the view-slider at the bottom and see more than 100 values. You
can imagine how this becomes a problem when the data stream is
continuous and the Flash player memory balloons up after a couple of
hours :)

I can't find a way to clear/flush the old data.. Is this normal
behaviour ? Is there a known solution ?

I'm attaching the code I'm using. Thanks in advance.

        // Global variables
        var chart, data;
        var startDate, endDate;
        google.load("visualization", "1", {packages: ['annotatedtimeline']});
        google.setOnLoadCallback(drawChart);

        function drawChart() {

                var query = new google.visualization.Query("http://
<my_instrument_data_source>");
                data = new google.visualization.DataTable();

                // Send the query with a callback function.
                query.setRefreshInterval(3);
                query.send(handleQueryResponse);

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

        }

        function handleQueryResponse(response) {
                if (response.isError()) {
                        alert('Error in query: ' + response.getMessage() + ' ' +
response.getDetailedMessage());
                        return;
                }

                data = response.getDataTable();
                chart.draw(data, {'allowRedraw': true, 'displayAnnotations' :
false});

        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-chart-api?hl=en.

Reply via email to