# How set Plotly values using msg.payload

**URL:** <https://discourse.nodered.org/t/how-set-plotly-values-using-msg-payload/63259>\
**Category:** Dashboard\
**Created:** [30 May 2022 14:23 UTC](https://discourse.nodered.org/t/how-set-plotly-values-using-msg-payload/63259 "2022-05-30T14:23:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicoloToscani](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@NicoloToscani](https://discourse.nodered.org/u/NicoloToscani)\
**Post date:** [30 May 2022 14:23 UTC](https://discourse.nodered.org/t/how-set-plotly-values-using-msg-payload/63259/1 "2022-05-30T14:23:55Z")

</div>

Hi,  
I need to set values of a chart using msg.payload in `ui_template` node.

For example, I need to set `link:value` using `msg.payload.some_values`

```auto
link: {
    source: [0,2,1,1],
    target: [1,3,2,1],
    value: [5,4,10,8]
  }

```

My code:

```auto
<style>
#plot{
    display: flex;
    justify-content: center;
}
</style>

<div id="plot"></div>

<script>
setTimeout(function(){ 
    d3.json('https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy_dark.json', function(fig){

    var data = {
        
  type: "sankey",
  orientation: "h",
  node: {
    pad: 15,
    thickness: 30,
    line: {
      color: "black",
      width: 0.5
    },
   label: ["A", "B", "C", "D"],
   color: ["blue", "blue", "blue", "blue"]
      },

  link: {
    source: [0,2,1,1,3],
    target: [1,3,2,1],
    value: [5,4,10,8]
  }
}

var data = [data]

var layout = {
  title: "",
  font: {
    size: 10
  }
}

Plotly.newPlot('plot', data, layout)
    });
}, 300);
    
</script>

```

Nicolò

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 June 2022 14:24 UTC](https://discourse.nodered.org/t/how-set-plotly-values-using-msg-payload/63259/2 "2022-06-29T14:24:26Z")

</div>

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