Skip to content

Commit 5171a8d

Browse files
committed
decent offsetting of point labels
1 parent 6337ca2 commit 5171a8d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/traces/streamtubes/convert.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ proto.handlePick = function(selection) {
5959
}
6060
};
6161

62-
function calculateTextOffset(tp) {
62+
function calculateTextOffset(tp, offsetValue) {
6363
//Read out text properties
6464
var textOffset = [0, 0];
6565
if(Array.isArray(tp)) return [0, -1];
66-
if(tp.indexOf('bottom') >= 0) textOffset[1] += 1;
67-
if(tp.indexOf('top') >= 0) textOffset[1] -= 1;
68-
if(tp.indexOf('left') >= 0) textOffset[0] -= 1;
69-
if(tp.indexOf('right') >= 0) textOffset[0] += 1;
66+
if(tp.indexOf('bottom') >= 0) textOffset[1] += offsetValue;
67+
if(tp.indexOf('top') >= 0) textOffset[1] -= offsetValue;
68+
if(tp.indexOf('left') >= 0) textOffset[0] -= offsetValue;
69+
if(tp.indexOf('right') >= 0) textOffset[0] += offsetValue;
7070
return textOffset;
7171
}
7272

@@ -149,7 +149,7 @@ function convertPlotlyOptions(scene, data) {
149149
}
150150

151151
if('textposition' in data) {
152-
params.textOffset = calculateTextOffset(data.textposition); // arrayOk === false
152+
params.textOffset = calculateTextOffset(data.textposition, 1.5 * Math.pow(scene.dataScale[0] * scene.dataScale[1] * scene.dataScale[2], 1/2) * Math.max.apply(Math, data.marker.size)); // arrayOk === false
153153
params.textColor = formatColor(data.textfont, 1, len);
154154
params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12);
155155
params.textFont = data.textfont.family; // arrayOk === false

0 commit comments

Comments
 (0)