 
   setSampleSize: (e) =>
     @options.sampleSize = $(e.currentTarget).val()
+
+  generateImageFromGraph: (e) =>
+    svg_string = @serializeXmlNode document.querySelector '#graph svg'
+    canvg 'canvas', svg_string
+
+    canvas = document.getElementById 'canvas'
+    img = canvas.toDataURL 'image/png'
+    window.open img
 
   onSubmit: (e) =>
     e.preventDefault()

    # @graph.getDataSource("SkyServerSubject", @options.sampleSize)
    # @histogram.getDataSource("InteractiveSubject", {sample: @options.sample, limit: parseInt(@sampleSize.val()), user: false})

  generateImageFromGraph: (e) =>
    svg_string = @serializeXmlNode document.querySelector '#graph svg'
    canvg 'canvas', svg_string

    canvas = document.getElementById 'canvas'
    img = canvas.toDataURL 'image/png'
    window.open img

  # Helper functions
  setPressed: (button) =>
    button.siblings().removeClass 'pressed'
    button.toggleClass 'pressed'
   
  serializeXmlNode: (xmlNode) ->
    if typeof window.XMLSerializer != "undefined"

    else if typeof xmlNode.xml != "undefined"
      xmlNode.xml



module.exports = Graphs