Issue
I have published a Tableau 9.3 viz on Tableau public: https://public.tableau.com/profile/michel.page#!/vizhome/exercice1/Courbesventesetprofit
I have succedded to have this viz displayed in a web page by integrating the code given by the 'Share' button on the Tableau public viz page.
Now I want to do the same, but inside an IPython notebook. It seems to be possible because I saw an example in nbviewer here: http://nbviewer.jupyter.org/gist/msund/96bd1d837f4139b2558d
I have integrated the 'Share' button script code into a Markdown cell but the viz won't get displayed when the cell is run. When I look at the browser console, it seems that the js code, and object tag get sanitized, even if I tell IPython to trust the notebook.
Is there any workaround ?
Solution
If you want the Tableau viz to show up in your Jupyter notebook, Use the %%HTML magic in a normal cell:
%%HTML
<div class='tableauPlaceholder' id='viz1474058356757' style='position: relative'><noscript><a href='#'><img alt=' ' src='https://public.tableau.com/static/images/ex/exercice1/Courbesventesetprofit/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='site_root' value='' /><param name='name' value='exercice1/Courbesventesetprofit' /><param name='tabs' value='yes' /><param name='toolbar' value='yes' /><param name='static_image' value='https://public.tableau.com/static/images/ex/exercice1/Courbesventesetprofit/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1474058356757'); var vizElement = divElement.getElementsByTagName('object')[0]; vizElement.style.width='100%';vizElement.style.height=(divElement.offsetWidth*0.75)+'px'; var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>
This is a great resource on what else you can do with magics: https://blog.dominodatalab.com/lesser-known-ways-of-using-notebooks/
Answered By - rmdelgad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.