# Creating area chart based on data that contains time ranges

**URL:** <https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985>\
**Category:** Kibana\
**Created:** [May 7, 2019, 1:36pm UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985 "2019-05-07T13:36:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samkit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samkit/32/45734_2.png) [@samkit](https://discuss.elastic.co/u/samkit)\
**Post date:** [May 7, 2019, 1:36pm UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985/1 "2019-05-07T13:36:12Z")

</div>

I have data in the below form which tells between [start\_time, end\_time] I have processed "total\_bytes\_processed" data and my average processing power in that duration was "average\_bytes\_processed\_per\_second" (can be computed from the remaining 3 fields as well).

> {  
> "start\_time": "2019-05-01 01:00:00.000Z",  
> "end\_time": "2019-05-04 01:00:00.000Z",  
> "total\_bytes\_processed": 102345,  
> "average\_bytes\_processed\_per\_second": 12  
> }

My requirement is to aggregate "average\_bytes\_processed\_per\_second" across overlapping intervals of [start\_time, end\_time] and show as an area chart.

For eg if the dataset is having 2 records like below:

> [{  
> "start\_time": "2019-05-01 00:00:00.000Z",  
> "end\_time": "2019-05-03 00:00:00.000Z",  
> "total\_bytes\_processed": 102345,  
> "average\_bytes\_processed\_per\_second": 12  
> },  
> {  
> "start\_time": "2019-05-02 00:00:00.000Z",  
> "end\_time": "2019-05-05 01:00:00.000Z",  
> "total\_bytes\_processed": 102345,  
> "average\_bytes\_processed\_per\_second": 12  
> }]

then the output area chart will show data in somewhat below form (where from\_time and to\_time show the start and end time for a particular value on x-axis):

> [{  
> "from\_time": "2019-05-01 00:00:00.000Z",  
> "to\_time": "2019-05-02 00:00:00.000Z",  
> "average\_bytes\_processed\_per\_second": 12  
> },  
> {  
> "from\_time": "2019-05-02 00:00:00.000Z",  
> "to\_time": "2019-05-03 00:00:00.000Z",  
> "average\_bytes\_processed\_per\_second": 17  
> },  
> {  
> "from\_time": "2019-05-03 00:00:00.000Z",  
> "to\_time": "2019-05-05 00:00:00.000Z",  
> "average\_bytes\_processed\_per\_second": 5  
> }]

I have tried a few things but I haven't been successful yet, so wanted to know how would others do it?

PS: I don't have access to change source data format/type.

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [May 7, 2019, 11:16pm UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985/2 "2019-05-07T23:16:24Z")

</div>

Hey @samkit -- would something like this achieve what you are looking for?

- Create an area chart
- Under Metrics, set a Sum aggregation on `average_bytes_processed_per_second`
- Under Buckets, do a Date Histogram aggregation on `start_time`, with your interval set to `daily`

A vertical bar chart would probably be even clearer in this case, as you'd have one bar for each day, with the sum of total bytes processed per second for that day.

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [May 7, 2019, 11:19pm UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985/3 "2019-05-07T23:19:15Z")

</div>

Ah actually, as I think about this, I'm not 100% certain this will calculate the sum as you want it to -- but either way let me know what you find.

---

<div class="post-metadata">

**Author:** ![samkit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samkit/32/45734_2.png) [@samkit](https://discuss.elastic.co/u/samkit)\
**Post date:** [May 8, 2019, 4:08am UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985/4 "2019-05-08T04:08:20Z")

</div>

Hi @lukeelmers - yeah this is not what I want. I also want to consider range between start\_time and end\_time. What you suggested will work if I had just single timestamp field but I have a time range which i want to consider.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 5, 2019, 4:08am UTC](https://discuss.elastic.co/t/creating-area-chart-based-on-data-that-contains-time-ranges/179985/5 "2019-06-05T04:08:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
