pages/_includes/scripts/chartjs.liquid
George 08d562a104
Offline mode (closes #1181) (#2312)
Created a plugin to tackle #1181. Currently have an issue with tikzjax
since it imports some wasm file from its javascript. The rest should
work as expected.

---------

Signed-off-by: George Araujo <george.gcac@gmail.com>
2024-04-08 14:51:28 -03:00

20 lines
633 B
Plaintext

{% if page.chart and page.chart.chartjs %}
<script defer src="{{ site.third_party_libraries.chartjs.url.js }}"></script>
<script>
$(document).ready(function () {
var $canvas = null,
$this = null,
_ctx = null,
_text = '';
$('.language-chartjs').each(function () {
$this = $(this);
$canvas = $('<canvas></canvas>');
_text = $this.text();
$this.text('').append($canvas);
_ctx = $canvas.get(0).getContext('2d');
_ctx && _text && new Chart(_ctx, JSON.parse(_text)) && $this.attr('data-processed', true);
});
});
</script>
{% endif %}