~bittercode/pureburn

7b8c549134e307f952dd7b93c47c4de6e2ff78f8 — bittercode 8 months ago 1d23829
	new file:   layouts/shortcodes/chart.html
1 files changed, 15 insertions(+), 0 deletions(-)

A layouts/shortcodes/chart.html
A layouts/shortcodes/chart.html => layouts/shortcodes/chart.html +15 -0
@@ 0,0 1,15 @@
{{ $w := default "100" (.Get 0) }}
{{ $h := default "300" (.Get 1) }}
{{ $r := ( .Inner | chomp) }}
{{ $seed := "foo" }}
{{ $id := delimit (shuffle (split (md5 $seed) "" )) "" }}

<div style="width: {{ $w }}%;height: {{ $h }}px;margin: 0 auto">
    <canvas id="{{ $id }}"></canvas>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js/dist/chart.min.js"></script>
<script type="text/javascript">
    var ctx = document.getElementById('{{ $id }}').getContext('2d');
    var options = {{ $r | safeJS }};
    new Chart(ctx, options);
</script>
\ No newline at end of file