Using DateTime on the X axis of a ChartsJS LineChart

1
Newbie here, so please bear with me.   I'm currently trying to plot an animal's weight over time in a linechart. To do so, I've been trying to get the date of the weight measurement on the X axis. The actual line is plotted properly, but something appears to be going wrong with the x axis. I've checked the values in my microflows and they are actual datetimes, so I'm not actually sure where things are going wrong. I've attached a screenshot of the problem below. Please let me know if you require anything else (domain models, microflows, etc.) to get a clear picture of what's happening. I'd really appreciate any advice on where to look for a solution to this problem. Thank you in advance!      
asked
2 answers
3

Hi Eline,

I think the number you see is a representation in ticks of your datetime. I would advice to convert your datetime to a string value and use this in your datapoint

formatDateTime($yourEntity/attributeName, 'dd/MM/yyyy')

 

Regards,

answered
2

Hi Eline,
I would like to extend on what Corne already suggests. The chart widget allows you to provide two values for the x axis:

an XValue attribute and a XSortingValue. The XValue attribute is what is shown in the UI and the XSorttingValue is used to order the data points. If you have a DateTime attribute called "Date" then you can parse this as Corne suggests and connect it to the XValue. Additionally, sort the list and add the indexes as a new Integer attribute which is connected to the XSortingValue.

Hope this helps,

Andrej

answered