diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-05-24 22:53:19 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-05-24 22:53:19 +0200 |
| commit | b15201fd9ddb1a6ef9c52f55aab928345da8c59e (patch) | |
| tree | 1db26b9b7b82d7c9f83b7cdaa783cf2419a482ca /layouts/shortcodes/perf-chart.html | |
| parent | d74516ce030f71044d85c285169d4927ec3e21db (diff) | |
Publish article
Diffstat (limited to 'layouts/shortcodes/perf-chart.html')
| -rw-r--r-- | layouts/shortcodes/perf-chart.html | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/layouts/shortcodes/perf-chart.html b/layouts/shortcodes/perf-chart.html index ff13130..b47e519 100644 --- a/layouts/shortcodes/perf-chart.html +++ b/layouts/shortcodes/perf-chart.html @@ -3,6 +3,8 @@ {{- $labelsRaw := .Get "labels" -}} {{- $datasetsRaw := .Get "datasets" -}} {{- $xAxisLabel := .Get "xAxisLabel" | default "Time (ms)" -}} +{{- $stackedRaw := .Get "stacked" | default "true" -}} +{{- $stacked := ne $stackedRaw "false" -}} {{/* Load chart configuration */}} {{- $config := site.Data.chart_presets -}} @@ -50,22 +52,24 @@ <script> document.addEventListener('DOMContentLoaded', function() { const ctx = document.getElementById('{{ $id }}').getContext('2d'); + const chartData = {{ dict "labels" $labels "datasets" $parsedDatasets | jsonify | safeJS }}; + chartData.datasets = chartData.datasets.map(ds => ({ ...ds, data: ds.data.map(Number) })); new Chart(ctx, { type: 'bar', - data: {{ dict "labels" $labels "datasets" $parsedDatasets | jsonify | safeJS }}, + data: chartData, options: { responsive: true, maintainAspectRatio: false, indexAxis: 'y', scales: { x: { - stacked: true, + stacked: {{ $stacked }}, title: { display: true, text: '{{ $xAxisLabel }}' } }, - y: { } + y: { stacked: {{ $stacked }} } }, plugins: { legend: { position: 'top' }, |
