Refast extension for ECharts
Project description
refast-echarts
Refast extension for ECharts
A Refast extension that provides the Echarts component.
Installation
pip install refast-echarts
Usage
Option 1: Auto-Discovery (Recommended)
When you install the package, Refast will automatically discover and load the extension:
from fastapi import FastAPI
from refast import RefastApp, Context
from refast.components import Container
from refast_echarts import ECharts
ui = RefastApp(title="ECharts Demo")
@ui.page("/")
def home(ctx: Context):
option = {
"title": {"text": "Monthly Sales"},
"tooltip": {},
"xAxis": {
"data": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
},
"yAxis": {},
"series": [
{
"name": "Sales",
"type": "bar",
"data": [120, 200, 150, 80, 70, 110],
}
],
}
return Container(
children=[
ECharts(option=option, height="400px"),
]
)
app = FastAPI()
app.include_router(ui.router)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
Option 2: Manual Registration
If you want to disable auto-discovery and register extensions manually:
from refast import RefastApp
from refast_echarts import Echarts, EchartsExtension
ui = RefastApp(
title="Echarts Demo",
auto_discover_extensions=False,
extensions=[EchartsExtension()],
)
Component Props
| Prop | Type | Default | Description |
|---|---|---|---|
option |
dict | {} |
ECharts option configuration object |
theme |
str | dict | None |
Theme name ("light", "dark") or custom theme object |
height |
str | None |
Chart height (e.g. "400px") |
width |
str | None |
Chart width (e.g. "100%") |
auto_resize |
bool | True |
Auto-resize chart when container size changes |
loading |
bool | False |
Show loading animation |
on_click |
Callback | None |
Fired when clicking on a chart element |
on_mouseover |
Callback | None |
Fired when hovering over a chart element |
id |
str | None |
Component ID (required for setOption calls) |
class_name |
str | "" |
CSS classes to apply to the container |
Development
Prerequisites
- Python 3.10+
- Node.js 18+
- npm
Building the Frontend
cd frontend
npm install
npm run build
This builds the UMD bundle to src/refast_echarts/static/.
Installing Locally
# Install with automatic frontend build (via hatch hook)
pip install -e .
# Or build frontend first, then install
cd frontend && npm install && npm run build && cd ..
pip install -e .
Running the Example
python usage.py
Then open http://localhost:8000 in your browser.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file refast_echarts-0.1.0.tar.gz.
File metadata
- Download URL: refast_echarts-0.1.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2003d6ee96ceb0d8c821702f4f9f2e1aa9131864fe53b17e3cb4ef703a952344
|
|
| MD5 |
a9b52b3d77a73f2acc4a67b2b3762d1c
|
|
| BLAKE2b-256 |
d58fe04b55bf46200222e841cd4d4bcbe04c9838e7590575e97547da48c74247
|
File details
Details for the file refast_echarts-0.1.0-py3-none-any.whl.
File metadata
- Download URL: refast_echarts-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e85ad6cd8e1ffae949da71caf595d8c277acd30439511ba896957d9179335432
|
|
| MD5 |
1a02db95788e005302f4da1e513d83fd
|
|
| BLAKE2b-256 |
4047b4e8c7688b54b9b18869b24cc956f7883d7e05d384bf97376030e8c126a2
|