Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c29b58d

Browse files
committedMay 3, 2019
revisit textinfo and width defaults - fix and improve tests
1 parent 0c169b5 commit c29b58d

21 files changed

+51
-47
lines changed
 

‎src/traces/funnel/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
orientation: barAttrs.orientation,
4848

4949
offset: extendFlat({}, barAttrs.offset, {arrayOk: false}),
50-
width: extendFlat({}, barAttrs.width, {arrayOK: false}),
50+
width: extendFlat({}, barAttrs.width, {arrayOk: false}),
5151

5252
marker: barAttrs.marker,
5353

‎src/traces/funnel/defaults.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
3131
coerce('offset');
3232
coerce('width');
3333

34-
coerce('text');
34+
var text = coerce('text');
3535

3636
coerce('hovertext');
3737
coerce('hovertemplate');
@@ -40,7 +40,9 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
4040

4141
// TODO: move this block to bar handleText if/when textinfo implimented for bars/histograms
4242
if(traceOut.textposition !== 'none') {
43-
coerce('textinfo');
43+
var defaultTextinfo =
44+
Lib.isArrayOrTypedArray(text) ? 'text+value' : 'value';
45+
coerce('textinfo', defaultTextinfo);
4446
}
4547

4648
var markerColor = coerce('marker.color', defaultColor);
Loading
4.3 KB
Loading

‎test/image/baselines/funnel_11.png

3.35 KB
Loading

‎test/image/baselines/funnel_attrs.png

1.86 KB
Loading
Loading
3.55 KB
Loading
4.32 KB
Loading

‎test/image/baselines/funnel_gap0.png

6.32 KB
Loading
-519 Bytes
Loading
-4.98 KB
Loading
Loading

