# How to store bar chart data?

**URL:** <https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160>\
**Category:** Elasticsearch\
**Created:** [June 15, 2020, 3:35pm UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160 "2020-06-15T15:35:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [June 15, 2020, 3:35pm UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/1 "2020-06-15T15:35:31Z")

</div>

Hello,  
we are in the middle of restructuring one of our products to use ES instead of MySQL as its data storage. Now we are not sure what would be the best way to model the following data:  
Each element has a bar chart that visualizes a value in 10 second steps\*, e.g.:

```
0: -1.6783
10: 20.034
20: 15.2223
30: 10.139

```

Should we

1. save that as an **object** and use the times "0", "10", "20", "30" as the field names within this object, so we'd have "hist.0", "hist.10", "hist.20", "hist.30"?
2. save the values as an array of **nested** objects like `[{ "bucket":0, "value":-1.6783}, …]`
3. save the array as **flattened** json
4. save the key value pairs as a linestring **shape**?
5. do something different that you can recommend that we haven't thought of yet?

Thank you in advance!

* * *

(\*we can't eliminate the possibility that the interval might change in the future.)

* * *

**PS** : I'm under the impression that option 2 might give us the most flexibility for queries or aggregations if we ever need them?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2020, 10:37pm UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/2 "2020-06-15T22:37:28Z")

</div>

Can you attach the full timestamp, instead of an N second increment?

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [June 16, 2020, 8:20am UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/3 "2020-06-16T08:20:27Z")

</div>

I think that might make the processing of the data in our software more difficult as we need to work with the times relative to the element start. What would we gain from that?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 16, 2020, 8:26am UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/4 "2020-06-16T08:26:35Z")

</div>

Let me step back - what sort of data is this? What sort of questions does it help answer/what value does it provide?

I can ask a bunch of questions about different options, but understanding what the higher level value is might make things clearer 🙂

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [June 16, 2020, 9:45am UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/5 "2020-06-16T09:45:24Z")

</div>

We've got measurements for the user reactions over the course of a playout of an audio element. These have been calculated in Python and shall be saved to decrease the loading times of the user interface. Later multiple playouts are aggregated to show the average user acceptance over the last X days on a dashboard.

Thank you for investing some of your time to help us!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 17, 2020, 7:02am UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/6 "2020-06-17T07:02:19Z")

</div>

Ahh ok, now the time offset makes more sense to me 🙂

The second option seems the best, but maybe also include a `"offset_value": 10` as well, so that if you do change that offset, it'll be more obvious?

---

<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 15, 2020, 7:02am UTC](https://discuss.elastic.co/t/how-to-store-bar-chart-data/237160/7 "2020-07-15T07:02:22Z")

</div>

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