🏠 back to Observable

Retrieve value from graph

So, i want to get an array back from clicking on a certain square in a Heatmap…
The issue i have is that i want to retrieve the value in an external cell and not the same graph cell because i want to use it as a global value (or something like that for usage in other cells)!
For that i have tried to create a variable in a separate cell as such:
val = data (where data is my original data so val is like a copy to not affect it)
And in my heatmap cell code i have an onclick as such:
combi.on(‘click’, function (d) {
d3.select(this).select(“rect”).selectAll(function() {
val.value = exp
}) });
In this example i was just trying to change the value to another array that i have (exp) when activating the click function but the ‘val’ didn’t change…
In another way, i have seen something as “mutable” and even when i used it nothing changed.
So, here’s the thing again:

  1. how to change a value from a different cell?
  2. how to retrieve the value from the clicked cell (unlike the simple change of ‘val’ in example)?
    I’m quite sure the function is quite wrong so excuse me for that :smiley:
mutable val = data
f() {
   mutable val = newVal;

A cell can be triggered & read from a mutable just by depending on it as usual.

It worked!
Thank you greatly for this as it helped me solve one of the 2 issues!
Apparently i was using ‘mutable’ in a wrong way but now after seeing your examples it seemed that in the onclick function i changed ‘mutable val.value’ instead of just ‘mutable val’ which was the main issue…
And, i edited to be only as such:
combi.on(‘click’, function (d) {
mutable val = d.values
so that i can solve the other issue of getting the selected data…
Thanks again so much :slight_smile:

1 Like

value like from an <input>?

click_handler = (event) => {
   mutable val = evt.target.value

ah. i already had that issue solved as i mentioned earlier by getting “d.value” on click… but thanks again for the reply!