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.2.0.tar.gz (24.5 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.2.0-py3-none-any.whl (397.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: refast_echarts-0.2.0.tar.gz
  • Upload date:
  • Size: 24.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 a5448e94cdbf0dc9c2c1d4d41d160449791cc87546ebccbaee24b98f096e330a
MD5 7eea97023205afff9f126cdf9cca0d2b
BLAKE2b-256 005efe54bac4d002057dfc74cec74e5a304d1c59b1df1f148347f034fcfb8dad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: refast_echarts-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 397.3 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b53623544bd8ada0cc0961017c0dec0ed76412d709bd30004821f9faa2883fcc
MD5 39833ebe8419a35f39a63a66c42c0d2e
BLAKE2b-256 40802fb61ea8b20fb8d3c455ca39d3708e9b8ef785c2b834f68a233966c428e1

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