# Change value of a datum field using signal

**URL:** https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158
**Category:** Kibana
**Tags:** vega
**Created:** [May 17, 2021, 10:15am UTC](https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158 "2021-05-17T10:15:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dzious](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@Dzious](https://discuss.elastic.co/u/Dzious)
#### Post date: [May 17, 2021, 10:15am UTC](https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158/1 "2021-05-17T10:15:24Z")

</div>

Hi,  
I'm trying to have data that are relative to each one of my data. I've tried to use signal's data but i didn't managed to make them relative to one and only one value of my data.

i decided to add a field in my data values. now i'm trying to change the value of this field but i can't find a way to do so.

I've tried :

```auto
"signals": [
    {
      "name": "color_changer",
      "value": "",
      "on": [
        {
          "events": "rect:click",
          "update": "datum.color === 'red' ? datum.color ='white' : datum.color ='red'"
        }
      ]
    }
  ],

```

But this does not work and result in a parsing error.

if anyone has an idea, some help would be appreciate. Thanks by advance.

---

<div class="post-metadata">

### Author: ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)
#### Post date: [May 25, 2021, 8:00pm UTC](https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158/2 "2021-05-25T20:00:13Z")

</div>

@Dzious Thanks for the question!  
I'm not familiar with Vega but I think going through the Vega docs for [`signals`](https://vega.github.io/vega/docs/signals/) and [`expressions`](https://vega.github.io/vega/docs/expressions/) might help you out here.  
I've used the examples from those docs in the past and they work great!

---

<div class="post-metadata">

### Author: ![Dzious](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@Dzious](https://discuss.elastic.co/u/Dzious)
#### Post date: [May 26, 2021, 6:03am UTC](https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158/3 "2021-05-26T06:03:51Z")

</div>

Hi @cheiligers,  
Thanks for your help.  
Unfortunately, due to technical limitations i've had to gave up the visualisation i was trying to build.  
Since this vega was designed for a real time data visualisation, this means it would be needed to refresh it every X seconds making it impossible to save the state of each component between two refreshes  
Still that's good to know and i'll have a look at it later on  
Once again thanks and have a great day

---

<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 23, 2021, 6:04am UTC](https://discuss.elastic.co/t/change-value-of-a-datum-field-using-signal/273158/4 "2021-06-23T06:04:10Z")

</div>

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