jeudi 4 mai 2017

Python+Altair (Vega-Lite): Web server

I want to visualize some graphs on web pages using Python 2.7.12 and Altair 1.2.0.

Using their examples it is easy and straightforward:

from altair import *
from altair import Chart, load_dataset

# load built-in dataset as a pandas DataFrame
cars = load_dataset('cars')

chart = Chart(cars).mark_circle().encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
)

chart.display()  

This works in Jupyter Notebook.

Changing chart.display() to chart.server() (as described at http://ift.tt/2pbR3Fo) should be enough to start a web server using Python's HTTPServer.

It starts, but the page it provides is empty. The source is there but nothing is visualized.

Any idea about why?




Aucun commentaire:

Enregistrer un commentaire