Skip to content

Commit 6d50386

Browse files
committed
revisit transform inside bar to reduce diff after textangle - revert bar_attrs_relative to original
1 parent fd1f6ca commit 6d50386

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Diff for: src/traces/bar/plot.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,18 @@ function getTransformToMoveInsideBar(x0, x1, y0, y1, textBB, isHorizontal, const
356356
var lx = Math.abs(x1 - x0);
357357
var ly = Math.abs(y1 - y0);
358358

359-
var rotation = getRotationFromAngle(angle);
359+
var textpad = (
360+
lx > (2 * TEXTPAD) &&
361+
ly > (2 * TEXTPAD)
362+
) ? TEXTPAD : 0;
363+
364+
lx -= 2 * textpad;
365+
ly -= 2 * textpad;
360366

361367
var autoRotate = (angle === 'auto');
362368
var isAutoRotated = false;
363369
if(autoRotate &&
370+
!(textWidth <= lx && textHeight <= ly) &&
364371
(textWidth > lx || textHeight > ly) && (
365372
!(textWidth > ly || textHeight > lx) ||
366373
((textWidth < textHeight) !== (lx < ly))
@@ -375,21 +382,14 @@ function getTransformToMoveInsideBar(x0, x1, y0, y1, textBB, isHorizontal, const
375382
lx = tmp;
376383
}
377384

385+
var rotation = getRotationFromAngle(angle);
378386
var absSin = Math.abs(Math.sin(Math.PI / 180 * rotation));
379387
var absCos = Math.abs(Math.cos(Math.PI / 180 * rotation));
380388

381389
// compute and apply text padding
382390
var dx = Math.max(lx * absCos, ly * absSin);
383391
var dy = Math.max(lx * absSin, ly * absCos);
384392

385-
var textpad = (
386-
dx > (2 * TEXTPAD) &&
387-
dy > (2 * TEXTPAD)
388-
) ? TEXTPAD : 0;
389-
390-
dx -= 2 * textpad;
391-
dy -= 2 * textpad;
392-
393393
var scale = (constrained) ?
394394
Math.min(dx / textWidth, dy / textHeight) :
395395
Math.max(absCos, absSin);

Diff for: test/image/baselines/bar_attrs_relative.png

24 Bytes
Loading

Diff for: test/image/baselines/funnel_axis_textangle.png

643 Bytes
Loading
759 Bytes
Loading

0 commit comments

Comments
 (0)