8000 unified hover: simplify legend.draw signature · pfacto/plotly.js@a87107b · GitHub
[go: up one dir, main page]

Skip to content

Commit a87107b

Browse files
committed
unified hover: simplify legend.draw signature
1 parent 35848da commit a87107b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/components/fx/hover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,10 @@ function createHoverText(hoverData, opts, gd) {
950950
hoverData[j].name = name;
951951
legendOpts.entries.push([hoverData[j]]);
952952
}
953+
legendOpts.layer = container;
953954

954955
// Draw unified hover label
955-
legend.draw(gd, container, legendOpts);
956+
legend.draw(gd, legendOpts);
956957

957958
// Position the hover
958959
var ly = Lib.mean(hoverData.map(function(c) {return (c.y0 + c.y1) / 2;}));

src/components/legend/draw.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,26 @@ var getLegendData = require('./get_legend_data');
3030
var style = require('./style');
3131
var helpers = require('./helpers');
3232

33-
module.exports = function draw(gd, layer, opts) {
33+
module.exports = function draw(gd, opts) {
3434
var fullLayout = gd._fullLayout;
3535
var clipId = 'legend' + fullLayout._uid;
36+
var layer;
3637

3738
// Check whether this is the main legend (ie. called without any opts)
3839
var main;
3940
if(!opts) {
4041
main = true;
4142
opts = fullLayout.legend;
43+
layer = fullLayout._infolayer;
4244
} else {
45+
layer = opts.layer;
4346
clipId += '-hover';
4447
}
4548

46-
if(!layer) layer = fullLayout._infolayer;
4749
if(!layer) return;
4850

4951
if(!gd._legendMouseDownTime) gd._legendMouseDownTime = 0;
5052

51-
5253
var legendData;
5354
if(main) {
5455
if(!gd.calcdata) return;

0 commit comments

Comments
 (0)
0