<h2>جدول مقارنة أسعار الذهب</h2><table><thead><tr><th>نوع الذهب</th><th>سعر الشراء الأخير</th><th>سعر البيع الأخير</th><th>سعر الشراء السابق</th><th>سعر البيع السابق</th><th>فرق الشراء</th><th>فرق البيع</th></tr></thead><tbody><tr><td>21</td><td>3395</td><td>3379</td><td>3395</td><td>3379</td><td>0</td><td>0</td></tr></tbody></table><h2>منحنى سعر الذهب عيار 21 في مصر خلال شهر</h2> <h3>آخر سعر شراء: 3395 جنيه، آخر سعر بيع: 3379 جنيه، تاريخ آخر إدخال: 2024-09-11 17:42:21.781265</h3> <div class="chart-container"> <canvas id="goldPricesChart"></canvas> </div> <script> // Fetch data from PHP const data = [{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3370"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3400","sell_price":"3380"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3395","sell_price":"3384"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3395","sell_price":"3384"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3395","sell_price":"3384"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3395","sell_price":"3384"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3450","sell_price":"3430"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3388","sell_price":"3377"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3385","sell_price":"3374"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3387","sell_price":"3376"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3378"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3390","sell_price":"3374"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3395","sell_price":"3379"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3450","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3440","sell_price":"3428"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3434"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3445","sell_price":"3425"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3425","sell_price":"3409"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3410","sell_price":"3390"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3385","sell_price":"3370"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3370","sell_price":"3354"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3380","sell_price":"3360"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 15:26:35.149409","buy_price":"3375","sell_price":"3359"},{"entery_date":"2024-09-11 17:42:21.781265","buy_price":"3395","sell_price":"3379"}]; // Debugging: Log the data to console console.log("Data from PHP:", data); // Prepare data for Chart.js const dates = data.map(entry => entry.entery_date); const buyPrices = data.map(entry => entry.buy_price); const sellPrices = data.map(entry => entry.sell_price); // Debugging: Log the prepared data to console console.log("Dates:", dates); console.log("Buy Prices:", buyPrices); console.log("Sell Prices:", sellPrices); const ctx = document.getElementById("goldPricesChart").getContext("2d"); const goldPricesChart = new Chart(ctx, { type: "line", data: { labels: dates, datasets: [ { label: "Buy Price", data: buyPrices, borderColor: "rgba(75, 192, 192, 1)", fill: false, tension: 0.4 // Adjust tension for a smoother curve }, { label: "Sell Price", data: sellPrices, borderColor: "rgba(255, 99, 132, 1)", fill: false, tension: 0.4 // Adjust tension for a smoother curve } ] }, options: { scales: { x: { type: "time", time: { unit: "month" } } } } }); </script>