How to change date format on chart?
-
How to change date format on chart x axis? I want to change "22 May" to "May 22" etc, is that possible?
-
/ui/docs/ng-mango/ma-serial-chart
Read the docs under API Docs -> components -> maSerialChart
there's an attribute you can set to alter the format:
time-format (optional) string The moment.js time format to be used in displaying timestamps on the X axis.
Put your moment.js format in there and that will let you set the format to 'DD mm' etc
-
Thanks Fox!
Just to ensure for timkk880, when he says,
moment format
he means Moment.js format
-
@timkk880 FYI by default it uses locale aware formatting. You can try changing the system wide locale (under system settings, language settings), or just change your user's locale.
-
@phildunlap thanks Phil, I'll be sure to keep that in mind. Thank you both for your help
-
Thank you MattFox, phildunlap and Jared Wiltshire,
I searched the folder, and only found momentFilter.js, moment-timezone-with-data.js, moment-with-locales.js, moment-timezone-with-data.min.js, moment-with-locales.min.js, which one I should modify? Is that mean to replace "string" to "YYYY/MM/DD"? -
I think I may have confused you a bit...
When you use the dashboard designer, one of the options for the maSerialChart is time-format.
so:<ma-serial-chart points="chartPoints" values="chartPointValues" time-format="DD mm"></ma-serial-chart>
I trust that is more along the lines of what you are trying to accomplish. Refer to the moment.js website for their docs if you are looking to format the time value in a specific manner.
-
Thank you MattFox, I get it!