Skip to main content

fh-altair

Making it easier to show vegalite charts made with altair in FastHTML.

Usage

You can install this tool by running:

python -m pip install fh-altair

After this step, it is ready for use! To use it you will want to make sure that you add the right headers to your FastHTML app.

from fh_altair import altair_headers

app, rt = fast_app(
    hdrs = altair_headers
)

This ensures that the required javascript and css files are always loaded. From here all you need to do is wrap your altair chart with our function and you are good to go!

from fh_altair import altair2fasthtml

def generate_chart():
    pltr = pd.DataFrame({'y': [1, 2, 3, 2], 'x': [3, 1, 2, 4]})
    chart = alt.Chart(pltr).mark_line().encode(x='x', y='y').properties(width=400, height=200)
    return altair2fasthtml(chart)

This will return a Div that contains your rendered altair chart.

Roadmap

This repository is originally meant to be simple helper, but if there are more advanced use-cases to consider I will gladly consider them. Please start a conversation by opening up an issue before starting a PR though.

Metadata

Release files for fh-altair 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fh-altair 0.1.0
File Interpreter ABI Platform
fh_altair-0.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / fh_altair-0.1.0-py2.py3-none-any.whl

Download URL fh_altair-0.1.0-py2.py3-none-any.whl
Size 4.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
365a3dd2aa7187b6f3d7140e03ebc86025b311073bd1686d6664213e32179e8f
BLAKE2b-256 checksum
How to use checksums
5ec62cd4a138b892b8c74a1db2cad09cab88600801b74a2177bbeab831192346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page