Hi all,

I am trying to dynamically change the time range of a timeplot
after I do a Timeplot.loadText(). Is that possible?

My overall objective is to have a timeplot that scrolls almost
in real-time.  I tried to accomplish this goal by calling
Timeplot.loadText() periodically with a different set of
points. But while the right range expands to accommodate the
new points (and as a result compressing the plot), the left
range never changes.

The remote data file (retrieved by loadText) is updated
continuously and contains only the most recent data points
in a fixed range (say the last 300sec).  The actual range is
embedded inside the datafile and I extract it with a filter.

I tried to clear the event source before the call to loadText()
but that did not help. It only resulted in points outside of my
range not to appear, but the left range remained unchanged.

Any suggestions? I include the javascript below that calls
reload_data() every one second to reload the data file.

Great work on timeplot btw.

Thanks,
Pavlos

<script>
var timeplot1;
var eventSource1 = new Timeplot.DefaultEventSource();
var dataSource1 = new Timeplot.ColumnSource(eventSource1,1);
var timeGeometry1 = new Timeplot.DefaultTimeGeometry();

var minTimeRange = 0;
var maxTimeRange = 0;

var dataFile = "data.txt"
var dataURL = "none";
var refreshSeconds = 1;

var dataFilter = function(data)
{
    // first and second row contain the range
    var firstRow = data.shift();
    var secondRow = data.shift();

    minTimeRange = firstRow[0];
    maxTimeRange = secondRow[0];
    return data;
};

function reload_data()
{
    timestamp = new Date().getTime();

    // randomize the url so that the browser does not use the cache
    // to retrieve the data file
    dataURL = dataFile + "?timestamp=" + timestamp;

    eventSource1.clear();
    timeplot1.loadText(dataURL,",",eventSource1, dataFilter);

    // PROBLEM: The plot's left range is stuck to the left range of
    //          the first loadText()
    timeGeometry1.setRange(minTimeRange, maxTimeRange);
    timeplot1.update();

    setTimeout("reload_data()", refreshSeconds * 1000);
}

function onLoad()
{
    var plotInfo1 = [
        Timeplot.createPlotInfo({
            id: "first plot",
            dataSource: dataSource1,
            timeGeometry: timeGeometry1,
            valueGeometry: new Timeplot.DefaultValueGeometry({
                min: 0,
                max: 10
            })
        })
    ];
    timeplot1 = Timeplot.create(document.getElementById("plot1"), plotInfo1);
    reload_data();
}

// onResize() omitted
</script>
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general

Reply via email to