Plotly Grouped条形图:单个元素的悬停信息
Plotly Grouped bar chart: hover info of single element
I have copied the grouped bar chart from https://plotly.com/javascript/bar-charts/
var trace1 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
name: 'SF Zoo',
type: 'bar'
};
var trace2 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [12, 18, 29],
name: 'LA Zoo',
type: 'bar'
};
var data = [trace1, trace2];
var layout = {barmode: 'group'};
Plotly.newPlot('myDiv', data, layout);
当我将鼠标悬停在一个元素上时,会显示两个元素的悬停信息。如何只显示悬停元素的信息?
解决方案是添加 hovermode closest {barmode: 'group', hovermode: 'closest'}。
var trace1 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
name: 'SF Zoo',
type: 'bar'
};
var trace2 = {
x: ['giraffes', 'orangutans', 'monkeys'],
y: [12, 18, 29],
name: 'LA Zoo',
type: 'bar'
};
var data = [trace1, trace2];
var layout = {barmode: 'group'};
Plotly.newPlot('myDiv', data, layout);
当我将鼠标悬停在一个元素上时,会显示两个元素的悬停信息。如何只显示悬停元素的信息?
解决方案是添加 hovermode closest {barmode: 'group', hovermode: 'closest'}。