Can't position annotation by date

I have a timeline that is basically an x-axis of dates, and annotations for events at particular dates. They are not evenly spaced, because I want to show events at particular dates. I have specified one of the dates as the x-position of the annotation, but it’s not showing up at the right place. Here is a fiddle: https:// jsfiddle.net/ abalter/98phb124/

Here’s a working version: https://jsfiddle.net/etpinard/98phb124/3/

As mentioned in Dates on x-axis not spaced appropriately, plotly only understand a limited set strings as dates. The above version has the annotation x attribute set to a unix timestamp.

For date string like the one in your example, the convert function would be:

function toDate(d) {
  var parts = d.split('/');
  
  return new Date(parts[2], parts[0], parts[1]).getTime();
} 
1 Like

Excelent! Thanks for filling me in about the date format, and providing the function.