Metadata-Version: 2.4
Name: ogcio-wagtail-charts
Version: 0.1.0
Summary: Chart.js-powered chart StreamField block for Wagtail, with a spreadsheet editor for chart data.
Author: Office of the Government Chief Information Officer (OGCIO)
License-Expression: MIT
Project-URL: Repository, https://github.com/ogcio/wagtail-charts
Project-URL: Changelog, https://github.com/ogcio/wagtail-charts/blob/main/CHANGELOG.md
Keywords: wagtail,django,charts,chart.js,streamfield
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Wagtail
Classifier: Framework :: Wagtail :: 7
Classifier: Framework :: Wagtail :: 8
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: wagtail>=7.1
Requires-Dist: wagtail-color-panel>=1.5
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-django>=4.8; extra == "test"
Dynamic: license-file

# wagtail-charts

A chart StreamField block for [Wagtail](https://wagtail.org), drawn with
[Chart.js](https://www.chartjs.org). Editors enter chart data in a spreadsheet editor in the
Wagtail admin and choose the chart type and display settings alongside it.

Maintained by the Office of the Government Chief Information Officer (OGCIO) for
[gov.ie](https://www.gov.ie). It started as a fork of
[wagtailcharts](https://github.com/overcastsoftware/wagtailcharts) by Overcast Software.

## Chart types

Line, vertical bar, horizontal bar, area, combo (line/bar/area), pie, doughnut, radar, polar,
waterfall and scatter. Bar and area charts can be stacked or stacked to 100%, and horizontal
bars can be drawn as a pyramid.

## Requirements

- Python 3.10+
- Wagtail 7.1+
- [wagtail-color-panel](https://pypi.org/project/wagtail-color-panel/) (installed automatically)

## Installation

```sh
pip install ogcio-wagtail-charts
```

Add the app and its dependency to `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ...
    "wagtail_charts",
    "wagtail_color_panel",
    # ...
]
```

## Usage

Add `ChartBlock` to a StreamField:

```python
from wagtail.fields import StreamField
from wagtail.models import Page

from wagtail_charts.blocks import ChartBlock


class ReportPage(Page):
    body = StreamField([
        ("chart", ChartBlock()),
    ])
```

Load the Chart.js scripts once in your base template, after the page content (for example just
before `</body>`):

```django
{% load wagtailcharts_tags %}

{% render_charts %}
```

### Colours

Dataset colours are chosen from a palette. Pass your own as `colors`, a sequence of
`(hex value, label)` pairs:

```python
from wagtail_charts.blocks import CHART_COLOR_CHOICES, ChartBlock

ChartBlock(colors=CHART_COLOR_CHOICES + (("#ffd700", "Gold"),))
```

### Templates

To change the chart markup, override `wagtailcharts/blocks/chart_block.html` in your project's
templates.

## Development

```sh
python -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest
```

## Releasing

1. Update `version` in `pyproject.toml` and add an entry to `CHANGELOG.md`.
2. Optionally, run the **Publish** workflow manually from the Actions tab to upload to
   [TestPyPI](https://test.pypi.org/project/ogcio-wagtail-charts/) and check the result.
3. Create a GitHub release with a tag matching the version (for example `v0.1.0`). Publishing
   the release runs the tests, builds the package and uploads it to PyPI.

## Licence

MIT. See [LICENSE](LICENSE), which also lists the bundled third-party JavaScript libraries.
