Skip to main content

Light-weight wrapper bringing modern, interactive charts to Jupyter with Apache ECharts

Project description

PyPI version License: MIT

notecharts (note-charts or not-echarts) is designed for web-quality, interactive charts in Jupyter notebooks through Apache ECharts. It faithfully brings the full power of ECharts' declarative JSON-like API directly into Python notebooks, with a couple enhancements.

Why notecharts?

If you've done data visualization in Python before, you've likely encountered these standard tools:

  • matplotlib: Excellent for publication-quality static charts, but lacks out-of-the-box interactivity.
  • plotly.py: Great for interactive charts, but can require extensive configuration to achieve a polished, modern aesthetic or smooth animations.

Apache ECharts is an incredibly powerful web plotting library. While there have been previous attempts to bring it to Jupyter, they often come with trade-offs:

  • pyecharts: Powerful, but introduces a deep "Pythonic" abstraction. This deviates from the official ECharts API, making it difficult to translate JavaScript examples from the docs into Python.
  • ipecharts: Provides widget integration, but can have inconsistent interactivity and currently lacks support for environments like Google Colab.

notecharts bridges this gap. It provides a thin layer that allows you to write ECharts options exactly as they appear in the official docs, while handling the heavy lifting of library loading, font injection, dynamic palettes, and serialization.

Force Directed Graph Multi-Line
Force Directed Graph Multi-Line
Geo/Map 3D Scatter
Map Scatter 3D

Key Features

  • Declarative API: Pass a dictionary, get a chart. No complex class hierarchies to learn.
  • JSCode Support: Inject raw JavaScript functions for formatters, tooltips, and custom processing logic.
  • Font Injection: Automatically detect font declarations in your config, fetch the corresponding fonts (if available) from Google Fonts.
  • Rich Color Palettes: Access 196 professionally-designed color palettes from Palettable and customize them.
  • Pre-built Charts: Includes pre-built primitives like Bar, Line, Scatter, and Radar with beautiful defaults.
  • Environment Agnostic: Works seamlessly in VS Code, JupyterLab, and Google Colab.

Installation

pip install notecharts

Usage

The Declarative Way

If you can find an example on the ECharts Gallery, you can run it in notecharts.

from notecharts import Chart, JSCode, Palette

options = {
    "title": {"text": "Bar Chart"},
    "textStyle": {"fontFamily": "Josefin Sans"},  # Automatically loaded from Google Fonts
    "xAxis": {"data": ["Mon", "Tue", "Wed", "Thurs", "Fri"]},
    "yAxis": {},
    "tooltip": {
        "trigger": "axis",
        "formatter": JSCode("function(params) { return params[0].name + ': $' + params[0].value; }")
    },
    "legend": {},
    "series": [
        {
            "name": "Sales",
            "type": "bar",
            "data": [120, 150, 200, 180, 220]
        },
        {
            "name": "Expenses",
            "type": "bar",
            "data": [80, 100, 120, 110, 140]
        },
        {
            "name": "Profit",
            "type": "bar",
            "data": [40, 50, 80, 70, 80]
        }
    ],
    "color": Palette("Plasma", 3),  # Load the Plasma palette with 3 colors
}

Chart(options, width="60%").display()

The Quick Way

Use the pre-configured classes for common visualizations with sensible defaults and automatic palette generation.

from notecharts import Line

Line(
    x=["Mon", "Tue", "Wed", "Thu", "Fri"],
    y={
        "Product A": [120, 200, 150, 220, 280],
        "Product B": [180, 160, 200, 240, 290]
    },
    title="Weekly Sales Comparison",
    palette="Blues"
).display()

With palette options:

from notecharts import Bar

Bar(
    x=["Jan", "Feb", "Mar", "Apr"],
    y={
        "Sales": [150, 230, 224, 310],
        "Expenses": [120, 150, 180, 210]
    },
    title="Revenue vs Expenses",
    palette={
        "palette": "Set2",
        "saturation": 0.7,  # Adjust saturation
        "alpha": 0.85       # Control opacity
    }
).display()

Disclaimer

  • Security: Use of JSCode allows for arbitrary JavaScript execution in the browser/notebook context. Always ensure you are passing trusted code and data to your charts.
  • Connectivity: This library is ultra-lightweight because it does not ship with the ECharts binaries. It fetches them from cdn.jsdelivr.net at runtime, so an active internet connection is required to render charts if the libraries are not already cached.

License & Attribution

  • notecharts is licensed under the MIT License.
  • Apache ECharts: This library is a wrapper for Apache ECharts which is licensed under the Apache License 2.0.
  • Apache ECharts, ECharts, Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the Apache Software Foundation.

References

See the ECharts gallery for bespoke examples, or the official docs for an in-depth explanation of features and how to use them.

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

notecharts-0.3.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

notecharts-0.3.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file notecharts-0.3.0.tar.gz.

File metadata

  • Download URL: notecharts-0.3.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for notecharts-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3ee8d336d403e88b74bd8268ae45069461feba4e1c4db10c0d31c85ebe40de32
MD5 f877b25f8dbd2cc3f5c14b826fcca799
BLAKE2b-256 8cb2f759c0a76ee37251b0316f75d71219ecfb1081dcea9835b6d5f169be7ede

See more details on using hashes here.

File details

Details for the file notecharts-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: notecharts-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for notecharts-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41c88f7c8f6de378ef7066cb6d8b4dfc32febdc3c6ae57a3d2a38ad00219e863
MD5 626f52b6934a33df0e8fc04ad3164012
BLAKE2b-256 9a36b2361ee758b27c12031d353687519a85cfe4a6a055c75fd7fb450af26552

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