<?php

namespace Macymed\MacymedLinkTracker\Utils;

use Macymed\MacymedLinkTracker\Admin\Hooks;

if (! defined('ABSPATH')) {
    exit; // Sécurité
}

class Chart
{
    public static function init()
    {
        add_action('macymed_link_tracker_details_url_graph_evolution', [Chart::class, 'renderGraphEvolution'], 10);
        add_action('macymed_link_tracker_details_url_graph_network', [Chart::class, 'renderGraphNetwork'], 10);
    }
    public static function renderGraphNetwork($id, $url = null)
    {
        do_action('macymed_link_tracker_pro_details_url_graph_network', 'Graph de type network');
    }

    public static function renderGraphEvolution($id, $url = null)
    {
        ?>
        <div>
            <canvas id="myChart"></canvas>

        </div>
        <script>
            (async function() {
                await generateGraph('myChart');
            })();
        </script>
<?php
    }
}
