How set Plotly values using msg.payload

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

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

My code:

<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ò

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