From 9853ce05d459847d9acb87ed8f545c6054c4365e Mon Sep 17 00:00:00 2001 From: Lanta Date: Wed, 8 Nov 2023 20:03:52 +0100 Subject: [PATCH] per player --- demo.php | 61 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/demo.php b/demo.php index c8dbcf3..0c66151 100644 --- a/demo.php +++ b/demo.php @@ -59,9 +59,24 @@ if ($handle = opendir($directory)) { // $playerData = $dataPointsPerPlayer['Lanta01']; // Output the array for debugging purposes -echo '
';
-print_r($dataPointsPerPlayer);
-echo '
'; +// At the end of your PHP script, where you previously printed the array +// Instead, we will encode the $dataPointsPerPlayer array into JSON +$chartData = []; +foreach ($dataPointsPerPlayer as $player => $dataPoints) { + $chartData[] = [ + 'type' => 'line', + 'showInLegend' => true, + 'legendText' => $player, + 'dataPoints' => $dataPoints + ]; +} + +// Store the JSON encoded data in a PHP variable +$encodedChartData = json_encode($chartData, JSON_NUMERIC_CHECK); + +// You can then pass this to your JavaScript code like this +echo ""; + ?> @@ -72,23 +87,33 @@ echo ''; +