Skip to content

Commit c7a4fc2

Browse files
Merge pull request #934 from plotly/funnels
Funnel support
2 parents e930ad9 + 1242135 commit c7a4fc2

File tree

15 files changed

+174
-109
lines changed

15 files changed

+174
-109
lines changed

dev/mocks.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"/percy/panelTest.json",
44
"/percy/bar.json",
55
"/percy/box.json",
6+
"/percy/funnel.json",
7+
"/percy/funnelarea.json",
68
"/percy/histogram.json",
79
"/percy/histogram2d.json",
810
"/percy/pie.json",

dev/percy/funnel.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"data": [
3+
{
4+
"type": "funnel",
5+
"y": ["Lead", "Pipeline", "Proposal", "Negotiation", "Closed (Won)"],
6+
"x": [ 610, 432, 231, 103, 54 ]
7+
}
8+
]
9+
}

dev/percy/funnelarea.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"data": [
3+
{
4+
"type": "funnelarea",
5+
"labels": ["Lead", "Pipeline", "Proposal", "Negotiation", "Closed (Won)"],
6+
"values": [ 610, 432, 231, 103, 54 ]
7+
}
8+
]
9+
}

dev/percy/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ export {default as box} from './box.json';
88
export {default as waterfall} from './waterfall.json';
99
export {default as sunburst} from './sunburst.json';
1010
export {default as sankey} from './sankey.json';
11+
export {default as funnel} from './funnel.json';
12+
export {default as funnelarea} from './funnelarea.json';
1113
export {default as geoTest} from './geoTest.json';

src/EditorControls.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
shamefullyAdjustSplitStyleTargetContainers,
1212
shamefullyDeleteRelatedAnalysisTransforms,
1313
shamefullyAdjustSizeref,
14+
shamefullyAdjustAxisDirection,
1415
} from './shame';
1516
import {EDITOR_ACTIONS} from './lib/constants';
1617
import isNumeric from 'fast-isnumeric';
@@ -71,7 +72,7 @@ class EditorControls extends Component {
7172
}
7273

7374
shamefullyAdjustSizeref(graphDiv, payload);
74-
75+
shamefullyAdjustAxisDirection(graphDiv, payload);
7576
shamefullyClearAxisTypes(graphDiv, payload);
7677
shamefullyAdjustAxisRef(graphDiv, payload);
7778
shamefullyAddTableColumns(graphDiv, payload);

src/components/containers/SubplotAccordion.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class SubplotAccordion extends Component {
6464
// of right type that have attr 'subplot': 'ternary' in their data.
6565

6666
/**
67-
Example:
67+
Example:
6868
{
6969
"data": [
7070
{
@@ -126,7 +126,9 @@ class SubplotAccordion extends Component {
126126
data.forEach((d, i) => {
127127
if (
128128
(d.type === 'pie' && d.values) ||
129-
['pie', 'table', 'sunburst', 'sankey', 'parcoords', 'parcats'].includes(d.type)
129+
['pie', 'table', 'sunburst', 'sankey', 'parcoords', 'parcats', 'funnelarea'].includes(
130+
d.type
131+
)
130132
) {
131133
counter[d.type]++;
132134
const currentCount = counter[d.type];

src/components/containers/TraceMarkerSection.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ class TraceMarkerSection extends Component {
1515
setLocals(context) {
1616
const _ = this.context.localize;
1717
const traceType = context.fullContainer.type;
18-
if (['bar', 'histogram'].includes(traceType)) {
18+
if (['bar', 'histogram', 'funnel', 'waterfall'].includes(traceType)) {
1919
this.name = _('Bars');
20-
} else if (traceType === 'pie') {
21-
this.name = _('Pie Segments');
22-
} else if (traceType === 'sunburst') {
23-
this.name = _('Sunburst Segments');
20+
} else if (['funnelarea', 'pie', 'sunburst'].includes(traceType)) {
21+
this.name = _('Segments');
2422
} else {
2523
this.name = _('Points');
2624
}

src/components/fields/DataSelector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class UnconnectedDataSelector extends Component {
4040
'scatter',
4141
'scattergl',
4242
'bar',
43+
'funnel',
4344
'heatmap',
4445
'heatmapgl',
4546
'violin',

src/components/fields/TextPosition.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@ export default connectToContainer(UnconnectedTextPosition, {
9191
{label: _('Bottom Center'), value: 'bottom center'},
9292
{label: _('Bottom Right'), value: 'bottom right'},
9393
];
94-
if (['pie', 'bar', 'waterfall'].includes(context.container.type)) {
94+
if (['pie', 'bar', 'funnel', 'waterfall'].includes(context.container.type)) {
9595
options = [
9696
{label: _('Inside'), value: 'inside'},
9797
{label: _('Outside'), value: 'outside'},
9898
{label: _('Auto'), value: 'auto'},
9999
{label: _('None'), value: 'none'},
100100
];
101101
}
102+
if (['funnelarea'].includes(context.container.type)) {
103+
options = [{label: _('Inside'), value: 'inside'}, {label: _('None'), value: 'none'}];
104+
}
102105
plotProps.options = options;
103106
plotProps.clearable = false;
104107
},

src/components/fields/derived.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,23 @@ function computeAxesRefOptions(axes, propsAttr) {
500500
export const TextInfo = connectToContainer(UnconnectedFlaglist, {
501501
modifyPlotProps: (props, context, plotProps) => {
502502
const {localize: _, container} = context;
503-
const options = [
503+
504+
let options = [
504505
{label: _('Label'), value: 'label'},
505506
{label: _('Value'), value: 'value'},
506507
{label: _('%'), value: 'percent'},
507508
];
508509

510+
if (container.type === 'funnel') {
511+
options = [
512+
{label: _('Label'), value: 'label'},
513+
{label: _('Value'), value: 'value'},
514+
{label: _('% initial'), value: 'percent initial'},
515+
{label: _('% previous'), value: 'percent previous'},
516+
{label: _('% total'), value: 'percent total'},
517+
];
518+
}
519+
509520
if (container.text) {
510521
options.push({label: _('Text'), value: 'text'});
511522
}
@@ -591,11 +602,11 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
591602
options = [];
592603
}
593604

594-
if (container.labels && ['pie', 'sunburst'].includes(container.type)) {
605+
if (container.labels && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) {
595606
options.push({label: _('Label'), value: 'label'});
596607
}
597608

598-
if (container.values && ['pie', 'sunburst'].includes(container.type)) {
609+
if (container.values && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) {
599610
options.push({label: _('Value'), value: 'value'});
600611
}
601612

0 commit comments

Comments
 (0)