30 lines
709 B
PHP
Executable File
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
|
|
]);
|
|
|