Calculating energy based on Power measures

Newbie question, as I just start with Grafana. I have a Power (kW) measures in InfluxDB. How could I create a bar chart with Energy measures (kWh)? I assume I need to somehow transform it and combine with time, but how to do this?

In addition to that, on a separate chart, I would like to calculate cumulative sum, that would reset every day - so at the end of the day the highest bar would tell me what was the total consumption at that day.