Skip to main content

canvasxpress-anywidget

CanvasXpress interactive charts as notebook widgets, built on anywidget. One package renders in Jupyter, JupyterLab, Google Colab, VS Code notebooks and marimo — anywhere the anywidget protocol is supported.

The CanvasXpress library (CSS + JS) is loaded from the CanvasXpress CDN in the browser, so there is no JavaScript build step and nothing to bundle.

Install

pip install canvasxpress-anywidget

Use

from canvasxpress_anywidget import CanvasXpress

CanvasXpress(
    data={
        "y": {
            "vars": ["Revenue"],
            "smps": ["Q1", "Q2", "Q3", "Q4"],
            "data": [[10, 14, 9, 17]],
        }
    },
    config={"graphType": "Bar", "title": "Quarterly Revenue"},
)

data, config and events are exactly the arguments of new CanvasXpress({...}) in JavaScript, so any spec from the gallery, the R / Python packages, or the Quarto shortcode works unchanged.

From a shared spec file

The {"data", "config", "events"} JSON object used across CanvasXpress hosts loads directly:

import json
from canvasxpress_anywidget import CanvasXpress

spec = json.load(open("chart.json"))
CanvasXpress.from_spec(spec)

Update in place

Assigning to an attribute re-renders the chart without creating a new cell output:

w = CanvasXpress(data=..., config={"graphType": "Bar"})
w  # display it
w.config = {**w.config, "graphType": "Line"}   # morphs to a line chart

Parameters

Attribute Type Default Meaning
data dict {} CanvasXpress data object (y, x, z, …).
config dict {} CanvasXpress configuration (graphType, title, …).
events dict {} Optional event handlers.
width int 600 Canvas width in pixels.
height int 400 Canvas height in pixels.

License

Dual-licensed. The core library is LGPL-3.0-or-later; commercial terms are available — see https://canvasxpress.org/license.html.

Download files

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

Source Distribution

canvasxpress_anywidget-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file canvasxpress_anywidget-0.1.0.tar.gz.

File metadata

  • Download URL: canvasxpress_anywidget-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for canvasxpress_anywidget-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35f363af598b94e8dcba204d518e52a8f948549f303d91622157655d87231fe4
MD5 986524d76fa4b95a3a689d61021f31d3
BLAKE2b-256 0713a25db8d5333c1756fd8ec67f023a83cfda98b5149ec441bd12f7b80e0ee5

See more details on using hashes here.

File details

Details for the file canvasxpress_anywidget-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for canvasxpress_anywidget-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29be48b69c67f5c2f8ec2455e9ac1b11fe945bd1109aeb1e742ad7721aff3910
MD5 392a709e3c34475959137971829a7819
BLAKE2b-256 a58198f96dc7e4d29ade40e707bc8d27e03c19b6111086ff16588352f69c232f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page