Search code examples
pythonaltair

Making dashboards using altair


I would like to use the excellent altair library to create dashboards. Is there a way to create the dashboards and not show any code? I see some really nice examples here: https://altair-viz.github.io/case_studies/exploring-weather.html but the code is visible too. Also, what is the best (well tested/easy to use) frontend for altair? Colab? Jupyter?


Solution

  • Any Altair chart can be saved as HTML using chart.save("filename.html"). If you open the resulting file with a web browser, you'll see the chart without any of the associated Python code.

    Alternatively, you can use chart.to_json() to get out the JSON chart specification, which can then be embedded in any web page using vega-embed... this is exactly what is done in the page exported by chart.save.


    As to your second question (please in the future try to limit your StackOverflow posts to a single question): Altair works with JupyterLab, Jupyter notebook, CoLab, nteract, and Hydrogen. You can use any of these frontends, though some require some extra setup. See https://altair-viz.github.io/getting_started/installation.html for details. I use JupyterLab, and would suggest starting with that.