/* CSS để điều chỉnh độ cao dòng và hộp nhập */ #currencyForm { margin-bottom: 30px; } #currencyForm label, #currencyForm select, #currencyForm input, #currencyForm button { display: block; margin-bottom: 50px; font-size: 16px; line-height: 2; } #currencyForm select, #currencyForm input { height: 40px; padding: 5px 10px; font-size: 16px; border-radius: 5px; border: 1px solid #ccc; } #currencyForm button { height: 40px; padding: 5px 20px; font-size: 16px; background-color: #007BFF; color: white; border: none; border-radius: 5px; cursor: pointer; } #currencyForm button:hover { background-color: #0056b3; } .chart-container { margin-top: 75px; margin-bottom: 75px; } /* Thêm class để điều chỉnh khoảng cách trên cho biểu đồ */ .chart-container .chart { margin-top: 35px; /* Điều chỉnh giá trị này để thay đổi khoảng cách */ } So Sánh Tỷ Giá Tiền Tệ Các Đồng tiền trong danh mục Hãy chọn 1 đồng tiền từ nút thả để so sánh Xem hướng dẫn bên dưới để hiểu cách tương tác biểu đồ. Biểu Đồ 1: So sánh tiền tệ USD EUR CNY JPY RUB CHF GBP INR SGD Chọn đồng tiền để so sánh: Đô la Mỹ (USD) Bảng Anh (GBP) Yên Nhật (JPY) Euro (EUR) Rúp Nga (RUB) Nhân dân tệ (CNY) Rupee Ấn Độ (INR) Franc Thụy Sĩ (CHF) Đô la Singapore (SGD) Biểu đồ 2: USD EUR CNY JPY RUB CHF GBP INR SGD + đồng KRW (Won Hàn Quốc) Chọn đồng tiền để so sánh: Đô la Mỹ (USD) Bảng Anh (GBP) Yên Nhật (JPY) Won Hàn Quốc (KRW) Euro (EUR) Rúp Nga (RUB) Nhân dân tệ (CNY) Rupee Ấn Độ (INR) Franc Thụy Sĩ (CHF) Đô la Singapore (SGD) Biểu đồ 3: Danh mục USD EUR CNY JPY RUB CHF GBP INR SGD KRW + VND (Đồng Việt Nam) Chọn đồng tiền để so sánh: Đô la Mỹ (USD) Bảng Anh (GBP) Yên Nhật (JPY) Won Hàn Quốc (KRW) Euro (EUR) Rúp Nga (RUB) Nhân dân tệ (CNY) Rupee Ấn Độ (INR) Franc Thụy Sĩ (CHF) Đô la Singapore (SGD) Đồng Việt Nam (VND) Biểu Đồ 4: So Sánh Tiền Tệ Các Nước Đông Nam Á Chọn đồng tiền để so sánh: Đô la Singapore (SGD) Baht Thái (THB) Ringgit Malaysia (MYR) Đồng Việt Nam (VND) Rupiah Indonesia (IDR) Kip Lào (LAK) Peso Philippines (PHP) Riel Campuchia (KHR) Đô la Brunei (BND) Kyat Myanmar (MMK) Đồng Timor-Leste (TLS) const currencies1 = ["USD", "GBP", "JPY", "EUR", "RUB", "CNY", "INR", "CHF", "SGD"]; const currencies2 = ["USD", "GBP", "JPY", "KRW", "EUR", "RUB", "CNY", "INR", "CHF", "SGD"]; const currencies3 = ["USD", "GBP", "JPY", "KRW", "EUR", "RUB", "CNY", "INR", "CHF", "SGD", "VND"]; const currencies4 = ["SGD", "THB", "MYR", "VND", "IDR", "LAK", "PHP", "KHR", "BND", "MMK", "TLS"]; const currencyNames = { "USD": "Đô la Mỹ (USD)", "GBP": "Bảng Anh (GBP)", "JPY": "Yên Nhật (JPY)", "KRW": "Won Hàn Quốc (KRW)", "EUR": "Euro (EUR)", "RUB": "Rúp Nga (RUB)", "CNY": "Nhân dân tệ (CNY)", "INR": "Rupee Ấn Độ (INR)", "CHF": "Franc Thụy Sĩ (CHF)", "SGD": "Đô la Singapore (SGD)", "VND": "Đồng Việt Nam (VND)", "THB": "Baht Thái (THB)", "MYR": "Ringgit Malaysia (MYR)", "IDR": "Rupiah Indonesia (IDR)", "LAK": "Kip Lào (LAK)", "PHP": "Peso Philippines (PHP)", "KHR": "Riel Campuchia (KHR)", "BND": "Đô la Brunei (BND)", "MMK": "Kyat Myanmar (MMK)", "TLS": "Đồng Timor-Leste (TLS)" // Thêm tên tiền tệ này với ký hiệu khác USD }; function formatNumber(value) { return new Intl.NumberFormat('de-DE', { minimumFractionDigits: 0, maximumFractionDigits: 3 }).format(value); } function formatPercentage(value) { if (isNaN(value)) return ''; const precision = Math.abs(value) < 1 ? 3 : 2; return `${value.toFixed(precision)}%`; } function compareCurrencies(container, currencies, baseCurrencyId, chartTitle) { const baseCurrency = document.getElementById(baseCurrencyId).value; fetch('/wp-content/uploads/exchange_rates_history.json') .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { const dates = Object.keys(data).map(date => new Date(date)); const seriesData = []; const colors = ['#007BFF', '#FF5733', '#FFC300', '#DAF7A6', '#C70039', '#900C3F', '#581845', '#28B463', '#138D75', '#1ABC9C']; currencies.forEach((currency, index) => { if (currency !== baseCurrency) { const rates = dates.map(date => data[date.toISOString().split('T')[0]][currency] / data[date.toISOString().split('T')[0]][baseCurrency]); const percentageChanges = rates.map((rate, index) => { if (index === 0) return { y: rate, percentageChange: NaN }; const previousRate = rates[index - 1]; const change = ((rate - previousRate) / previousRate) * 100; return { y: rate, percentageChange: change }; }); seriesData.push({ name: currencyNames[currency], data: percentageChanges, color: colors[index % colors.length], fillColor: { linearGradient: [0, 0, 0, 300], stops: [ [0, colors[index % colors.length] + '80'], // 80 là độ trong suốt 50% [1, colors[index % colors.length] + '00'] // 00 là độ trong suốt 100% ] } }); } }); Highcharts.chart(container, { chart: { type: 'spline', zoomType: 'xy' }, title: { text: chartTitle }, xAxis: { type: 'datetime', categories: dates, title: { text: null // Ẩn tiêu đề trục x }, labels: { autoRotation: [-10, -20, -30, -40, -50, -60, -70, -80, -90], // Xoay nhãn trục x tự động align: 'right', style: { fontSize: '14px', // Chỉnh sửa kích thước color: '#000000' // Chỉnh sửa màu sắc }, formatter: function () { return Highcharts.dateFormat('%e %b %Y', this.value); } } }, yAxis: { title: { text: null // Ẩn tiêu đề trục y }, type: 'logarithmic', labels: { formatter: function () { return this.value > 1 ? formatNumber(this.value) : this.value.toFixed(3); }, style: { fontSize: '14px', // Chỉnh sửa kích thước color: '#000000' // Chỉnh sửa màu sắc } } }, tooltip: { pointFormatter: function () { const color = this.percentageChange >= 0 ? 'green' : 'red'; const formattedChange = formatPercentage(this.percentageChange); return `${this.series.name}: ${formatNumber(this.y)} ${formattedChange}`; } }, exporting: { buttons: { contextButton: { menuItems: [ "viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG" ] } } }, plotOptions: { spline: { marker: { enabled: false }, lineWidth: 2, states: { hover: { lineWidth: 3 } }, threshold: null } }, credits: { text: 'Tien.Day', href: 'https://Tien.Day', enabled: true }, series: seriesData }); }) .catch(error => { console.error('Error fetching exchange rate data:', error); }); } // Khởi tạo biểu đồ ban đầu khi tải trang document.addEventListener('DOMContentLoaded', () => { // Tải biểu đồ đầu tiên ngay lập tức compareCurrencies('container1', currencies1, 'baseCurrency1', 'Danh mục USD EUR CNY JPY RUB CHF GBP INR SGD | Tien.Day'); // Tải các biểu đồ còn lại với trì hoãn setTimeout(() => compareCurrencies('container2', currencies2, 'baseCurrency2', 'Danh mục USD EUR CNY JPY RUB CHF GBP INR SGD + KRW | Tien.Day'), 3000); setTimeout(() => compareCurrencies('container3', currencies3, 'baseCurrency3', 'Danh mục USD EUR CNY JPY RUB CHF GBP INR SGD KRW + VND | Tien.Day'), 6000); setTimeout(() => compareCurrencies('container4', currencies4, 'baseCurrency4', 'Biểu Đồ So Sánh Tiền Tệ Các Nước Đông Nam Á | Tien.Day'), 9000); });