Files
wevads-platform/scripts/hamid-charts.php
2026-02-26 04:53:11 +01:00

30 lines
709 B
PHP
Executable File

<?php
header('Content-Type: application/json');
$type = $_POST['type'] ?? 'bar'; // bar, line, pie, doughnut
$data = json_decode($_POST['data'] ?? '{}', true);
$title = $_POST['title'] ?? 'Chart';
// Générer config Chart.js
$config = [
'type' => $type,
'data' => $data,
'options' => [
'responsive' => true,
'plugins' => [
'title' => ['display' => true, 'text' => $title],
'legend' => ['position' => 'top']
]
]
];
// URL QuickChart (gratuit)
$chartUrl = "https://quickchart.io/chart?c=" . urlencode(json_encode($config)) . "&w=600&h=400";
echo json_encode([
'success' => true,
'chart_url' => $chartUrl,
'config' => $config
]);