# How do you draw "fit" line in time series builder in kibana (7.1.1)?

**URL:** https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895
**Category:** Kibana
**Created:** [August 27, 2019, 7:51am UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895 "2019-08-27T07:51:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)
#### Post date: [August 27, 2019, 7:51am UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/1 "2019-08-27T07:51:26Z")

</div>

I am trying to draw "fit" line in time series in below red points.

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/1/f105c88d8ce95dc91be2dcd345014f9881fbf494.png)

I have referenced the [github issue](https://github.com/elastic/elasticsearch/issues/24747) but not quite sure if _fitting_ .

Can we do the fit (average) same as _timelion_ in _timeseries builder_ ?

Thanks,  
Yu Watanabe

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 27, 2019, 8:21pm UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/2 "2019-08-27T20:21:56Z")

</div>

Unfortunately it does not appear to be possible as stated in the github issue.

---

<div class="post-metadata">

### Author: ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)
#### Post date: [August 28, 2019, 2:46am UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/3 "2019-08-28T02:46:55Z")

</div>

@mattkime  
Thank you for the reply.

Reading the github conversation carefully , my understanding for _fit_ was to make chart smoother, links to the below comment by [polyfractal](https://github.com/elastic/elasticsearch/issues/24747#issuecomment-302821886).

> Upsampling/interpolating for visual consumption is totally acceptable imo. It's just making a chart more pleasant to look at, or to smooth out gaps so as to not distract the user. That's fine, and also totally doable client-side after the final aggregation is done running.

First I would like share my requirement. (My apology I did not share at first place.)

I have a dataset where each data (group of integer value) is sampled on random day.

Dataset will be something like,

2019-08-05 type: fruit, price: 100  
2019-08-05 type: veg, price: 200  
2019-08-05 type: fish, price: 300  
2019-08-13 type: fruit, price: 200  
2019-08-13 type: veg, price: 50  
2019-08-13 type: fish, price: 300  
...

For each day , I will need to calculate below metric (_price_ in above) .

1. Max
2. Min
3. Standard Deviation (_standard\_deviation_ in extended\_agg)
4. Average

To plot the data point _precisely_ on the chart , I want to use the **daily interval**.

Also, to visually understand the growth between the samples, I would like to show the line chart as below instead of interpolating the data point as **0** on other days.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/7/f796cb31abfe6ec466b041c97d83b09e39d3946f.png)

I assume _timelion_ is not the option for me since the metric aggregation does not support the _standard deviation_ .

I thought if `min_doc_count` option in date histogram is available in time serires builder , chart above might be available . Is `min_doc_count` in date histogram ?

Otherwise, I will use `vega` .

Thanks,  
Yu

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 28, 2019, 4:18pm UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/4 "2019-08-28T16:18:57Z")

</div>

Hello @YuWatanabe

I think I'm still working to understand your question. A 'fit' line attempts to summarize a dataset as an equation. It sounds to me like you want a line chart - which you have in your screenshot.

How does your screenshot differ from your goal?

---

<div class="post-metadata">

### Author: ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)
#### Post date: [September 3, 2019, 8:16am UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/5 "2019-09-03T08:16:23Z")

</div>

@mattkime

My apology for late reply and sorry for the confusion.

I have _artificially_ connected the dots using powerpoint in the screenshot.  
Usually, for sparse data , data points **are not connected**.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/b/2b858c420ead0ba0ff48574f6a40fb59f32c5c6f.png)

To avoid this , you will need to create `date histogram aggregation` which the buckets next to each other has valid values.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/8/a8df003a8e2b6924440176d6599f6885dfe61dd4.png)

In my case like person who is already aware of the buckets that data does not exist, **filtering out the unnecesssary buckets and just connect the lines** using `min_doc_count` would be fantastic.

Thanks,  
Yu Watanabe

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [September 3, 2019, 5:33pm UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/6 "2019-09-03T17:33:34Z")

</div>

I think the best route is to figure out why those 'empty' buckets are appearing. Can you share a screenshot of the config for Average/max/min/std deviation? It would also be helpful to see your field mapping.

---

<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: [October 1, 2019, 5:33pm UTC](https://discuss.elastic.co/t/how-do-you-draw-fit-line-in-time-series-builder-in-kibana-7-1-1/196895/7 "2019-10-01T17:33:34Z")

</div>

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