# Put names to the values of a field

**URL:** <https://discuss.elastic.co/t/put-names-to-the-values-of-a-field/179600>\
**Category:** Kibana\
**Created:** [May 4, 2019, 12:58am UTC](https://discuss.elastic.co/t/put-names-to-the-values-of-a-field/179600 "2019-05-04T00:58:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Woolis\_Xiibil\_Peek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/woolis_xiibil_peek/32/42830_2.png) [@Woolis\_Xiibil\_Peek](https://discuss.elastic.co/u/Woolis_Xiibil_Peek)\
**Post date:** [May 4, 2019, 12:58am UTC](https://discuss.elastic.co/t/put-names-to-the-values-of-a-field/179600/1 "2019-05-04T00:58:26Z")

</div>

Hi.

I did a pie chart with a field that have a numeric value that represent the code of a operation.

This field is called oper. So in this field I can count how many kinds of operations occurs in 1 day. So in the pie chart I can see, for example, that there was 5 operations with the code 2 and 10 operations with the code 7, etc.

So, until this point everything is fine.

But I need to put the name of the code operation in the legend of the chart. I mean the code 2 operations are yellow operations, and the code 7 are de blue operations. So in the legend of the pie chart I need to display this yellow instead of 2 and blue instead fo 7 and so on for all de codes operations.

Something like tihs.

```
                                                                                   "legend"
                                                                                   2 - yellow

```

this is 5 - red  
my 4 - black  
pie chart 7 - blue

I have the list of the codes in a Excel file. The names doesn't come in the info that are being inserted on Elasticsearch.

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 9, 2019, 3:55am UTC](https://discuss.elastic.co/t/put-names-to-the-values-of-a-field/179600/2 "2019-05-09T03:55:06Z")

</div>

I would use a scripted field for that.

To get started, see

- [https://www.elastic.co/blog/using-painless-kibana-scripted-fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields)
- [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

Write a script that maps each code to a readable name (2-\>yellow, 7-\>blue, ...)

Then, make your pie-chart using the scripted field instead.

---

<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 6, 2019, 3:55am UTC](https://discuss.elastic.co/t/put-names-to-the-values-of-a-field/179600/3 "2019-06-06T03:55:08Z")

</div>

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