Plotlyjs反应图像

时间:2017-03-01 23:39:34

标签: javascript html plotly

对于下面的代码,我想将图像保留在Plotly.toImage中,但只更改布局坐标。它将在中间有一个白色方块,它根据事件数据或换句话说改变

  layout.shapes[0].x0 = eventdata["xaxis.range[0]"];

这似乎不起作用。有什么帮助吗?

var img_jpg = d3.select('#jpg-export');

var img_png = d3.select('#png-export');
var svg  = d3.select('#svg-export');
var redi = Plotly.newPlot('myDiv', data, layout);
redi.then( function(gd) {
    Plotly.toImage(gd,{height:700,width:700})
    .then( function(url) {
        img_jpg.attr("src", url);
        Plotly.toImage(gd,{format:'jpeg',height:700,width:700});
    })
});

myDiv.on('plotly_relayout', function(eventdata){  
    console.log( eventdata["xaxis.range[0]"]);
    console.log(layout.shapes[0]);
     // layout.shapes[0].x0=eventdata["xaxis.range[0]"];
     // layout.shapes[0].x1=eventdata["xaxis.range[1]"];

Plotly.toImage(redi,{height:700,width:700})
.then( function(url) {
     img_jpg.attr("src", url);
     Plotly.toImage(redi,{format:'jpeg',height:700 ,width:700});
});
console.log("changes!");

0 个答案:

没有答案