Hello @Tolosmoc ,
Welcome to the community!
Yes, you should be able to wrangle this to work.
All charts obviously use the plotly functions, you just need to figure out what events are going to trigger the events. Instead of returning the new layout in the callback, you should be able to return the new figure to the plotly chart.
function (n, f) {
newFig = JSON.parse(JSON.stringify(f))
console.log(f.layout)
dragEls = $('.dragula')
l = $('.editing .draglayer > g')
if (!sp) {
sp = Math.abs(f.layout.yaxis.domain[0] - f.layout.yaxis2.domain[1])
}
if (dragEls[0]) {
newLayout = JSON.parse(JSON.stringify(f.layout))
ht = 0
try {
$('.dragula').each( function () { ht += parseFloat(this.style.height)})
ht += sp*(dragEls.length-1)
} catch {}
for (y=0; y<dragEls.length; y++) {
per = parseFloat(dragEls[y].style.height) / ht
if ($(dragEls[y]).text() == 'xy') {
ref = ''
} else {
ref = $(dragEls[y]).text().split('y')[0].split('x')[1]
}
if (y==0) {
newLayout['yaxis'+ref] = f.layout['yaxis'+ref]
newLayout['yaxis'+ref].domain = [1-per+(sp/2), 1]
oldDom = 1 - per
}
else {
newLayout['yaxis'+ref] = f.layout['yaxis'+ref]
if ((oldDom - per+(sp/2)) < 0) {
newLayout['yaxis'+ref].domain = [0, oldDom]
} else {
newLayout['yaxis'+ref].domain = [oldDom - per+(sp/2), oldDom]
}
oldDom = oldDom - per
}
}
newFig.layout = newLayout
try {
setTimeout(function() {
drake.destroy()}, 500)
} catch {}
$($('.editing').find('div')[0]).empty()
console.log(newLayout)
}
return JSON.parse(JSON.stringify(newFig))
}
This should be where you would make the same changes. The figure in this example is just the combination of layout
, data
and frames
from the Plotly chart.