Text not showing running total

I have a plot to show a running total across time. It works fine, but I am stuck in showing the latest value at the end of a line chart. I tried a few options, shown below, the chart works, the tooltip shows the right values (running total), but the text values are showing the month totals but not the running totals.
Clearly I am missing something.

   Plot.text(data_driver,
      Plot.mapY("cumsum", {
        x: (d) => new Date(d.d_month),
        y: "d_count",
        text: "d_count",
        dy: -5,
        tip: true,
      })),

Thank you.

Here only the y channel is mapped with the cumsum reducer. You’ll want to map the text channel. To do so, there is not Plot.mapText method, but you can use the generic map method. Probably something like:

    Plot.text(data_driver,
      Plot.map({
        y: "cumsum",
        text: "cumsum"
      }, {
        x: (d) => new Date(d.d_month),
        y: "d_count",
        text: "d_count",
        dy: -5,
        tip: true,
      })
    )

Brilliant, thank you.