Create a "running integral" of values from another measurement

In InfluxDB 2, I have my battery charge / discharge power (in Watt) as follows:

As you can see, the battery supplied power from 20:00 yesterday to ~7:15 today, then a few short bursts during the morning, and was charged again (drain <0) between 13:00 and 15:00.

I would like to add the battery power (in Wh) to this graph. To do this I would have to calculate a “running integral” from the start of the graph to each point in time, summing up the area below the graph. I know that the drain or charge can be off by a constant (as all integrals can) but I can live with that.

I have found the integral() function but this always returns only a single value.

How do I create a “running integral” which returns just as many datapoints as the input function?

Thank you!