-
So I have a GET rest request to retrieve data and I set it to retrieve an array objects of the data instead of the whole json data. My question is, can I process the year and month into one single date and use the date to sort it in the data provider as well as the charts in the screen. The above is my json data, the year is 2022 and the month is 9, how do I transform it to September 2022/ 9.22 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @joeytzy As this is just JavaScript, you could probably find some examples online. Your transformer may look something like this: function getMonthName(monthNumber) {
const date = new Date();
date.setMonth(monthNumber - 1);
return date.toLocaleString('en-US', {
month: 'long',
});
}
return data.yearly.sales.map(sale => ({ ...sale, label: getMonthName(sale.month) + " " + sale.year })) reference: https://bobbyhadz.com/blog/javascript-convert-month-number-to-name |
Beta Was this translation helpful? Give feedback.
Hey @joeytzy
As this is just JavaScript, you could probably find some examples online. Your transformer may look something like this:
reference: https://bobbyhadz.com/blog/javascript-convert-month-number-to-name