Public
Edited
May 10, 2022
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
chart_spec = py`# start with a fake dependency on the libraries being installed:
# ${deps_installed}

# now the basic altair example:
import altair as alt
import json
from vega_datasets import data
cars = data.cars.url

chart = alt.Chart(cars).mark_point().encode(
x=alt.X('Horsepower:Q', scale=alt.Scale(domain=[0, ${max_horsepower}])),
y='Miles_per_Gallon:Q',
color='Origin:N',
).interactive()

# this outputs Map, not Object:
# chart.to_dict()
# which, we could probably correct for directly
# for now, we'll take the hit of encoding and recoding it to JSON:
json.dumps(chart.to_dict())`
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more