class_docstr: Svg related methods
class_docstr_tok: ["Svg","related","methods"]
docstr: Add the js to the svg
docstr_tok: ["Add","the","js","to","the","svg"]
code: def add_scripts(self):
      """Add the js to the svg"""
      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
              )
  
imports: from __future__ import division
  import io
  import json
  import os
  from datetime import date, datetime
  from math import pi
  from numbers import Number
  from urllib.parse import quote_plus
  from pygal import __version__
  from pygal.etree import etree
  from pygal.util import coord_abs_project, coord_diff, coord_dual, coord_format, coord_project, minify_css, template
label_desc: Use image node_id 3 for calling the Svg obj's underlying member method code with example usage: obj.add_scripts() and returns: dict, json, o, o