new_site/_includes/scripts/chartjs.liquid

25 lines
742 B
Plaintext

{% if page.chart and page.chart.chartjs %}
<script
defer
src="{{ site.third_party_libraries.chartjs.url.js }}"
integrity="{{ site.third_party_libraries.chartjs.integrity.js }}"
crossorigin="anonymous"
></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 %}