Skip to content

Commit 7246537

Browse files
authored
Merge pull request #4519 from plotly/pie-add-textpad
Improve pie and sunburst inside text pad
2 parents 80262b5 + 056eed3 commit 7246537

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+210
-12
lines changed

src/traces/pie/plot.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var svgTextUtils = require('../../lib/svg_text_utils');
1919
var uniformText = require('../bar/uniform_text');
2020
var recordMinTextSize = uniformText.recordMinTextSize;
2121
var clearMinTextSize = uniformText.clearMinTextSize;
22+
var TEXTPAD = require('../bar/constants').TEXTPAD;
2223

2324
var helpers = require('./helpers');
2425
var eventData = require('./event_data');
@@ -684,6 +685,8 @@ function isCrossing(pt, angle) {
684685
}
685686

686687
function calcRadTransform(textBB, r, ring, halfAngle, midAngle) {
688+
r = Math.max(0, r - 2 * TEXTPAD);
689+
687690
// max size if text is rotated radially
688691
var a = textBB.width / textBB.height;
689692
var s = calcMaxHalfSize(a, halfAngle, r, ring);
@@ -695,6 +698,8 @@ function calcRadTransform(textBB, r, ring, halfAngle, midAngle) {
695698
}
696699

697700
function calcTanTransform(textBB, r, ring, halfAngle, midAngle) {
701+
r = Math.max(0, r - 2 * TEXTPAD);
702+
698703
// max size if text is rotated tangentially
699704
var a = textBB.height / textBB.width;
700705
var s = calcMaxHalfSize(a, halfAngle, r, ring);
@@ -1148,11 +1153,7 @@ function computeTransform(
11481153
transform, // inout
11491154
textBB // in
11501155
) {
1151-
var rotate = transform.rotate;
1152-
var scale = transform.scale;
1153-
if(scale > 1) scale = 1;
1154-
1155-
var a = rotate * Math.PI / 180;
1156+
var a = transform.rotate * Math.PI / 180;
11561157
var cosA = Math.cos(a);
11571158
var sinA = Math.sin(a);
11581159
var midX = (textBB.left + textBB.right) / 2;
-88 Bytes
76 Bytes

test/image/baselines/mathjax.png

-9 Bytes
-4 Bytes

test/image/baselines/pie_fonts.png

-238 Bytes
-879 Bytes

0 commit comments

Comments
 (0)