diff --git a/src/routes/economic-indicator/+page.svelte b/src/routes/economic-indicator/+page.svelte index 3d62cad1..78cbb2de 100644 --- a/src/routes/economic-indicator/+page.svelte +++ b/src/routes/economic-indicator/+page.svelte @@ -24,6 +24,7 @@ let optionsCPI; let filterRule = 'annual'; let timePeriod = 'threeYears'; +const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; function filterEndOfYearDates(data) { @@ -180,6 +181,14 @@ async function plotData() { xAxis: { axisLabel: { color: '#fff', + formatter: function (value) { + // Assuming dates are in the format 'yyyy-mm-dd' + // Extract the month and day from the date string and convert the month to its abbreviated name + const dateParts = value.split('-'); + const year = dateParts[0].substring(2); // Extracting the last two digits of the year + const monthIndex = parseInt(dateParts[1]) - 1; // Months are zero-indexed in JavaScript Date objects + return `${monthNames[monthIndex]} '${year}`; + } }, data: dates, type: 'category', @@ -234,6 +243,14 @@ async function plotCPI() { xAxis: { axisLabel: { color: '#fff', + formatter: function (value) { + // Assuming dates are in the format 'yyyy-mm-dd' + // Extract the month and day from the date string and convert the month to its abbreviated name + const dateParts = value.split('-'); + const year = dateParts[0].substring(2); // Extracting the last two digits of the year + const monthIndex = parseInt(dateParts[1]) - 1; // Months are zero-indexed in JavaScript Date objects + return `${monthNames[monthIndex]} '${year}`; + } }, data: dates, type: 'category',