This module provides a Twig extension that enables you to generate charts in Twig using that Charts module API. Make sure you've installed the Charts module (including at least one submodule (and associated library), and set a default library at /admin/config/content/charts).
Your Twig might look something like:
{% set title = 'The Chart Title' %}
{% set data = [10, 20, 30] %}
{% set data2 = [8, 14, 22] %}
{%
set series = {
'my_first_series' : {
'title' : 'My first series',
'data' : data,
'color': 'purple'
},
'my_second_series' : {
'title' : 'My second series',
'data' : data2
}
}
%}
{%
set xaxis = {
'title' : 'X-Axis Label',
'labels' : ['a', 'b', 'c']
}
%}
{{ chart('my_twig_chart', 'column', title, series, xaxis, [], []) }}
If you plan to use translation, use the |t or |trans filter in your Twig.
Support
Support Charts and Similar Modules
The Charts module is part of an ecosystem dedicated to empowering users to store, visualize, and analyze their data. Please consider helping to financially support the Charts ecosystem by becoming a backer or by making a one-time contribution to say thanks by joining the Charts module's Open Collective.
| Become a Backer | Say Thanks |
There are plenty of other ways to help maintain, further enhance, and support the Charts module, as detailed in how to contribute.