Skip to main content

Make is easy to use altair in FastHTML

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fh_altair-0.1.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fh_altair-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: fh_altair-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for fh_altair-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 365a3dd2aa7187b6f3d7140e03ebc86025b311073bd1686d6664213e32179e8f
MD5 cae01664f05663e72e08cb9068a2e476
BLAKE2b-256 5ec62cd4a138b892b8c74a1db2cad09cab88600801b74a2177bbeab831192346

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page