Hello everyone,
I found a great example of what I need but it’s not working as expected. I need to show values from all traces by using hovermode:‘compare’. But that breaks horizontal zooming using scaleanchor. I finally got horizontal zooming working with etienne help. But now combining hovermode:‘compare’ and scaleanchor:‘y’ do not seem to work together. Is that combination not allowed? Is there a fix? Thanks
var names = ['A', 'B', 'C']
var trace1 = {
x: [4, 5, 6],
y: [1, 2, 3],
text: names,
hoverinfo: 'x+y+text',
xaxis: 'x',
yaxis: 'y',
mode: 'markers',
type: 'scatter'
};
var trace2 = {
x: [50, 60, 70],
y: [1, 2, 3],
text: names,
hoverinfo: 'x+y+text',
xaxis: 'x2',
yaxis: 'y2',
mode: 'markers',
type: 'scatter'
};
var data = [trace1, trace2];
var layout = {
hovermode: 'compare',
xaxis: {anchor: 'y'},
yaxis: {domain: [0, 0.45], scaleanchor: 'y'},
xaxis2: {anchor: 'y2'},
yaxis2: {domain: [0.55, 1], scaleanchor: 'y'}
};
Plotly.newPlot('graph', data, layout);
var myPlot = document.getElementById('graph');
myPlot.on('plotly_hover', function (eventdata) {
console.log(eventdata.xvals);
Plotly.Fx.hover('graph',
[
{curveNumber: 0, pointNumber: eventdata.points[0].pointNumber},
{curveNumber: 1, pointNumber: eventdata.points[0].pointNumber},
],
['xy', 'x2y2']
);
});