js/plugins/exportTimeline.js
function(download) {
      $("#addtrack").css("visibility","hidden");
      var element = document.getElementsByTagName('path')[0];
      element.setAttribute("stroke" , "black"); 
      element.setAttribute("fill" , "none");
      element = document.getElementsByTagName('line');
      for( var i=0 ; i<element.length ; i++)
      {
        element[i].setAttribute("stroke" , "black");
        element[i].setAttribute("fill" , "none");
          
      }
      var svgString = new XMLSerializer().serializeToString(document.querySelector(spec.timelineDiv+" svg"));
      var canvas = document.getElementById("canvas");
      var ctx = canvas.getContext("2d");
      var DOMURL = self.URL || self.webkitURL || self;
      var img = new Image();
      var svg = new Blob([svgString], {type: "image/svg+xml;charset=utf-8"});
      var url = DOMURL.createObjectURL(svg);
      img.onload = function() {
          ctx.drawImage(img, 0, 0);
          var png = canvas.toDataURL("image/png");
          document.querySelector("#png-container").innerHTML = '<img src="'+png+'"/>';
          var link = document.createElement("a");
          link.download = "clinical-timeline.png";
          if (download) {
            link.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
          }
          link.click();
          DOMURL.revokeObjectURL(png);
          link.remove();
      };
      img.src = url;
      $("#addtrack").css("visibility","visible");
    }
function(download) {
      $("#addtrack").css("visibility","hidden");
      var element = document.getElementsByTagName('path')[0];
      element.setAttribute("stroke" , "black"); 
      element.setAttribute("fill" , "none");
      element = document.getElementsByTagName('line');
      for( var i=0 ; i<element.length ; i++)
      {
        element[i].setAttribute("stroke" , "black");
        element[i].setAttribute("fill" , "none");
          
      }
      var svgString = new XMLSerializer().serializeToString(document.querySelector(spec.timelineDiv+" svg"));
      var canvas = document.getElementById("canvas");
      var ctx = canvas.getContext("2d");
      var DOMURL = self.URL || self.webkitURL || self;
      var img = new Image();
      var svg = new Blob([svgString], {type: "image/svg+xml;charset=utf-8"});
      var url = DOMURL.createObjectURL(svg);
      img.onload = function() {
          ctx.drawImage(img, 0, 0);
          var png = canvas.toDataURL("image/png");
          document.querySelector("#png-container").innerHTML = '<img src="'+png+'"/>';
          var link = document.createElement("a");
          link.download = "clinical-timeline.png";
          if (download) {
            link.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
          }
          link.click();
          DOMURL.revokeObjectURL(png);
          link.remove();
      };
      img.src = url;
      $("#addtrack").css("visibility","visible");
    }
function ( download ) { $ ( "#addtrack" ) . css ( "visibility" , "hidden" ) ; var element = document . getElementsByTagName ( 'path' ) [ 0 ] ; element . setAttribute ( "stroke" , "black" ) ; element . setAttribute ( "fill" , "none" ) ; element = document . getElementsByTagName ( 'line' ) ; for ( var i = 0 ; i < element . length ; i ++ ) { element [ i ] . setAttribute ( "stroke" , "black" ) ; element [ i ] . setAttribute ( "fill" , "none" ) ; } var svgString = new XMLSerializer ( ) . serializeToString ( document . querySelector ( spec . timelineDiv + " svg" ) ) ; var canvas = document . getElementById ( "canvas" ) ; var ctx = canvas . getContext ( "2d" ) ; var DOMURL = self . URL || self . webkitURL || self ; var img = new Image ( ) ; var svg = new Blob ( [ svgString ] , { type : "image/svg+xml;charset=utf-8" } ) ; var url = DOMURL . createObjectURL ( svg ) ; img . onload = function ( ) { ctx . drawImage ( img , 0 , 0 ) ; var png = canvas . toDataURL ( "image/png" ) ; document . querySelector ( "#png-container" ) . innerHTML = '<img src="' + png + '"/>' ; var link = document . createElement ( "a" ) ; link . download = "clinical-timeline.png" ; if ( download ) { link . href = canvas . toDataURL ( "image/png" ) . replace ( "image/png" , "image/octet-stream" ) ; } link . click ( ) ; DOMURL . revokeObjectURL ( png ) ; link . remove ( ) ; } ; img . src = url ; $ ( "#addtrack" ) . css ( "visibility" , "visible" ) ; }
Exports the clinical-timeline as PNG
@param  {boolean} download enable or disable download
Exports the clinical - timeline as PNG