code: def add_scripts(self):
          
          common_script = self.node(self.defs, 'script', type='text/javascript')
  
          def get_js_dict():
              return dict(
                  (k, getattr(self.graph.state, k))
                  for k in dir(self.graph.config)
                  if not k.startswith('_') and hasattr(self.graph.state, k)
                  and not hasattr(getattr(self.graph.state, k), '__call__')
              )
  
          def json_default(o):
              if isinstance(o, (datetime, date)):
                  return o.isoformat()
              if hasattr(o, 'to_dict'):
                  return o.to_dict()
              return json.JSONEncoder().default(o)
  
          dct = get_js_dict()
          # Config adds
          dct['legends'] = [
              l.get('title') if isinstance(l, dict) else l
              for l in self.graph._legends + self.graph._secondary_legends
          ]
  
          common_js = 'window.pygal = window.pygal || {};'
          common_js += 'window.pygal.config = window.pygal.config || {};'
          if self.graph.no_prefix:
              common_js += 'window.pygal.config = '
          else:
              common_js += 'window.pygal.config[%r] = ' % self.graph.uuid
  
          common_script.text = common_js + json.dumps(dct, default=json_default)
  
          for js in self.graph.js:
              if js.startswith('file://'):
                  script = self.node(self.defs, 'script', type='text/javascript')
                  with io.open(js[len('file://'):], encoding='utf-8') as f:
                      script.text = f.read()
              else:
                  if js.startswith('//') and self.graph.force_uri_protocol:
                      js = '%s:%s' % (self.graph.force_uri_protocol, js)
                  self.node(self.defs, 'script', type='text/javascript', href=js)
docs: Add the js to the svg