Spline line graph being funky and out of order

Would you be able to suggest how to avoid this behavior on a time-on-x-axis graph:

The x axis is timestamps. The y axis is an integer. Haven't found exactly why this behavior occurs or when. It should be connecting dots left to right, not top to bottom!!

Appreciate any help!

Hi @Ori, this behavior can happen when the input data is ordered/sorted in a different order than the date. Choosing the date as the x-axis doesn't automatically order the line.

If the data is coming from a SQL query you could ORDER BY date_column_name ASC, or if you want to use javascript you can sort by the date like so:
return data.sort((a,b) => new Date(b.date) - new Date(a.date))

2 Likes

awesome tyty!

1 Like