Skip to main content

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


Download files

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

Source Distribution

refast_echarts-0.1.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refast_echarts-0.1.1-py3-none-any.whl (397.1 kB view details)

Uploaded Python 3

File details

Details for the file refast_echarts-0.1.1.tar.gz.

File metadata

  • Download URL: refast_echarts-0.1.1.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

Hashes for refast_echarts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2566e9e086e40d6f81668ab96c8f057e47e53e891ccb9c74d2005874624131ce
MD5 cba33ccae724c4f00a1f2b59d8f663c7
BLAKE2b-256 bd5fdcd691858303ee0531d4b77b7c83ceb9d66525cfe0481817f83192d41e35

See more details on using hashes here.

File details

Details for the file refast_echarts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: refast_echarts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 397.1 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

Hashes for refast_echarts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e21709a71ba7f74b5fa37cd02542bfe1a65f590d759ce1a886544f7e7193580b
MD5 4c330d51b9e20370b2f0a220296aa2c7
BLAKE2b-256 645df8a68e9138d9f30b23aecf84524485bdd30a26e5d25cf0c747b6781ff34d

See more details on using hashes here.

Supported by

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