How to get time division data when data reset to 0

Hi Guys,
I using Grafana and influxdb to collect ‘product data’ in the assembly line. I make a chat by grafana to show how many products was done in every hour.

It works good, but i have one problem, sometimes the worker will clear the total count because of shifts change. this cause the division data less than 0.

Considering this serial data(each data 10 minutes):
100 200 300 400 0 10 20
the correct time division in this hour should be (400-100) + (20-0) = 320

I tried also search but no help, do you have any ideas? (Sperate to 2 time divisions when data set to 0 is also OK , in this sample, we can get two bars with 300 and 20)

Thanks a lot!