Hello,
I'm using the plotly to show my trends, but i have a small problem with zoom event, i want to receive a msg in my node red with zoom data, im already receiving this information, but when i recevi the data my chart lose all the data and goes to blank mode.
Examples:
but if I don't use the way to send a message to the node just an alert, it works perfectly
my chart code
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myChart"></div>
<script>
var myChart = document.getElementById('myChart');
(function(scope) {
scope.$watch('msg', function(msg) {
if (msg) {
var data = msg.payload;
var layout = {
// title: "Chart",
// titlefont: {
// size: 22,
// },
autosize: true,
width: 1500,
height: 700,
plot_bgcolor: '#ffffff',
paper_bgcolor: '#ffffff',
'xaxis': {
title: 'date',
rangeslider: {}
},
'yaxis': {
//title: 'Average Temperature °C',
mode: 'lines'
}
};
Plotly.newPlot(myChart, data, layout, {displaylogo: false, scrollZoom: true})
//Plotly.react(myChart, data).then(function(){Plotly.newPlot(myChart, data, layout, {displaylogo: false, scrollZoom: true}); });
myChart.on('plotly_relayout',function(eventdata){
//scope.send({payload: ('ZOOM!' + '\n\n' + 'Event data:' + '\n' + JSON.stringify(eventdata) + '\n\n' + 'x-axis start:' + eventdata['xaxis.range[0]'] + '\n' +'x-axis end:' + eventdata['xaxis.range[1]'])});
scope('ZOOM!' + '\n\n' + 'Event data:' + '\n' + JSON.stringify(eventdata) + '\n\n' + 'x-axis start:' + eventdata['xaxis.range[0]'] + '\n' +'x-axis end:' + eventdata['xaxis.range[1]']);
//alert( 'ZOOM!' + '\n\n' + 'Event data:' + '\n' + JSON.stringify(eventdata) + '\n\n' + 'x-axis start:' + eventdata['xaxis.range[0]'] + '\n' +'x-axis end:' + eventdata['xaxis.range[1]'] );
});
}//close if
});
})(scope);
</script>
</body>
I hope someone can help with this problem
thanks.