Last active
May 9, 2018 06:52
-
-
Save imcomking/4734472b217779adf44c88e8da1873b9 to your computer and use it in GitHub Desktop.
Jupyter notebook bokeh canvas archive via javascript hacking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.core.display import display, HTML, Javascript | |
def Archive_the_bk_canvas(): | |
archiving_the_bkcanvas= "\ | |
console.log(this); \ | |
var loop = setInterval(execute.bind(this, null), 1000); \ | |
function execute(output_area){ \ | |
console.log(this); \ | |
if(this.element.find(\".bk-canvas\").length == 0){\ | |
console.log(\"loop\"); \ | |
}else{ \ | |
var i; \ | |
this.outputs.length = 0; \ | |
for (i = 0; i < this.element.find(\".bk-canvas\").length; i++) {\ | |
var dataURL = this.element.find(\".bk-canvas\")[i].toDataURL(\"image/png\"); \ | |
var output_object = {\"output_type\":\"display_data\",\"transient\":{},\"data\":{\"text/html\":\"<img src=\'\"+dataURL+\"\'/>\",\"text/plain\":\"<IPython.core.display.HTML object>\"},\"metadata\":{}} ; \ | |
this.outputs.push(output_object); \ | |
} \ | |
clearInterval(loop); \ | |
};\ | |
};" | |
display(Javascript(archiving_the_bkcanvas)) | |
#display("<script>"+HTML(archiving_the_bkcanvas+"</script>")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Old version