Search code examples
dygraphs

How do I get a reference to a dygraph based on Div ID it was assigned to?


Is there a way to get a reference to the graph via the div id it was placed in?

new Dygraph(document.getElementById("chartxyz"),.....)

Since that wasnt stored to a var, (or even it if was, but i try to access it from another script)

is there a way i can get a dygraph object via that div id of chartxyz? I'd like to run the setSelection on it to highlight a series.

Thanks


Solution

  • No, you'll have to maintain the mapping yourself.

    var dygraphs = {};
    dygraphs['chartxyz'] = new Dygraph(document.getElementById("chartxyz"), .....)