Dygraph 2.2.1 Add Annotations to graph lines

I have dygraph charts with multiple lines of timeseries data like shown below, I wanted to display a set of annotations on top of the different chart lines where the data has been flagged.

function createGraph(div_element,graph_data) {
const dygraph_div = document.getElementById(div_element);

    gs.push(
      (g = new Dygraph(dygraph_div, await fetchData(graph_data), {
        animatedZooms: true,
        annotations: true,
        zoomCallback: function (minDate, maxDate) {
          let start_date= new Date(minDate).toLocaleString("sv");
          let end_date= new Date(maxDate).toLocaleString("sv");
          console.log("Zoomed to [", start_date, ", ", end_date, "]");
          zoom(begin_date, end_date);
        },
        legend: "always",
      }))
    );

};

The function below is used to convert an array containing information of the start and end timestamp where the data was flagged, can be up to 100 elements.

  async function convertToAnnotations(flagged_data) {
    flagged_data.forEach((flag) => {
      const { start_timestamp, stop_timestamp, chart_lines} = flag;
  
      chart_lines.forEach((line) => {
        const graph = gs.find((g) => g && g.attributes_ && g.attributes_.series_ && g.attributes_.series_[line]);
  
        if (graph) {
          const annotations = graph.annotations() || [];
  
          annotations.push({
            series: line,
            x: new Date(start_timestamp).toLocaleString("sv"),
            height: 5,
            width: 5,
            tickHeight: 1,
            shortText: "test",
            text: "Flagged data",
          });
  
          graph.setAnnotations(annotations);
        }
      });
  
    });
    console.log(gs);
  }

This is a sample result of one object inside the annotations array at the end:

height: 5
series: "A"
shortText: "test"
text: "Flagged data"
tickHeight: 1
width: 5
x: "2022-09-26 13:40:00"

My problem is, the annotations have been set in the function and I can see it when I console.log(gs) but nothing is displaying on any charts, the series does match.

I tried to use .getTime() instead of toLocaleString() but I was getting errors.

I tried to manually create html elements but it ended up not working or displaying little circles vertically or in random places, not on the proper chart lines.

I searched everywhere but I could not fix this issue so I came here.