1- # Wagtail Charts
2- Chart.js charts in Wagtail, edited and customised from the Wagtail admin
1+ # Wagtail Tables
2+ jspreadsheet tables in Wagtail, edited and customised from the Wagtail admin
33
44## Getting started
55
@@ -17,13 +17,13 @@ INSTALLED_APPS = [
1717]
1818```
1919
20- Add a wagtailtables ChartBlock to one of your StreamFields:
20+ Add a wagtailtables TableBlock to one of your StreamFields:
2121
2222``` python
23- from wagtailtables.blocks import ChartBlock
23+ from wagtailtables.blocks import TableBlock
2424
2525class ContentBlocks (StreamBlock ):
26- chart_block = ChartBlock ()
26+ table_block = TableBlock ()
2727```
2828
2929Include your streamblock in one of your pages
@@ -37,12 +37,10 @@ class HomePage(Page):
3737 ]
3838```
3939
40- Add the ` wagtailtables_tags ` templatetag to your template and call the ` render_charts ` tag just before your ` </body> ` closing tag.
41- Please note that you must render your chart block so that the ` render_charts ` tag can detect the charts.
42- Here is a tiny example of a page rendering template:
40+ Simply render your table block as you would render any other block.
4341
4442``` django
45- {% load wagtailcore_tags wagtailtables_tags %}
43+ {% load wagtailcore_tags %}
4644
4745{% block content %}
4846<div class="container-fluid">
@@ -57,65 +55,7 @@ Here is a tiny example of a page rendering template:
5755 {% endfor %}
5856</div>
5957{% endblock %}
60-
61- {% block extra_js %}
62- {% render_charts %}
63- {% endblock %}
64- ```
65-
66- ## Configuration
67-
68- ` ChartBlock ` accepts a few extra arguments in addition to the standard ` StructBlock ` arguments.
69-
70- ### ` colors `
71- A tuple of color tuples defining the available colors in the editor.
72-
73- ``` python
74- from wagtailtables.blocks import ChartBlock
75-
76- COLORS = (
77- (' #ff0000' , ' Red' ),
78- (' #00ff00' , ' Green' ),
79- (' #0000ff' , ' Blue' ),
80- )
81-
82- class ContentBlocks (StreamBlock ):
83- chart_block = ChartBlock(colors = COLORS )
84- ```
85-
86- ### ` chart_types `
87-
88- You can override the default chart types available for your ` ChartBlock ` instance:
89-
90- ``` python
91- from wagtailtables.blocks import ChartBlock
92-
93- CHART_TYPES = (
94- (' line' , ' Custom title for line chart' ),
95- )
96-
97- class ContentBlocks (StreamBlock ):
98- chart_block = ChartBlock(chart_types = CHART_TYPES )
99- ```
100-
101- The default types are:
102-
103- ``` python
104- CHART_TYPES = (
105- (' line' , ' Line Chart' ),
106- (' bar' , ' Vertical Bar Chart' ),
107- (' bar_horizontal' , ' Horizontal Bar Chart' ),
108- (' area' , ' Area Chart' ),
109- (' multi' , ' Combo Line/Bar/Area Chart' ),
110- (' pie' , ' Pie Chart' ),
111- (' doughnut' , ' Doughnut Chart' ),
112- (' radar' , ' Radar Chart' ),
113- (' polar' , ' Polar Chart' ),
114- )
11558```
11659
117-
11860## Dependencies
11961* This project relies on [ Jspreadsheet Community Edition] ( https://bossanova.uk/jspreadsheet/v4/ ) for data entry and manipulation.
120- * Charts are rendered using [ Chart.js] ( https://www.chartjs.org/ ) .
121- * 100% stacked bar charts use a plugin [ https://github.com/y-takey/chartjs-plugin-stacked100 ] ( https://github.com/y-takey/chartjs-plugin-stacked100 )
0 commit comments