Skip to main content

pydacharts

Pydantic ❤️ chartjs This is a code generator for ChartJS configuration JSON.

Set Up

  1. Pip install the package with pip install pydacharts, uv add pydacharts, or clone the repo
  2. Use the class generator to write a "config" file. One simple example
from pydacharts.models import Config, Data, Dataset

def spending_by_year_chartjs() -> Config:
    """
    Return a chartjs "config" object for sip dataset
    charting
    """
    return Config(
        type="bar",
        data=Data(
            labels=["Green is nice", "Red is angry", "Blue is calming"],
            datasets=[Dataset(
                backgroundColor = ["green", "red", "blue"],
                data = [1,2,3],
                label = "We love colors"
            )]
        )
    )

(This example should work standalone)

For running examples

Run Examples

uv sync --extra serve
uv .venv/bin/activate
cd serve
fastapi run

go to localhost:8000

Dev

Linting is done with ruff & mypy, testing with pytest. Expected output is like this:

(pydacharts) josh@carbonmint:~/github/catalpainternational/pydacharts$ uv run mypy .
Success: no issues found in 25 source files

(pydacharts) josh@carbonmint:~/github/catalpainternational/pydacharts$ uv run ruff check --fix .
All checks passed!

(pydacharts) josh@carbonmint:~/github/catalpainternational/pydacharts$ uv run pytest
===================================================================================================================== test session starts =====================================================================================================================
platform linux -- Python 3.11.10, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/josh/github/catalpainternational/pydacharts
configfile: pyproject.toml
plugins: cov-5.0.0, anyio-4.6.0
collected 41 items                                                                                                                                                                                                                                            

tests/test_bar.py .....                                                                                                                                                                                                                                 [ 12%]
tests/test_chart_examples.py ..                                                                                                                                                                                                                         [ 17%]
tests/test_chart_utils.py ....                                                                                                                                                                                                                          [ 26%]
tests/test_datalabels.py .                                                                                                                                                                                                                              [ 29%]
tests/test_elements.py ....                                                                                                                                                                                                                             [ 39%]
tests/test_line.py ....                                                                                                                                                                                                                                 [ 48%]
tests/test_models.py ..................                                                                                                                                                                                                                 [ 92%]
tests/test_options.py .                                                                                                                                                                                                                                 [ 95%]
tests/test_other.py .                                                                                                                                                                                                                                   [ 97%]
tests/test_pie.py .                                                                                                                                                                                                                                     [100%]

===================================================================================================================== 41 passed in 0.37s ======================================================================================================================

Building

Update the version field in pyproject.toml Create a git tag same as the version

uv build
uv publish --token pypi-YOURTOKENHERE

Metadata

Release files for pydacharts 0.2.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 pydacharts 0.2.0
File Size Uploaded
pydacharts-0.2.0.tar.gz 124.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydacharts 0.2.0
File Interpreter ABI Platform
pydacharts-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 139.3 kB

Release files / pydacharts-0.2.0.tar.gz

Download URL pydacharts-0.2.0.tar.gz
Size 124.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c26ca7033dd906c41e864b84b9769b2d45c749cf3f7f723bd5dbd51233ee91dd
BLAKE2b-256 checksum
How to use checksums
732668547d0e317f2cb8857a7766715338b84aa761fae32399c58eca51d3ee80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.19

Release files / pydacharts-0.2.0-py3-none-any.whl

Download URL pydacharts-0.2.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5242c29b41629fc74dd3fa3628b51a4869f86bde768a9aea5726f3138263b0d8
BLAKE2b-256 checksum
How to use checksums
57ee9c148d34b159cba7f1da553138a32ae5430a1cd6f84bd6445df5ca5861a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.19

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

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