2

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.

1 Answer 1

5

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
2
  • Thanks! I ended up working around by making all children of the panel invisible and re-adding new children, because in fact while the above solution works, it doesn't extend to things like changing scales based on data bounds. If you're graphing data from 1-10 and the next version of your data goes from 1-50, you can't rescale your graph by updating the data, can you? Apr 28, 2011 at 4:37
  • Nicolas, You are correct, when you adjust your data, you need to rebuild your scale objects if you want to change their domain or range based on the data.
    – bsterne
    Apr 28, 2011 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.