How to create a graph from sum differences?

I haven't created a pie chart yet, but that's the intention. In general, I have lots of docs that provide the duration (time) between 2 events on a specific resource id. I want to create a pie chart showing how the total time is split among the various events. Getting the pie chart slice for a specific pair of events marked in a single document seems simple enough. However, one of the slices will be a time difference between two pairs of events.

Here are the ordering of original events in index events:

<timestamp>, id, PRE_CALC_BEGIN, ...
<timestamp>, id,PRE_CALC_END
<timestamp>, id, CALC_FOO_BEGIN
... Other events
<timestamp>, id ,CALC_BAR_BEGIN
<timestamp>, id, CALC_BAR_END
... other events
<timestamp>, id, CALC_FOO_END

And I have another index durations with those event pairs of interest and a duration between events:

id, start_event, end_event, duration

The TOTAL time spent on the activity is from PRE_CALC_BEGIN --> CALC_FOO_END

I want a pie chart with 3 slices totaling to 100%:

  1. Percent of time spent between PRE_CALC_BEGIN --> PRE_CALC_END
  2. Percent of time spent between CALC_BAR_BEGIN --> CALC_BAR_END
  3. Percent of time spent in all other activities calculated as the time (CALC_FOO_BEGIN/END time - CALC_BAR_BEGIN/END time

Does that make more sense @a5a?