MContentLoaded", function() {
    var products = JSON.parse('{{ products | tojson | safe }}');
    var names = products.map(p => p.name);
    var prices = products.map(p => p.price);

    var barOptions = {
      chart: { type: 'bar', height: 350 },
      series: [{ name: 'Price', data: prices }],
      xaxis: { categories: names }
    };
    var barChart = new ApexCharts(document.querySelector("#bar-chart"), barOptions);
    barChart.render();

    var pieOptions = {
      chart: { type: 'pie', height: 350