Advertisement
Higem

Untitled

Apr 2nd, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. from bokeh.models.widgets import FileInput
  2.  
  3. div = Div(text='<div id="document-container10"></div>', width=500, height=500)
  4.  
  5. l = FileInput(accept='.json')
  6.  
  7. l.js_on_change('value', CustomJS(code="""
  8. function b64DecodeUnicode(str) {
  9. return decodeURIComponent(atob(str).split('').map(function(c) {
  10. return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  11. }).join(''));
  12. }
  13.  
  14. const {Document} = Bokeh.require('document/document');
  15. const data = JSON.parse(b64DecodeUnicode(cb_obj.value));
  16. const doc = Document.from_json_string(data);
  17. Bokeh.embed.add_document_standalone(doc, document.getElementById('document-container10'), [], true);
  18. cb_obj.disabled = true;
  19. """))
  20.  
  21. show(column(l, div))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement