avoid global variables

this fixes a safari bug: the 'graph' global variable
was referencing the dom element with an id of 'graph'
so the actual graph was not being created.