Skip to content

Commit b5c85b1

Browse files
committed
make offset a function of font-size
1 parent bf97aa1 commit b5c85b1

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

src/traces/contour/plot.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,15 @@ exports.calcTextOpts = function(level, contourFormat, dummyText, gd) {
438438
var text = contourFormat(level);
439439
dummyText.text(text)
440440
.call(svgTextUtils.convertToTspans, gd);
441-
var bBox = Drawing.bBox(dummyText.node(), true);
441+
442+
var el = dummyText.node();
443+
var bBox = Drawing.bBox(el, true);
442444

443445
return {
444446
text: text,
445447
width: bBox.width,
446448
height: bBox.height,
449+
fontSize: +(el.style['font-size'].replace('px', '')),
447450
level: level,
448451
dy: (bBox.top + bBox.bottom) / 2
449452
};
@@ -543,8 +546,9 @@ function locationCost(loc, textOpts, labelData, bounds) {
543546
}
544547

545548
exports.addLabelData = function(loc, textOpts, labelData, labelClipPathData) {
546-
var w = textOpts.width + 4;
547-
var h = Math.max(0, textOpts.height - 4);
549+
var fontSize = textOpts.fontSize;
550+
var w = textOpts.width + fontSize / 3;
551+
var h = Math.max(0, textOpts.height - fontSize / 3);
548552

549553
var x = loc.x;
550554
var y = loc.y;
12 Bytes
Loading
-41 Bytes
Loading
4 Bytes
Loading
Loading

0 commit comments

Comments
 (0)