Skip to main content

Chart Data Model

Purpose

vcti-chart provides a chart data model that exports to self- contained HTML files for use in web applications, prompt UIs, reports, or anywhere you need interactive chart visualisations.

Define a chart once in Python, then export it to a standalone HTML file that renders with any JavaScript charting framework — Plotly.js, ECharts, Chart.js, or any other. The Jinja2 template controls which JS library is used and how the chart looks. Adding support for a new JS library means writing a new template — no Python code changes.

Define chart in Python  →  Pass to Jinja2 template  →  Standalone HTML file

Python chart libraries (Plotly, Bokeh) are also supported for interactive exploration in Jupyter during development.

Dependencies: numpy, pandas, vcti-enum.


How It Works

┌──────────────────────┐
│     ChartStack       │   Define chart: layers, panels, properties
│  Layer → Panel → Stack│
│  to_dict() → dict    │   All values as JSON-safe Python types
└──────────┬───────────┘
           │
┌──────────▼───────────┐
│   Jinja2 Template    │   User-provided (or built-in default)
│                      │
│  {{ chart.* }}       │   Template accesses chart dict directly
│  {{ tojson }}        │   Reshapes into library-specific JS config
│  → output.html       │   Standalone, self-contained HTML artifact
└──────────────────────┘

No Python-side JS serialisers. The Jinja2 template does all the library- specific reshaping. to_dict() provides the raw ingredients.


Installation

# Latest main branch
pip install vcti-chart



### In `requirements.txt`

vcti-chart>=1.0.0


### In `pyproject.toml` dependencies

```toml
dependencies = [
    "vcti-chart>=1.0.0",
]

Quick Start

1. Define a chart

from vcti.chart import (
    Chart, Facet, Panel, Variable, VariableInfo, DataArray,
    CoordSysType, XyLayer, XyPlotConfig, LineType, MarkerType,
)

# Create the shared independent variable (x-axis)
time = Variable("time", DataArray([0, 1, 2, 3, 4]),
                VariableInfo(name="Time", unit="s"))

# Create a dependent variable (y-axis metadata)
temp = Variable("temperature",
                metadata=VariableInfo(name="Temperature", unit="°C"))

# Build the hierarchy: Chart → Facet → Panel → Layer
chart = Chart()
facet = Facet(CoordSysType.CARTESIAN, domain_var=time)
panel = Panel(CoordSysType.CARTESIAN, range_var=temp)
panel.layers.add("line", XyLayer(
    values=DataArray([20, 22, 25, 23, 21]),
    config=XyPlotConfig(line_type=LineType.SOLID, marker_type=MarkerType.CIRCLE),
))
facet.panels.add("temp", panel)
chart.facets.add("main", facet)

2. Serialise for template consumption (primary workflow)

import json

data = chart.to_dict()   # JSON-safe dict for Jinja2 templates
print(json.dumps(data, indent=2))

The to_dict() output is the contract consumed by Jinja2 templates via the external vcti-template package.

3. Use with Python chart libraries (convenience)

# Plotly (for Jupyter / interactive exploration)
from vcti.chart.converters.plotly import get_figure
fig = get_figure(chart)
fig.show()

# Bokeh
from vcti.chart.converters.bokeh import chart_to_bokeh
from bokeh.io import show
show(chart_to_bokeh(chart))

Hierarchy

Chart                              Top-level container (grid layout)
  └── Facet                        Panels sharing a domain variable
        ├── domain_var: Variable   Shared x-axis data + metadata
        ├── axes_layout            Parallel or serial arrangement
        └── Panel                  One dependent variable
              ├── range_var        Y-axis metadata (name, unit)
              └── Layer            Visual representation
                    ├── XyLayer    Line / scatter / area
                    ├── BarLayer   Bar chart
                    └── SectorLayer Pie / donut

Documentation

Metadata

Release files for vcti-chart 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-chart 2.0.0
File Size Uploaded
vcti_chart-2.0.0.tar.gz 29.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vcti-chart 2.0.0
File Interpreter ABI Platform
vcti_chart-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.1 kB

Release files / vcti_chart-2.0.0.tar.gz

Download URL vcti_chart-2.0.0.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b08c52b6a5ca24417173ab1bcf9c205e656edf02f36e3762025f5aec9b7605d5
BLAKE2b-256 checksum
How to use checksums
640e77fd5cf953985a46fe795a622e134b72f39703e6af83c9b68ef1ae21998d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Release files / vcti_chart-2.0.0-py3-none-any.whl

Download URL vcti_chart-2.0.0-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b6b373b14ee7746c5e70eb65926104746e43e2d0d17837615dbb4dbb64b216c
BLAKE2b-256 checksum
How to use checksums
3e2a5abdf3bc2f03dcd59066d23bd80c4e6e62692c3953da8205d8db3443ef33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release 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