Search code examples
javascripthtmlchartsprotovis

How do I append Protovis chart to a specific HTML tag?


I have a div tag with id "chart" but how do I get Protovis to render the chart inside that tag?

I tried the canvas method but it did not work.

var vis = new pv.Panel().canvas("chart").width(width).height(height)

I need to keep my JS code the greates the chart as part of the framework I'm working on and can't have scripttags inside the HTML body.


Solution

  • This definitely works for me in the latest version of Protovis (3.2):

    <div id="#chart-div"></div>
    
    var vis = new pv.Panel().canvas('chart-div')
    

    Make sure its the root panel though.

    http://groups.google.com/group/protovis/browse_thread/thread/1ff9530cee6133ff