Renders data charts (bar / line / pie / donut) from a native Markdown table inside a ::: container, using Chart.js v4 on the client.
To load this plugin, add the following to the extras block in your
config.php or
theme settings.php:
'extras' => [
// ...
'chartjs' => [],
// ...
],
The chartjs extra supports the following global configuration options:
| Key | Default | Description |
|---|---|---|
colors |
[ '#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF', '#FF9F40' ] |
Array of CSS color strings used as the dataset palette |
title |
true |
Whether to display chart titles |
legend |
true |
Whether to display the legend |
Example configuration in PHP:
'extras' => [
'chartjs' => [
'colors' => [ '#FF0000', '#00FF00', '#0000FF' ],
'title' => false,
'legend' => true
],
],
:::bar
# Monthly Signups
| Month | Signups |
|:-----:|--------:|
| Jan | 10 |
| Feb | 45 |
| Mar | 22 |
:::
:::line
# Sales Trend
| Month | Revenue | Expenses |
|-------|---------|----------|
| Jan | 100 | 60 |
| Feb | 150 | 80 |
| Mar | 200 | 90 |
:::
:::pie
# Market Share
| Product | Share |
|---------|-------|
| A | 40 |
| B | 30 |
| C | 20 |
| D | 10 |
:::
:::donut
# Budget Allocation
| Category | Amount |
|----------|--------|
| Marketing| 500 |
| R&D | 300 |
| Operations| 200 |
:::
Use the .stacked class to enable stacked charts:
:::bar .stacked
# Team Performance
| Task | Alice | Bob | Carol |
|------|-------|-----|-------|
| Task 1 | 50 | 70 | 60 |
| Task 2 | 80 | 90 | 40 |
:::
Use the .fill class to fill the area under line charts:
:::line .fill
# Temperature
| Day | Celsius |
|-----|---------|
| Mon | 20 |
| Tue | 22 |
| Wed | 18 |
| Thu | 25 |
:::
Use the .no-legend class to hide the legend:
:::pie .no-legend
# Preferences
| Color | Count |
|-------|-------|
| Red | 30 |
| Blue | 40 |
| Green | 30 |
:::
The charts use a default color palette, which can be customized via the colors configuration option. Colors are applied in order to datasets.
If JavaScript is disabled or the chartjs extra fails to load, the raw Markdown table will remain visible as-is. This fallback works automatically since the table is only replaced during the upgrade process, not before.
This extra is client-side only and its scripts are stripped for crawlers.