Search code examples
websocketprotovis

Protovis force re-render


I know Protovis isn't really meant to be used this way, but is there a workaround for destroying what's currently in a pv.Panel and re-add()'ing and re-render()'ing a panel?

I'm working on a visualization which was built to be static and trying to migrate it to being updated periodically via WebSockets.


Solution

  • Yes you can have Protovis re-render without destroying the panel. You can update the data used by a panel, and call render on it again. For example:

    var data = [1, 2, 3];
    
    var panel = new pv.Panel()
        .data(data)
        .add(pv.Bar)
        ...
    
    panel.render();  // initial render
    
    data = [4, 5, 6];  
    panel.data(data);  // update the data
    panel.render();    // re-render