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

From GitHub (recommended for development)

# 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

Download files

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

Source Distribution

vcti_chart-2.0.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

vcti_chart-2.0.0-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file vcti_chart-2.0.0.tar.gz.

File metadata

  • Download URL: vcti_chart-2.0.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_chart-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b08c52b6a5ca24417173ab1bcf9c205e656edf02f36e3762025f5aec9b7605d5
MD5 e77c14de8d890fdb252f686aa895e2ab
BLAKE2b-256 640e77fd5cf953985a46fe795a622e134b72f39703e6af83c9b68ef1ae21998d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_chart-2.0.0.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-chart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_chart-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcti_chart-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_chart-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b6b373b14ee7746c5e70eb65926104746e43e2d0d17837615dbb4dbb64b216c
MD5 d2623ab23031767928cce487bf1f7bc6
BLAKE2b-256 3e2a5abdf3bc2f03dcd59066d23bd80c4e6e62692c3953da8205d8db3443ef33

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_chart-2.0.0-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-chart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

Supported by

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