Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/traces/pie/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var svgTextUtils = require('../../lib/svg_text_utils');
var uniformText = require('../bar/uniform_text');
var recordMinTextSize = uniformText.recordMinTextSize;
var clearMinTextSize = uniformText.clearMinTextSize;
var TEXTPAD = require('../bar/constants').TEXTPAD;

var helpers = require('./helpers');
var eventData = require('./event_data');
Expand Down Expand Up @@ -669,6 +670,8 @@ function isCrossing(pt, angle) {
}

function calcRadTransform(textBB, r, ring, halfAngle, midAngle) {
r = Math.max(0, r - 2 * TEXTPAD);

// max size if text is rotated radially
var a = textBB.width / textBB.height;
var s = calcMaxHalfSize(a, halfAngle, r, ring);
Expand All @@ -680,6 +683,8 @@ function calcRadTransform(textBB, r, ring, halfAngle, midAngle) {
}

function calcTanTransform(textBB, r, ring, halfAngle, midAngle) {
r = Math.max(0, r - 2 * TEXTPAD);

// max size if text is rotated tangentially
var a = textBB.height / textBB.width;
var s = calcMaxHalfSize(a, halfAngle, r, ring);
Expand Down Expand Up @@ -1133,11 +1138,7 @@ function computeTransform(
transform, // inout
textBB // in
) {
var rotate = transform.rotate;
var scale = transform.scale;
if(scale > 1) scale = 1;

var a = rotate * Math.PI / 180;
var a = transform.rotate * Math.PI / 180;
var cosA = Math.cos(a);
var sinA = Math.sin(a);
var midX = (textBB.left + textBB.right) / 2;
Expand Down
Binary file modified test/image/baselines/display-text_zero-number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/funnelarea_pie_colorways.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/funnelarea_with_other_traces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/legend-constant-itemsizing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mathjax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pie_automargin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pie_fonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pie_inside-text-orientation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pie_scale_textpos_hideslices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pie_style_arrays.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/pie_textpad_radial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/pie_textpad_tangential.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_count_branches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_flare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_inside-text-orientation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_inside-text-orientation_clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_packages_colorscale_novalue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_textfit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/sunburst_textpad_radial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_values_colorscale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/sunburst_with-without_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/texttemplate.png
Binary file modified test/image/baselines/treemap_level-depth.png
Binary file modified test/image/baselines/treemap_sunburst_marker_colors.png
Binary file modified test/image/baselines/uniformtext_pie_16_auto.png
Binary file modified test/image/baselines/uniformtext_pie_8_horizontal.png
Binary file modified test/image/baselines/uniformtext_pie_8_horizontal_center.png
Binary file modified test/image/baselines/uniformtext_pie_8_radial.png
Binary file modified test/image/baselines/uniformtext_pie_8_tangential.png
Binary file modified test/image/baselines/uniformtext_pie_inside-text-orientation.png
1 change: 1 addition & 0 deletions test/image/mocks/pie_fonts.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"inherit from<br><b>global...</b>",
"font"
],
"textposition": ["outside", "inside"],
"type": "pie",
"domain": {
"x": [0, 0.4],
Expand Down
46 changes: 46 additions & 0 deletions test/image/mocks/pie_textpad_radial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"data": [
{
"type": "pie",
"hole": 0.5,
"labels": [
"a",
"b",
"c",
"d"
],
"values": [
20,
10,
2,
1
],
"textposition": "inside",
"insidetextorientation": "radial",
"marker": {
"colors": [
"pink",
"lightgreen",
"skyblue",
"orange"
],
"line": {
"width": 3,
"color": [
"red",
"green",
"blue",
"grey"
]
}
}
}
],
"layout": {
"width": 300,
"height": 300,
"title": {
"text": "should provide some pad<br>before fiting & printing text"
}
}
}
46 changes: 46 additions & 0 deletions test/image/mocks/pie_textpad_tangential.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"data": [
{
"type": "pie",
"hole": 0.5,
"labels": [
"a",
"b",
"c",
"d"
],
"values": [
20,
10,
2,
1
],
"textposition": "inside",
"insidetextorientation": "tangential",
"marker": {
"colors": [
"pink",
"lightgreen",
"skyblue",
"orange"
],
"line": {
"width": 3,
"color": [
"red",
"green",
"blue",
"grey"
]
}
}
}
],
"layout": {
"width": 300,
"height": 300,
"title": {
"text": "should provide some pad<br>before fiting & printing text"
}
}
}
52 changes: 52 additions & 0 deletions test/image/mocks/sunburst_textpad_radial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"data": [
{
"type": "sunburst",
"parents": [
"",
"",
"",
"",
"Alpha",
"Bravo",
"Charlie",
"Delta"
],
"labels": [
"Alpha",
"Bravo",
"Charlie",
"Delta",
"Echo",
"Foxtrot",
"Golf",
"Hotel"
],
"branchvalues": "total",
"values": [
20,
10,
2,
1,
20,
10,
2,
1
],
"textposition": "inside",
"insidetextorientation": "radial",
"marker": {
"line": {
"width": 3
}
}
}
],
"layout": {
"width": 300,
"height": 300,
"title": {
"text": "should provide some pad<br>before fiting & printing text"
}
}
}
52 changes: 52 additions & 0 deletions test/image/mocks/sunburst_textpad_tangential.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"data": [
{
"type": "sunburst",
"parents": [
"",
"",
"",
"",
"Alpha",
"Bravo",
"Charlie",
"Delta"
],
"labels": [
"Alpha",
"Bravo",
"Charlie",
"Delta",
"Echo",
"Foxtrot",
"Golf",
"Hotel"
],
"branchvalues": "total",
"values": [
20,
10,
2,
1,
20,
10,
2,
1
],
"textposition": "inside",
"insidetextorientation": "tangential",
"marker": {
"line": {
"width": 3
}
}
}
],
"layout": {
"width": 300,
"height": 300,
"title": {
"text": "should provide some pad<br>before fiting & printing text"
}
}
}
6 changes: 3 additions & 3 deletions test/jasmine/tests/pie_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2010,15 +2010,15 @@ describe('pie uniformtext', function() {
Plotly.plot(gd, fig)
.then(assertTextSizes('without uniformtext', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
scales: [1, 1, 1, 1, 1, 1, 1, 0.58],
scales: [1, 1, 1, 1, 1, 1, 1, 0.52],
}))
.then(function() {
fig.layout.uniformtext = {mode: 'hide'}; // default with minsize=0
return Plotly.react(gd, fig);
})
.then(assertTextSizes('using mode: "hide"', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
scales: [0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58],
scales: [0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52],
}))
.then(function() {
fig.layout.uniformtext.minsize = 9; // set a minsize less than trace font size
Expand Down Expand Up @@ -2058,7 +2058,7 @@ describe('pie uniformtext', function() {
})
.then(assertTextSizes('clear uniformtext', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
scales: [1, 1, 1, 1, 1, 1, 1, 0.58],
scales: [1, 1, 1, 1, 1, 1, 1, 0.52],
}))
.catch(failTest)
.then(done);
Expand Down
8 changes: 4 additions & 4 deletions test/jasmine/tests/sunburst_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ describe('sunburst inside text orientation', function() {
return Plotly.react(gd, fig);
})
.then(assertTextRotations('using "tangential"', {
rotations: [0, 0, -42, -78]
rotations: [0, 30, -42, -78]
}))
.then(function() {
fig.data[0].insidetextorientation = 'auto';
Expand Down Expand Up @@ -2060,15 +2060,15 @@ describe('sunburst uniformtext', function() {
Plotly.plot(gd, fig)
.then(assertTextSizes('without uniformtext', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12, 12, 12],
scales: [1, 1, 1, 1, 1, 1, 1, 1, 1, 0.58],
scales: [1, 1, 1, 1, 1, 1, 1, 1, 1, 0.52],
}))
.then(function() {
fig.layout.uniformtext = {mode: 'hide'}; // default with minsize=0
return Plotly.react(gd, fig);
})
.then(assertTextSizes('using mode: "hide"', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12, 12, 12],
scales: [0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58],
scales: [0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52, 0.52],
}))
.then(function() {
fig.layout.uniformtext.minsize = 9; // set a minsize less than trace font size
Expand Down Expand Up @@ -2108,7 +2108,7 @@ describe('sunburst uniformtext', function() {
})
.then(assertTextSizes('clear uniformtext', {
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12, 12, 12],
scales: [1, 1, 1, 1, 1, 1, 1, 1, 1, 0.58],
scales: [1, 1, 1, 1, 1, 1, 1, 1, 1, 0.52],
}))
.catch(failTest)
.then(done);
Expand Down