Chart.js charts for Wagtail
Project description
Wagtail Charts
Chart.js charts in Wagtail, edited and customised from the Wagtail admin
Getting started
Assuming you have a Wagtail project up and running:
pip install wagtailcharts
Add wagtailcharts
to your settings.py in the INSTALLED_APPS section, before the core wagtail packages:
INSTALLED_APPS = [
# ...
'wagtailcharts',
# ...
]
Add a wagtailcharts ChartBlock to one of your StreamFields:
from wagtailcharts.blocks import ChartBlock
class ContentBlocks(StreamBlock):
chart_block = ChartBlock()
Include your streamblock in one of your pages
class HomePage(Page):
body = StreamField(ContentBlocks())
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
Add the wagtailcharts_tags
templatetag to your template and call the render_charts
tag just before your </body>
closing tag.
Please note that you must render your chart block so that the render_charts
tag can detect the charts.
Here is a tiny example of a page rendering template:
{% load wagtailcore_tags wagtailcharts_tags %}
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-6">
<h1>{{self.title}}</h1>
<div class="excerpt">{{self.excerpt|richtext}}</div>
</div>
</div>
{% for block in self.body %}
{% include_block block %}
{% endfor %}
</div>
{% endblock %}
{% block extra_js %}
{% render_charts %}
{% endblock %}
Configuration
ChartBlock
accepts a few extra arguments in addition to the standard StructBlock
arguments.
colors
A tuple of color tuples defining the available colors in the editor.
from wagtailcharts.blocks import ChartBlock
COLORS = (
('#ff0000', 'Red'),
('#00ff00', 'Green'),
('#0000ff', 'Blue'),
)
class ContentBlocks(StreamBlock):
chart_block = ChartBlock(colors=COLORS)
chart_types
You can override the default chart types available for your ChartBlock
instance:
from wagtailcharts.blocks import ChartBlock
CHART_TYPES = (
('line', 'Custom title for line chart'),
)
class ContentBlocks(StreamBlock):
chart_block = ChartBlock(chart_types=CHART_TYPES)
The default types are:
CHART_TYPES = (
('line', 'Line Chart'),
('bar', 'Vertical Bar Chart'),
('bar_horizontal', 'Horizontal Bar Chart'),
('area', 'Area Chart'),
('multi', 'Combo Line/Bar/Area Chart'),
('pie', 'Pie Chart'),
('doughnut', 'Doughnut Chart'),
('radar', 'Radar Chart'),
('polar', 'Polar Chart'),
('waterfall', 'Waterfall Chart')
)
Dependencies
- This project relies on Jspreadsheet Community Edition for data entry and manipulation.
- Charts are rendered using Chart.js.
- 100% stacked bar charts use a plugin https://github.com/y-takey/chartjs-plugin-stacked100
- Datalabels use a plugin [https://chartjs-plugin-datalabels.netlify.app] (https://chartjs-plugin-datalabels.netlify.app)
Release notes
Version 0.3
- Added Waterfall Chart
- Added DataLabels
- Added options for: ** grid display ** axis display ** y tick precision ** datalabel and tooltip precision
- Added grouping of options into multiple collapsible panels with buttons
- Multiple bugfixes
Version 0.2
- Added support for Wagtail 3.0
Version 0.1
- Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wagtailcharts-0.3.tar.gz
.
File metadata
- Download URL: wagtailcharts-0.3.tar.gz
- Upload date:
- Size: 280.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a163906deae1ae5ef83a7fa853fa4ef3378b43ba7fdd425ad0e320ac3290284 |
|
MD5 | 5d4bc9504e23f83c472353d3fc45fc36 |
|
BLAKE2b-256 | 7abae0a05d372d99ed8f9a20a54a7949ddf1c5b4f491cc900e20d9603f1abfba |
File details
Details for the file wagtailcharts-0.3-py3-none-any.whl
.
File metadata
- Download URL: wagtailcharts-0.3-py3-none-any.whl
- Upload date:
- Size: 288.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1edd5a751cef30e340ea159ec84d2628297dccf7cac99a7b1993a6c1bb598bc |
|
MD5 | b78b90043d9dca675a2d0424ec31a45c |
|
BLAKE2b-256 | 359be5c515a5c1c414c1d2c27b6c6e1dd1ab07448f7a792984e31693104d9944 |