Can you "grow" a TH1D on the x-axis?


I am analysing runs, plotting the event number on the x-axis and some value on the y-axis. I never know how many events a run may have, this can vary from 100 to 50,000.

I am currently running my code once to determine how many events there are and then changing my histogram constructors to set the number of bins to the number of events.

Is there a way for me to setup a TH1D so that every new event adds 1 to the number of bins, extends the range by 1, and plots it’s y value?