diff --git a/src/traces/bar/attributes.js b/src/traces/bar/attributes.js index 735421c03f4..1657292ec03 100644 --- a/src/traces/bar/attributes.js +++ b/src/traces/bar/attributes.js @@ -74,7 +74,7 @@ module.exports = { textposition: { valType: 'enumerated', values: ['inside', 'outside', 'auto', 'none'], - dflt: 'none', + dflt: 'auto', arrayOk: true, editType: 'calc', description: [ @@ -86,7 +86,8 @@ module.exports = { 'this one, then the text gets pushed inside.', '*auto* tries to position `text` inside the bar, but if', 'the bar is too small and no bar is stacked on this one', - 'the text is moved outside.' + 'the text is moved outside.', + 'If *none*, no text appears.' ].join(' ') }, diff --git a/src/traces/funnel/attributes.js b/src/traces/funnel/attributes.js index d13c7d502fe..0ba415b83a7 100644 --- a/src/traces/funnel/attributes.js +++ b/src/traces/funnel/attributes.js @@ -54,7 +54,7 @@ module.exports = { }), text: barAttrs.text, - textposition: extendFlat({}, barAttrs.textposition, {dflt: 'auto'}), + textposition: barAttrs.textposition, insidetextanchor: extendFlat({}, barAttrs.insidetextanchor, {dflt: 'middle'}), textangle: extendFlat({}, barAttrs.textangle, {dflt: 0}), textfont: barAttrs.textfont, diff --git a/test/image/baselines/histogram-offsetgroups.png b/test/image/baselines/histogram-offsetgroups.png index e2ecc685531..98ddad4b4e3 100644 Binary files a/test/image/baselines/histogram-offsetgroups.png and b/test/image/baselines/histogram-offsetgroups.png differ diff --git a/test/image/mocks/bar-autotext-log-size-axes.json b/test/image/mocks/bar-autotext-log-size-axes.json index 976c11eeb24..aaf73f2e403 100644 --- a/test/image/mocks/bar-autotext-log-size-axes.json +++ b/test/image/mocks/bar-autotext-log-size-axes.json @@ -3,14 +3,12 @@ "type": "bar", "x": ["giraffes", "orangutans", "monkeys"], "y": [20, 14, 1], - "text": ["giraffes", "orangutans", "monkeys"], - "textposition": "auto" + "text": ["giraffes", "orangutans", "monkeys"] }, { "type": "bar", "x": ["giraffes", "orangutans", "monkeys"], "y": [20, 14, 1], "text": ["giraffes", "orangutans", "monkeys"], - "textposition": "auto", "xaxis": "x2", "yaxis": "y2" }, { @@ -19,7 +17,6 @@ "x": [20, 14, 1], "text": ["giraffes", "orangutans", "monkeys"], "orientation": "h", - "textposition": "auto", "xaxis": "x3", "yaxis": "y3" }, { @@ -28,7 +25,6 @@ "x": [20, 14, 1], "text": ["giraffes", "orangutans", "monkeys"], "orientation": "h", - "textposition": "auto", "xaxis": "x4", "yaxis": "y4" }], diff --git a/test/image/mocks/bar-like_textangle45.json b/test/image/mocks/bar-like_textangle45.json index c9680ff3708..983f43f5d87 100644 --- a/test/image/mocks/bar-like_textangle45.json +++ b/test/image/mocks/bar-like_textangle45.json @@ -12,7 +12,6 @@ "invisible" ], "type": "bar", - "textposition": "auto", "textangle": -45, "xaxis": "x", "yaxis": "y" @@ -29,7 +28,6 @@ "visible" ], "type": "bar", - "textposition": "auto", "textangle": -45, "xaxis": "x", "yaxis": "y" diff --git a/test/image/mocks/bar-like_textangle60.json b/test/image/mocks/bar-like_textangle60.json index f873343b8b2..61daaa2dde4 100644 --- a/test/image/mocks/bar-like_textangle60.json +++ b/test/image/mocks/bar-like_textangle60.json @@ -12,7 +12,6 @@ "invisible" ], "type": "bar", - "textposition": "auto", "textangle": -60, "xaxis": "x", "yaxis": "y" @@ -29,7 +28,6 @@ "visible" ], "type": "bar", - "textposition": "auto", "textangle": -60, "xaxis": "x", "yaxis": "y" diff --git a/test/image/mocks/bar-like_traces_tozero.json b/test/image/mocks/bar-like_traces_tozero.json index 53da2ba1107..00927469281 100644 --- a/test/image/mocks/bar-like_traces_tozero.json +++ b/test/image/mocks/bar-like_traces_tozero.json @@ -20,7 +20,6 @@ "-11", "+1" ], - "textposition": "auto", "insidetextanchor": "middle", "base": 10 }, @@ -43,7 +42,6 @@ "+11", "-1" ], - "textposition": "auto", "insidetextanchor": "middle", "base": -10 }, @@ -66,7 +64,6 @@ "-12", "+1" ], - "textposition": "auto", "insidetextanchor": "middle", "base": 10 }, @@ -90,7 +87,6 @@ "+12", "-1" ], - "textposition": "auto", "insidetextanchor": "middle", "base": -10 } diff --git a/test/image/mocks/bar_display_height_zero.json b/test/image/mocks/bar_display_height_zero.json index 889aac57205..557eb417332 100644 --- a/test/image/mocks/bar_display_height_zero.json +++ b/test/image/mocks/bar_display_height_zero.json @@ -22,7 +22,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -48,7 +47,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -77,7 +75,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -106,7 +103,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", diff --git a/test/image/mocks/bar_display_height_zero_no_line_width.json b/test/image/mocks/bar_display_height_zero_no_line_width.json index 37e0338cdeb..1409dc58669 100644 --- a/test/image/mocks/bar_display_height_zero_no_line_width.json +++ b/test/image/mocks/bar_display_height_zero_no_line_width.json @@ -23,7 +23,6 @@ 0.75, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -55,7 +54,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -82,7 +80,6 @@ 0.75, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -116,7 +113,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -146,7 +142,6 @@ 0.75, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -181,7 +176,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -211,7 +205,6 @@ 0.75, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", @@ -246,7 +239,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", diff --git a/test/image/mocks/bar_display_height_zero_only_line_width.json b/test/image/mocks/bar_display_height_zero_only_line_width.json index b4e8983bd88..d456a8b92f0 100644 --- a/test/image/mocks/bar_display_height_zero_only_line_width.json +++ b/test/image/mocks/bar_display_height_zero_only_line_width.json @@ -28,7 +28,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -60,7 +59,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -92,7 +90,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -126,7 +123,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -161,7 +157,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -196,7 +191,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -231,7 +225,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", @@ -266,7 +259,6 @@ null, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", diff --git a/test/image/mocks/bar_hide_nulls.json b/test/image/mocks/bar_hide_nulls.json index 3f68cf7c615..9e69993fa3c 100644 --- a/test/image/mocks/bar_hide_nulls.json +++ b/test/image/mocks/bar_hide_nulls.json @@ -20,7 +20,6 @@ 0.001, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false }, @@ -44,7 +43,6 @@ 0.001, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x2", @@ -71,7 +69,6 @@ 0.001, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x3", @@ -98,7 +95,6 @@ 0.001, 1 ], - "textposition": "auto", "insidetextanchor": "middle", "cliponaxis": false, "xaxis": "x4", diff --git a/test/image/mocks/display-text_zero-number.json b/test/image/mocks/display-text_zero-number.json index ebd75c52348..93fdbb022c2 100644 --- a/test/image/mocks/display-text_zero-number.json +++ b/test/image/mocks/display-text_zero-number.json @@ -41,7 +41,6 @@ "measure": ["r", "r", "r", "r", "r", "t", "a"], "text": [null, "", "0", 0, 1, true, false], "textinfo": "label+text+final", - "textposition": "auto", "xaxis": "x2", "yaxis": "y2" } diff --git a/test/image/mocks/mathjax.json b/test/image/mocks/mathjax.json index a66e2085369..d1fe901f99b 100644 --- a/test/image/mocks/mathjax.json +++ b/test/image/mocks/mathjax.json @@ -9,7 +9,6 @@ "x": [0, 1], "y": [1.4, 0.1], "text": ["H1.400 \\pm 0.023H", "H0.100 \\pm 0.002H"], - "textposition": "auto", "type": "bar", "name": "$x=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$" }, { diff --git a/test/image/mocks/uniformtext_bar-like_10_auto.json b/test/image/mocks/uniformtext_bar-like_10_auto.json index 0b518a851c5..82d9d11f550 100644 --- a/test/image/mocks/uniformtext_bar-like_10_auto.json +++ b/test/image/mocks/uniformtext_bar-like_10_auto.json @@ -12,7 +12,6 @@ "invisible" ], "type": "bar", - "textposition": "auto", "xaxis": "x", "yaxis": "y" }, @@ -28,7 +27,6 @@ "visible" ], "type": "bar", - "textposition": "auto", "xaxis": "x", "yaxis": "y" }, diff --git a/test/image/mocks/uniformtext_bar-like_8_horizontal.json b/test/image/mocks/uniformtext_bar-like_8_horizontal.json index 890b423cb08..b01f49c5b0f 100644 --- a/test/image/mocks/uniformtext_bar-like_8_horizontal.json +++ b/test/image/mocks/uniformtext_bar-like_8_horizontal.json @@ -13,7 +13,6 @@ ], "type": "bar", "textangle": 0, - "textposition": "auto", "xaxis": "x", "yaxis": "y" }, @@ -30,7 +29,6 @@ ], "type": "bar", "textangle": 0, - "textposition": "auto", "xaxis": "x", "yaxis": "y" }, diff --git a/test/image/mocks/uniformtext_bar-like_8_textangle.json b/test/image/mocks/uniformtext_bar-like_8_textangle.json index cd468ff9824..f09a23ff110 100644 --- a/test/image/mocks/uniformtext_bar-like_8_textangle.json +++ b/test/image/mocks/uniformtext_bar-like_8_textangle.json @@ -12,7 +12,6 @@ "invisible" ], "type": "bar", - "textposition": "auto", "textangle": -90, "xaxis": "x", "yaxis": "y" @@ -29,7 +28,6 @@ "visible" ], "type": "bar", - "textposition": "auto", "textangle": -90, "xaxis": "x", "yaxis": "y" diff --git a/test/image/mocks/uniformtext_bar-like_8_textangle45.json b/test/image/mocks/uniformtext_bar-like_8_textangle45.json index fb7584c5bb4..78ebe02197c 100644 --- a/test/image/mocks/uniformtext_bar-like_8_textangle45.json +++ b/test/image/mocks/uniformtext_bar-like_8_textangle45.json @@ -12,7 +12,6 @@ "invisible" ], "type": "bar", - "textposition": "auto", "textangle": -45, "xaxis": "x", "yaxis": "y" @@ -29,7 +28,6 @@ "visible" ], "type": "bar", - "textposition": "auto", "textangle": -45, "xaxis": "x", "yaxis": "y" diff --git a/test/image/mocks/uniformtext_bar_edgecase1.json b/test/image/mocks/uniformtext_bar_edgecase1.json index 93326891cf9..64bd3511c70 100644 --- a/test/image/mocks/uniformtext_bar_edgecase1.json +++ b/test/image/mocks/uniformtext_bar_edgecase1.json @@ -24,7 +24,6 @@ "d", "50" ], - "textposition": "auto", "textangle": 0 } ], diff --git a/test/image/mocks/uniformtext_bar_edgecase3.json b/test/image/mocks/uniformtext_bar_edgecase3.json index aaef5d09958..79fc3d58976 100644 --- a/test/image/mocks/uniformtext_bar_edgecase3.json +++ b/test/image/mocks/uniformtext_bar_edgecase3.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{y}", - "textposition": "auto", "textangle": 0, "textfont": { "size": 16 diff --git a/test/image/mocks/uniformtext_bar_edgecase4.json b/test/image/mocks/uniformtext_bar_edgecase4.json index 7e40108cc48..36f6704fcea 100644 --- a/test/image/mocks/uniformtext_bar_edgecase4.json +++ b/test/image/mocks/uniformtext_bar_edgecase4.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{y}", - "textposition": "auto", "insidetextanchor": "start", "textangle": 0, "textfont": { diff --git a/test/image/mocks/uniformtext_bar_edgecase5.json b/test/image/mocks/uniformtext_bar_edgecase5.json index 8922ea304f4..54e9c0b7290 100644 --- a/test/image/mocks/uniformtext_bar_edgecase5.json +++ b/test/image/mocks/uniformtext_bar_edgecase5.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{y}", - "textposition": "auto", "insidetextanchor": "start", "textangle": -45, "textfont": { diff --git a/test/image/mocks/uniformtext_bar_edgecase6.json b/test/image/mocks/uniformtext_bar_edgecase6.json index a6fc6d4dc30..b2758a33e16 100644 --- a/test/image/mocks/uniformtext_bar_edgecase6.json +++ b/test/image/mocks/uniformtext_bar_edgecase6.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{y}", - "textposition": "auto", "insidetextanchor": "end", "textangle": -90, "textfont": { diff --git a/test/image/mocks/uniformtext_bar_edgecase7.json b/test/image/mocks/uniformtext_bar_edgecase7.json index 4304b3854dd..0848eb21f97 100644 --- a/test/image/mocks/uniformtext_bar_edgecase7.json +++ b/test/image/mocks/uniformtext_bar_edgecase7.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{x}", - "textposition": "auto", "insidetextanchor": "end", "textangle": 0, "textfont": { diff --git a/test/image/mocks/uniformtext_bar_edgecase8.json b/test/image/mocks/uniformtext_bar_edgecase8.json index 7cab217f5a1..4dc079780ba 100644 --- a/test/image/mocks/uniformtext_bar_edgecase8.json +++ b/test/image/mocks/uniformtext_bar_edgecase8.json @@ -17,7 +17,6 @@ 44999 ], "texttemplate": "%{x}", - "textposition": "auto", "insidetextanchor": "end", "textangle": 15, "textfont": { diff --git a/test/image/mocks/waterfall_attrs.json b/test/image/mocks/waterfall_attrs.json index 956e0e39dbe..0ef5e04efb6 100644 --- a/test/image/mocks/waterfall_attrs.json +++ b/test/image/mocks/waterfall_attrs.json @@ -15,7 +15,6 @@ }, { "width": [0.4, 0.6, 0.8, 1], "text": ["Three", 2, "inside text", 0], - "textposition": "auto", "textfont": { "size": [10]}, "y": [3, -2, 1, -1], "x": [1, 2, 3, 4], @@ -39,7 +38,6 @@ "type": "waterfall" }, { "text": [2, "outside text", -3, -2], - "textposition": "auto", "y": [2, 0.25, -3, -2], "x": [1, 2, 3, 4], "decreasing": { "marker": { "color": "Red" } }, diff --git a/test/image/mocks/waterfall_axis.json b/test/image/mocks/waterfall_axis.json index c070f7fa5b8..15569fba8a8 100644 --- a/test/image/mocks/waterfall_axis.json +++ b/test/image/mocks/waterfall_axis.json @@ -17,7 +17,6 @@ "r", "r" ], - "textposition": "auto", "textinfo": "initial+delta+final", "xaxis": "x", "yaxis": "y" @@ -40,7 +39,6 @@ "r", "r" ], - "textposition": "auto", "textinfo": "initial+delta+final", "xaxis": "x2", "yaxis": "y2" @@ -64,7 +62,6 @@ "r", "r" ], - "textposition": "auto", "textinfo": "initial+delta+final", "xaxis": "x3", "yaxis": "y3" @@ -88,7 +85,6 @@ "r", "r" ], - "textposition": "auto", "textinfo": "initial+delta+final", "xaxis": "x4", "yaxis": "y4" diff --git a/test/jasmine/tests/bar_test.js b/test/jasmine/tests/bar_test.js index 41d826f93c0..72e020c9dc7 100644 --- a/test/jasmine/tests/bar_test.js +++ b/test/jasmine/tests/bar_test.js @@ -125,11 +125,20 @@ describe('Bar.supplyDefaults', function() { expect(traceOut.width).toBeUndefined(); }); - it('should coerce textposition to none', function() { + it('should coerce textposition to auto', function() { traceIn = { y: [1, 2, 3] }; supplyDefaults(traceIn, traceOut, defaultColor, {}); + expect(traceOut.textposition).toBe('auto'); + }); + + it('should not coerce text styling attributes when textposition is set to none', function() { + traceIn = { + textposition: 'none', + y: [1, 2, 3] + }; + supplyDefaults(traceIn, traceOut, defaultColor, {}); expect(traceOut.textposition).toBe('none'); expect(traceOut.texfont).toBeUndefined(); expect(traceOut.insidetexfont).toBeUndefined(); @@ -1355,7 +1364,6 @@ describe('A bar plot', function() { y: [20, 14, 23, 10, 59, 15], text: [20, 14, 23, 10, 59, 15], type: 'bar', - textposition: 'auto', marker: { color: ['#ee1', '#eee', '#333', '#9467bd', '#dda', '#922'], } @@ -1715,7 +1723,7 @@ describe('A bar plot', function() { y: [10, 20, 30, 40], type: 'bar', text: ['T1P1', 'T1P2', 13, 14], - textposition: ['inside', 'outside', 'auto', 'BADVALUE'], + textposition: ['inside', 'outside', 'BADVALUE', 'none'], textfont: { family: ['"comic sans"'], color: ['red', 'green'], @@ -1739,7 +1747,7 @@ describe('A bar plot', function() { y: [10, 20, 30, 40], type: 'bar', text: ['T1P1', 'T1P2', '13', '14'], - textposition: ['inside', 'outside', 'none'], + textposition: ['inside', 'outside', 'auto', 'none'], textfont: { family: ['"comic sans"', 'arial'], color: ['red', 'green'], @@ -1868,8 +1876,7 @@ describe('A bar plot', function() { type: 'bar', x: ['Product A', 'Product B', 'Product C'], y: [20, 14, 23], - text: [20, 14, 23], - textposition: 'auto' + text: [20, 14, 23] }]) .then(function() { _assertNumberOfBarTextNodes(3); diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index 1c36a912650..d9de5053ba9 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -116,11 +116,20 @@ describe('Waterfall.supplyDefaults', function() { expect(traceOut.width).toBeUndefined(); }); - it('should coerce textposition to none', function() { + it('should coerce textposition to auto', function() { traceIn = { y: [1, 2, 3] }; supplyDefaults(traceIn, traceOut, defaultColor, {}); + expect(traceOut.textposition).toBe('auto'); + }); + + it('should not coerce text styling attributes when textposition is set to none', function() { + traceIn = { + textposition: 'none', + y: [1, 2, 3] + }; + supplyDefaults(traceIn, traceOut, defaultColor, {}); expect(traceOut.textposition).toBe('none'); expect(traceOut.texfont).toBeUndefined(); expect(traceOut.insidetexfont).toBeUndefined(); @@ -130,6 +139,7 @@ describe('Waterfall.supplyDefaults', function() { it('should not coerce textinfo when textposition is none', function() { traceIn = { + textposition: 'none', y: [1, 2, 3], textinfo: 'text' }; @@ -140,7 +150,6 @@ describe('Waterfall.supplyDefaults', function() { it('should coerce textinfo when textposition is not none', function() { traceIn = { y: [1, 2, 3], - textposition: 'auto', textinfo: 'text' }; supplyDefaults(traceIn, traceOut, defaultColor, {}); @@ -732,7 +741,6 @@ describe('A waterfall plot', function() { y: [20, 14, 23, 10, 59, 15], text: [20, 14, 23, 10, 59, 15], type: 'waterfall', - textposition: 'auto', marker: { color: ['#ee1', '#eee', '#333', '#9467bd', '#dda', '#922'], } @@ -775,7 +783,6 @@ describe('A waterfall plot', function() { }, { width: [0.4, 0.6, 0.8, 1], text: ['Three', 2, 'inside text', 0], - textposition: 'auto', textfont: { size: [10] }, y: [3, 2, 1, 0], x: [1, 2, 3, 4], @@ -789,7 +796,6 @@ describe('A waterfall plot', function() { type: 'waterfall' }, { text: [0, 'outside text', -3, -2], - textposition: 'auto', y: [0, -0.25, -3, -2], x: [1, 2, 3, 4], type: 'waterfall' @@ -1051,7 +1057,7 @@ describe('A waterfall plot', function() { y: [10, 20, 30, 40], type: 'waterfall', text: ['T1P1', 'T1P2', 13, 14], - textposition: ['inside', 'outside', 'auto', 'BADVALUE'], + textposition: ['inside', 'outside', 'BADVALUE', 'none'], textfont: { family: ['"comic sans"'], color: ['red', 'green'], @@ -1075,7 +1081,7 @@ describe('A waterfall plot', function() { y: [10, 20, 30, 40], type: 'waterfall', text: ['T1P1', 'T1P2', '13', '14'], - textposition: ['inside', 'outside', 'none'], + textposition: ['inside', 'outside', 'auto', 'none'], textfont: { family: ['"comic sans"', 'arial'], color: ['red', 'green'], @@ -1140,7 +1146,6 @@ describe('A waterfall plot', function() { x: ['Product A', 'Product B', 'Product C'], y: [20, 14, 23], text: [20, 14, 23], - textposition: 'auto' }]) .then(function() { _assertNumberOfWaterfallTextNodes(3);