<?php
/**
 * @package matomo
 */
namespace WpMatomo\Admin;

use WpMatomo\Feature;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // if accessed directly
}

class Chart extends Feature {
	public function register_hooks() {
		add_action( 'matomo_load_chartjs', [ $this, 'load_chartjs' ] );
	}

	public function load_chartjs() {
		wp_enqueue_script( 'chart.js', plugins_url( 'node_modules/chart.js/dist/chart.min.js', MATOMO_ANALYTICS_FILE ), [], matomo_get_asset_version(), true );
		wp_enqueue_script( 'matomo_chart.js', plugins_url( 'assets/chart.js', MATOMO_ANALYTICS_FILE ), [], matomo_get_asset_version(), true );
	}

	public function is_active() {
		return is_admin();
	}
}