‎test/image/mocks/funnel_axis_with_other_traces.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"data": [
33
{
44
"type": "funnel",
5+
"insidetextanchor": "start",
56
"width": 0.6,
67
"opacity": 0.8,
78
"x": [
@@ -23,6 +24,7 @@
2324
},
2425
{
2526
"type": "funnel",
27+
"insidetextanchor": "start",
2628
"width": 0.6,
2729
"opacity": 0.8,
2830
"x": [
@@ -56,6 +58,7 @@
5658
},
5759
{
5860
"type": "funnel",
61+
"insidetextanchor": "start",
5962
"width": 0.6,
6063
"opacity": 0.8,
6164
"orientation": "h",
@@ -148,13 +151,12 @@
148151
}
149152
],
150153
"layout": {
151-
"text": {
152-
"title": "Should not see axis lines by default when there are only funnels!"
154+
"title": {
155+
"text": "Should not see axis lines by default when there are only funnels!"
153156
},
154157
"width": 800,
155158
"height": 800,
156159
"dragmode": "pan",
157-
"funnelmode": "overlay",
158160
"xaxis": {
159161
"domain": [
160162
0,
@@ -197,13 +199,15 @@
197199
},
198200
"yaxis3": {
199201
"anchor": "x3",
202+
"autorange": "reversed",
200203
"domain": [
201204
0.52,
202205
1
203206
]
204207
},
205208
"yaxis4": {
206209
"anchor": "x4",
210+
"autorange": "reversed",
207211
"domain": [
208212
0,
209213
0.48

‎test/image/mocks/funnel_cliponaxis-false.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"x": ["apple", "banana", "clementine"],
77
"y": [3.8, 4, 4.2],
88
"text": ["apple", "banana", "x"],
9+
"textinfo": "text",
910
"textposition": "outside",
1011
"cliponaxis": false,
1112
"textfont": {
@@ -18,6 +19,7 @@
1819
"x": ["apple", "banana", "clementine"],
1920
"y": [3.8, 4, 4.2],
2021
"text": ["apple", "banana", "clementine"],
22+
"textinfo": "text",
2123
"textposition": "outside",
2224
"cliponaxis": true,
2325
"textfont": {
@@ -32,6 +34,7 @@
3234
"x": ["banana"],
3335
"y": [4],
3436
"text": ["X"],
37+
"textinfo": "text",
3538
"textposition": "outside",
3639
"cliponaxis": true,
3740
"textfont": {"size": [20]},
@@ -43,6 +46,7 @@
4346
"x": ["banana"],
4447
"y": [2],
4548
"text": ["banana"],
49+
"textinfo": "text",
4650
"textposition": "outside",
4751
"cliponaxis": false,
4852
"textfont": {"size": [20]},

‎test/image/mocks/funnel_date-axes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
}
2222
}],
2323
"layout": {
24+
"margin": { "l": 100, "r": 20, "t": 20, "b": 20 },
2425
"yaxis": {
2526
"autorange": "reversed"
2627
},

‎test/image/mocks/funnel_gap0.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
"data": [
33
{
44
"x": [
5-
"giraffes",
6-
"orangutans",
7-
"monkeys"
5+
"Lead",
6+
"Proposal",
7+
"Finalize"
88
],
99
"y": [
10-
20,
11-
14,
12-
23
10+
20.0020,
11+
10.001001,
12+
"05.0005"
1313
],
1414
"name": "SF Zoo",
15-
"type": "funnel"
15+
"type": "funnel",
16+
"textfont": { "size": 18 }
1617
}
1718
],
1819
"layout": {
20+
"margin": { "l": 20, "r": 20, "t": 20, "b": 50 },
1921
"funnelgap": 0,
2022
"xaxis": {
2123
"type": "category",
2224
"range": [
2325
-0.5,
2426
2.5
2527
],
26-
"autorange": true
28+
"tickfont": { "size": 24 }
2729
},
2830
"yaxis": {
2931
"type": "linear",
30-
"range": [
31-
0,
32-
24.210526315789473
33-
],
34-
"autorange": true
32+
"tickprefix": "$",
33+
"ticksuffix": " million"
34+
3535
},
36-
"height": 300,
36+
"height": 260,
3737
"width": 900,
3838
"autosize": false
3939
}

‎test/image/mocks/funnel_multicategory.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"data": [
33
{
4-
"type": "funnel", "opacity": 0.8, "offset": -0.25, "width": 0.5,
4+
"type": "funnel", "opacity": 0.8, "offset": -0.5, "width": 0.5,
55
"cliponaxis": false,
66
"textposition": "inside",
77
"textinfo": "value+percent initial",
@@ -13,7 +13,7 @@
1313
"y": [4000.004, 3000.003, 2000.002, 1000.001, 4000.004, 2000.002, 1000.001, 500.0005]
1414
},
1515
{
16-
"type": "funnel", "opacity": 0.8, "offset": -0.25, "width": 0.5,
16+
"type": "funnel", "opacity": 0.8, "offset": -0.5, "width": 0.5,
1717
"cliponaxis": false,
1818
"textposition": "outside",
1919
"textinfo": "text+value+percent initial",
@@ -25,7 +25,7 @@
2525
"y": [5000.005, 4000.004, 3000.003, 2000.002, 8000.008, 4000.004, 2000.002, 1000.001]
2626
},
2727
{
28-
"type": "waterfall", "opacity": 0.8, "offset": 0.25, "width": 0.5,
28+
"type": "waterfall", "opacity": 0.8, "offset": 0.0, "width": 0.5,
2929
"cliponaxis": false,
3030
"textposition": "inside",
3131
"insidetextrotate": "none",
@@ -41,7 +41,7 @@
4141
"layout": {
4242
"width": 1800,
4343
"height": 600,
44-
"margin": { "l": 150 },
44+
"margin": { "l": 50, "r": 50, "t": 50, "b": 50 },
4545
"xaxis": {
4646
"title": "MULTI-CATEGORY two stacked funnels with arrayOK text and one waterfall with textinfo",
4747
"tickfont": {"size": 16},

‎test/image/mocks/funnel_nonnumeric_sizes.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
1,
1414
null,
1515
"nonsense",
16-
14,
16+
2,
1717
0,
1818
1
1919
],
2020
"type": "funnel"
2121
}
22-
]
22+
],
23+
"layout": {
24+
"margin": { "l": 20, "r": 20, "t": 20, "b": 50 },
25+
"width": 600,
26+
"height": 200
27+
}
2328
}

‎test/image/mocks/funnel_vertical_overlay_custom_arrays.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
1
2020
],
2121
"textposition": "outside",
22-
"text": [
23-
"3756",
24-
"1580",
25-
"663",
26-
"343",
27-
"1"
28-
],
2922
"connector": {
3023
"fillcolor": "rgba(0, 0, 0, 0)",
3124
"line": {
@@ -59,14 +52,7 @@
5952
0
6053
]
6154
}
62-
},
63-
"width": [
64-
0.85,
65-
0.70,
66-
0.55,
67-
0.30,
68-
0.15
69-
]
55+
}
7056
},
7157
{
7258
"name": "orca",
@@ -122,7 +108,7 @@
122108
"yaxis": {
123109
"type": "linear"
124110
},
125-
"margin": { "l": 150 },
111+
"margin": { "l": 0 },
126112
"height": 800,
127113
"width": 800,
128114
"funnelmode": "overlay",

‎test/jasmine/tests/funnel_test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ describe('A funnel plot', function() {
754754
y: [20, 14, 23, 10, 59, 15],
755755
text: [20, 14, 23, 10, 59, 15],
756756
type: 'funnel',
757-
textposition: 'auto',
758757
marker: {
759758
color: ['#ee1', '#eee', '#333', '#9467bd', '#dda', '#922'],
760759
}
@@ -792,28 +791,30 @@ describe('A funnel plot', function() {
792791
data: [
793792
{
794793
text: [1, 2, 3333333333, 4],
794+
textinfo: 'text',
795795
textposition: 'outside',
796796
y: [1, 2, 3, 4],
797797
x: [1, 2, 3, 4],
798798
type: 'funnel'
799799
}, {
800800
width: 0.4,
801801
text: ['Three', 2, 'inside text', 0],
802-
textposition: 'auto',
802+
textinfo: 'text',
803803
textfont: { size: [10] },
804804
y: [3, 2, 1, 0],
805805
x: [1, 2, 3, 4],
806806
type: 'funnel'
807807
}, {
808808
width: 1,
809809
text: [4, 3, 2, 1],
810+
textinfo: 'text',
810811
textposition: 'inside',
811812
y: [4, 3, 2, 1],
812813
x: [1, 2, 3, 4],
813814
type: 'funnel'
814815
}, {
815816
text: [0, 'outside text', 3, 2],
816-
textposition: 'auto',
817+
textinfo: 'text',
817818
y: [0, 0.25, 3, 2],
818819
x: [1, 2, 3, 4],
819820
type: 'funnel'
@@ -1088,7 +1089,8 @@ describe('A funnel plot', function() {
10881089
y: [10, 20, 30, 40],
10891090
type: 'funnel',
10901091
text: ['T1P1', 'T1P2', 13, 14],
1091-
textposition: ['inside', 'outside', 'auto', 'BADVALUE'],
1092+
textinfo: 'text',
1093+
textposition: ['inside', 'outside', 'auto', 'none', 'BADVALUE'],
10921094
textfont: {
10931095
family: ['"comic sans"'],
10941096
color: ['red', 'green'],
@@ -1178,7 +1180,7 @@ describe('A funnel plot', function() {
11781180
x: ['Product A', 'Product B', 'Product C'],
11791181
y: [20, 14, 23],
11801182
text: [20, 14, 23],
1181-
textposition: 'auto'
1183+
textinfo: 'none'
11821184
}])
11831185
.then(function() {
11841186
_assertNumberOfFunnelTextNodes(3);

0 commit comments

Comments
 (0)
Please sign in to comment.