Skip to content

Commit

Permalink
UPdate readme
Browse files Browse the repository at this point in the history
  • Loading branch information
saevarom committed Apr 26, 2022
1 parent f36c0d4 commit 8b10455
Showing 1 changed file with 7 additions and 67 deletions.
74 changes: 7 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Wagtail Charts
Chart.js charts in Wagtail, edited and customised from the Wagtail admin
# Wagtail Tables
jspreadsheet tables in Wagtail, edited and customised from the Wagtail admin

## Getting started

Expand All @@ -17,13 +17,13 @@ INSTALLED_APPS = [
]
```

Add a wagtailtables ChartBlock to one of your StreamFields:
Add a wagtailtables TableBlock to one of your StreamFields:

```python
from wagtailtables.blocks import ChartBlock
from wagtailtables.blocks import TableBlock

class ContentBlocks(StreamBlock):
chart_block = ChartBlock()
table_block = TableBlock()
```

Include your streamblock in one of your pages
Expand All @@ -37,12 +37,10 @@ class HomePage(Page):
]
```

Add the `wagtailtables_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:
Simply render your table block as you would render any other block.

```django
{% load wagtailcore_tags wagtailtables_tags %}
{% load wagtailcore_tags %}
{% block content %}
<div class="container-fluid">
Expand All @@ -57,65 +55,7 @@ Here is a tiny example of a page rendering template:
{% 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.

```python
from wagtailtables.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:

```python
from wagtailtables.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:

```python
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'),
)
```


## Dependencies
* This project relies on [Jspreadsheet Community Edition](https://bossanova.uk/jspreadsheet/v4/) for data entry and manipulation.
* Charts are rendered using [Chart.js](https://www.chartjs.org/).
* 100% stacked bar charts use a plugin [https://github.com/y-takey/chartjs-plugin-stacked100](https://github.com/y-takey/chartjs-plugin-stacked100)

0 comments on commit 8b10455

Please sign in to comment.