update x label

This commit is contained in:
MuslemRahimi 2024-08-28 10:48:04 +02:00
parent 9cef649d52
commit f022b458c4

View File

@ -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',