# Interpolation on line graphs

**URL:** <https://discuss.elastic.co/t/interpolation-on-line-graphs/46521>\
**Category:** Kibana\
**Created:** [April 6, 2016, 12:15pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521 "2016-04-06T12:15:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![astickler](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@astickler](https://discuss.elastic.co/u/astickler)\
**Post date:** [April 6, 2016, 12:15pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/1 "2016-04-06T12:15:18Z")

</div>

Very new to Kibana, so please be patient.

I have time-series data (temperatures) in elasticsearch, which is sparse (e.g. might get 5-20 differetn values in a hour period). If I plot on a Timelion chart (using the elasticsearch 'max' function) and use the 1-hour buckets, the aggregated values are joined by lines, but if I drop to the 1-minute buckets, I just see either dots or very short lines, with no interpolation between the aggregated values. Is there any option to 'join the dots'?

I have uploaded pictures of the hourly an dminute views, and also the cardinality.  
Thanks - Andrew.

![](https://us1.discourse-cdn.com/elastic/original/2X/5/5ce24413585d089c4f55efdf8a0410c543a1e559.PNG)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/f5a51c335b0718a4f40d64022f38b97be3456afb.PNG)

 ![](https://us1.discourse-cdn.com/elastic/original/2X/e/e353e3d27ca189a1f80a2a30adf6bd9449fcd2b6.PNG)

---

<div class="post-metadata">

**Author:** ![rashid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid/32/12566_2.png) [@rashid](https://discuss.elastic.co/u/rashid)\
**Post date:** [April 6, 2016, 7:30pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/2 "2016-04-06T19:30:27Z")

</div>

Heya, while looking at this I found a bug in one of our fit functions. You should be able to pass `fit=average` to `.es()` to work around this, but it turned out there was a bug in the average fit function.

So I fixed that 🙂 I also added a `.fit()` function. So you can now add `.fit(average)` on to the end of your expression. There's a couple other fit functions. Here's all of them, you want average:

**You'll need to remove and reinstall Timelion to get the new function**. You won't lose any data.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/24354feabad045bc4e6d79e6ad11e0807220afe5.png)

---

<div class="post-metadata">

**Author:** ![astickler](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@astickler](https://discuss.elastic.co/u/astickler)\
**Post date:** [April 7, 2016, 10:13am UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/3 "2016-04-07T10:13:12Z")

</div>

Hi Rashid - that sounds like a good solution. I am actually using the Timelion built into the elastic cloud (trial version) , but that doesn't appear to support 'fit' yet. When might that change?

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![rashid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid/32/12566_2.png) [@rashid](https://discuss.elastic.co/u/rashid)\
**Post date:** [April 7, 2016, 2:38pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/4 "2016-04-07T14:38:26Z")

</div>

If I had to guess, at least a few weeks.

As a work around you can pass `fit=nearest` to `.es()`, eg `.es(index="my*", fit=nearest)` which will give you a stepped line

---

<div class="post-metadata">

**Author:** ![astickler](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@astickler](https://discuss.elastic.co/u/astickler)\
**Post date:** [April 7, 2016, 4:59pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/5 "2016-04-07T16:59:41Z")

</div>

I must be doing something wrong - here are two 1-minute charts, 1 using points() and the other using lines() with your 'fit=nearest' attribute in .es(). I still don't get the stepped line.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/6/65b5e34a2f1125803bee648a82a1bc48348f9a8a.PNG) ![](https://us1.discourse-cdn.com/elastic/original/2X/1/1f5253e224650738c0489c6cb11b26887b20ecbe.PNG)

---

<div class="post-metadata">

**Author:** ![rashid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid/32/12566_2.png) [@rashid](https://discuss.elastic.co/u/rashid)\
**Post date:** [April 7, 2016, 5:14pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/6 "2016-04-07T17:14:33Z")

</div>

Arrg, sorry, I was wrong there. Because elasticsearch is returning a bucket, but a null value, the fit algorithm isn't going to do anything. It only works in the instance that elasticsearch returns on bucket at that time. You really do need the `.fit()` function ☹

---

<div class="post-metadata">

**Author:** ![rashid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid/32/12566_2.png) [@rashid](https://discuss.elastic.co/u/rashid)\
**Post date:** [April 7, 2016, 5:17pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/7 "2016-04-07T17:17:24Z")

</div>

I know this isn't what you want, but if you want it to pull down to 0, instead of being null you can do something like

`.es(metric="max:indoorTemp").if(eq, null, 0)`

Which says, if the value at the point equals (eq) null, then set it to 0.

---

<div class="post-metadata">

**Author:** ![astickler](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@astickler](https://discuss.elastic.co/u/astickler)\
**Post date:** [April 8, 2016, 4:35pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/8 "2016-04-08T16:35:20Z")

</div>

That's good enough for now. See screenshots for 1 hour and 1 min with pullown, and 1-min without pulldown. I assume I can't do a pulldown to the previous value?  
Many thanks.  
Andrew

![](https://us1.discourse-cdn.com/elastic/original/2X/d/def73092eabfd404b522ee9c771a2c8b8695ddf6.PNG)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/b/bf168137c05e95b9a6816bfe3f33350ba86c2dec.PNG)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/7/77dd013bc42405ec908903ad56fd3214d2bfce4a.PNG)

---

<div class="post-metadata">

**Author:** ![rashid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid/32/12566_2.png) [@rashid](https://discuss.elastic.co/u/rashid)\
**Post date:** [April 8, 2016, 5:01pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/9 "2016-04-08T17:01:58Z")

</div>

Yeah unfortunately you can't pull to the previous value, thats roughly what `.fit(nearest)` will do when its available in elastic cloud

---

<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:** [July 6, 2017, 1:56pm UTC](https://discuss.elastic.co/t/interpolation-on-line-graphs/46521/10 "2017-07-06T13:56:31Z")

</div>


