Skip to content

Commit d5073df

Browse files
committed
set bar textposition default to auto
- adjust tests
1 parent 9a583b4 commit d5073df

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/traces/bar/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
textposition: {
7575
valType: 'enumerated',
7676
values: ['inside', 'outside', 'auto', 'none'],
77-
dflt: 'none',
77+
dflt: 'auto',
7878
arrayOk: true,
7979
editType: 'calc',
8080
description: [

src/traces/funnel/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
}),
5555

5656
text: barAttrs.text,
57-
textposition: extendFlat({}, barAttrs.textposition, {dflt: 'auto'}),
57+
textposition: barAttrs.textposition,
5858
insidetextanchor: extendFlat({}, barAttrs.insidetextanchor, {dflt: 'middle'}),
5959
textangle: extendFlat({}, barAttrs.textangle, {dflt: 0}),
6060
textfont: barAttrs.textfont,

test/jasmine/tests/bar_test.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,20 @@ describe('Bar.supplyDefaults', function() {
125125
expect(traceOut.width).toBeUndefined();
126126
});
127127

128-
it('should coerce textposition to none', function() {
128+
it('should coerce textposition to auto', function() {
129129
traceIn = {
130130
y: [1, 2, 3]
131131
};
132132
supplyDefaults(traceIn, traceOut, defaultColor, {});
133+
expect(traceOut.textposition).toBe('auto');
134+
});
135+
136+
it('should not coerce text styling attributes when textposition is set to none', function() {
137+
traceIn = {
138+
textposition: 'none',
139+
y: [1, 2, 3]
140+
};
141+
supplyDefaults(traceIn, traceOut, defaultColor, {});
133142
expect(traceOut.textposition).toBe('none');
134143
expect(traceOut.texfont).toBeUndefined();
135144
expect(traceOut.insidetexfont).toBeUndefined();
@@ -1715,7 +1724,7 @@ describe('A bar plot', function() {
17151724
y: [10, 20, 30, 40],
17161725
type: 'bar',
17171726
text: ['T1P1', 'T1P2', 13, 14],
1718-
textposition: ['inside', 'outside', 'auto', 'BADVALUE'],
1727+
textposition: ['inside', 'outside', 'BADVALUE', 'none'],
17191728
textfont: {
17201729
family: ['"comic sans"'],
17211730
color: ['red', 'green'],
@@ -1739,7 +1748,7 @@ describe('A bar plot', function() {
17391748
y: [10, 20, 30, 40],
17401749
type: 'bar',
17411750
text: ['T1P1', 'T1P2', '13', '14'],
1742-
textposition: ['inside', 'outside', 'none'],
1751+
textposition: ['inside', 'outside', 'auto', 'none'],
17431752
textfont: {
17441753
family: ['"comic sans"', 'arial'],
17451754
color: ['red', 'green'],

test/jasmine/tests/waterfall_test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,20 @@ describe('Waterfall.supplyDefaults', function() {
116116
expect(traceOut.width).toBeUndefined();
117117
});
118118

119-
it('should coerce textposition to none', function() {
119+
it('should coerce textposition to auto', function() {
120120
traceIn = {
121121
y: [1, 2, 3]
122122
};
123123
supplyDefaults(traceIn, traceOut, defaultColor, {});
124+
expect(traceOut.textposition).toBe('auto');
125+
});
126+
127+
it('should not coerce text styling attributes when textposition is set to none', function() {
128+
traceIn = {
129+
textposition: 'none',
130+
y: [1, 2, 3]
131+
};
132+
supplyDefaults(traceIn, traceOut, defaultColor, {});
124133
expect(traceOut.textposition).toBe('none');
125134
expect(traceOut.texfont).toBeUndefined();
126135
expect(traceOut.insidetexfont).toBeUndefined();
@@ -130,6 +139,7 @@ describe('Waterfall.supplyDefaults', function() {
130139

131140
it('should not coerce textinfo when textposition is none', function() {
132141
traceIn = {
142+
textposition: 'none',
133143
y: [1, 2, 3],
134144
textinfo: 'text'
135145
};
@@ -1051,7 +1061,7 @@ describe('A waterfall plot', function() {
10511061
y: [10, 20, 30, 40],
10521062
type: 'waterfall',
10531063
text: ['T1P1', 'T1P2', 13, 14],
1054-
textposition: ['inside', 'outside', 'auto', 'BADVALUE'],
1064+
textposition: ['inside', 'outside', 'BADVALUE', 'none'],
10551065
textfont: {
10561066
family: ['"comic sans"'],
10571067
color: ['red', 'green'],
@@ -1075,7 +1085,7 @@ describe('A waterfall plot', function() {
10751085
y: [10, 20, 30, 40],
10761086
type: 'waterfall',
10771087
text: ['T1P1', 'T1P2', '13', '14'],
1078-
textposition: ['inside', 'outside', 'none'],
1088+
textposition: ['inside', 'outside', 'auto', 'none'],
10791089
textfont: {
10801090
family: ['"comic sans"', 'arial'],
10811091
color: ['red', 'green'],

0 commit comments

Comments
 (0)