From 54ed82ed079fb0cbae182ae7659f4876eee02ffa Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Tue, 11 Jun 2019 16:29:18 -0400 Subject: [PATCH 1/4] wip --- src/components/containers/SubplotAccordion.js | 6 +++-- .../containers/TraceMarkerSection.js | 2 ++ src/components/fields/DataSelector.js | 1 + src/components/fields/TextPosition.js | 5 +++- src/components/fields/derived.js | 4 ++-- src/default_panels/StyleTracesPanel.js | 24 ++++++++++++++++++- src/lib/customTraceType.js | 23 +----------------- src/lib/traceTypes.js | 10 ++++++++ 8 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/components/containers/SubplotAccordion.js b/src/components/containers/SubplotAccordion.js index 54b8982d8..d62772168 100644 --- a/src/components/containers/SubplotAccordion.js +++ b/src/components/containers/SubplotAccordion.js @@ -64,7 +64,7 @@ class SubplotAccordion extends Component { // of right type that have attr 'subplot': 'ternary' in their data. /** - Example: + Example: { "data": [ { @@ -126,7 +126,9 @@ class SubplotAccordion extends Component { data.forEach((d, i) => { if ( (d.type === 'pie' && d.values) || - ['pie', 'table', 'sunburst', 'sankey', 'parcoords', 'parcats'].includes(d.type) + ['pie', 'table', 'sunburst', 'sankey', 'parcoords', 'parcats', 'funnelarea'].includes( + d.type + ) ) { counter[d.type]++; const currentCount = counter[d.type]; diff --git a/src/components/containers/TraceMarkerSection.js b/src/components/containers/TraceMarkerSection.js index 149f57557..6a26586ce 100644 --- a/src/components/containers/TraceMarkerSection.js +++ b/src/components/containers/TraceMarkerSection.js @@ -17,6 +17,8 @@ class TraceMarkerSection extends Component { const traceType = context.fullContainer.type; if (['bar', 'histogram'].includes(traceType)) { this.name = _('Bars'); + } else if (traceType === 'funnelarea') { + this.name = _('Funnel Segments'); } else if (traceType === 'pie') { this.name = _('Pie Segments'); } else if (traceType === 'sunburst') { diff --git a/src/components/fields/DataSelector.js b/src/components/fields/DataSelector.js index 5cdefe92b..59a676d5a 100644 --- a/src/components/fields/DataSelector.js +++ b/src/components/fields/DataSelector.js @@ -40,6 +40,7 @@ export class UnconnectedDataSelector extends Component { 'scatter', 'scattergl', 'bar', + 'funnel', 'heatmap', 'heatmapgl', 'violin', diff --git a/src/components/fields/TextPosition.js b/src/components/fields/TextPosition.js index 0542c7888..d0a12efa4 100644 --- a/src/components/fields/TextPosition.js +++ b/src/components/fields/TextPosition.js @@ -91,7 +91,7 @@ export default connectToContainer(UnconnectedTextPosition, { {label: _('Bottom Center'), value: 'bottom center'}, {label: _('Bottom Right'), value: 'bottom right'}, ]; - if (['pie', 'bar', 'waterfall'].includes(context.container.type)) { + if (['pie', 'bar', 'funnel', 'waterfall'].includes(context.container.type)) { options = [ {label: _('Inside'), value: 'inside'}, {label: _('Outside'), value: 'outside'}, @@ -99,6 +99,9 @@ export default connectToContainer(UnconnectedTextPosition, { {label: _('None'), value: 'none'}, ]; } + if (['funnelarea'].includes(context.container.type)) { + options = [{label: _('Inside'), value: 'inside'}, {label: _('None'), value: 'none'}]; + } plotProps.options = options; plotProps.clearable = false; }, diff --git a/src/components/fields/derived.js b/src/components/fields/derived.js index 2b03f664f..9b748dc27 100644 --- a/src/components/fields/derived.js +++ b/src/components/fields/derived.js @@ -591,11 +591,11 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, { options = []; } - if (container.labels && ['pie', 'sunburst'].includes(container.type)) { + if (container.labels && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) { options.push({label: _('Label'), value: 'label'}); } - if (container.values && ['pie', 'sunburst'].includes(container.type)) { + if (container.values && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) { options.push({label: _('Value'), value: 'value'}); } diff --git a/src/default_panels/StyleTracesPanel.js b/src/default_panels/StyleTracesPanel.js index e78cb8db8..b97e6be60 100644 --- a/src/default_panels/StyleTracesPanel.js +++ b/src/default_panels/StyleTracesPanel.js @@ -122,7 +122,28 @@ const StyleTracesPanel = (props, {localize: _}) => ( /> - + + + + + + + + + + + ( attr="connector.visible" options={[{label: _('Show'), value: true}, {label: _('Hide'), value: false}]} /> + diff --git a/src/lib/customTraceType.js b/src/lib/customTraceType.js index 9bd749d9b..251eb4720 100644 --- a/src/lib/customTraceType.js +++ b/src/lib/customTraceType.js @@ -1,5 +1,3 @@ -import {COLORS} from 'lib/constants'; - export function plotlyTraceToCustomTrace(trace) { if (typeof trace !== 'object') { throw new Error( @@ -45,29 +43,10 @@ export function traceTypeToPlotlyInitFigure(traceType, gl = '') { return {type: 'scatter' + gl, mode: 'lines', stackgroup: 1}; case 'scatterpolar': return {type: 'scatterpolar' + gl}; - case 'ohlc': - return { - type: 'ohlc', - decreasing: {line: {color: COLORS.middleGray}}, - increasing: {line: {color: COLORS.blueTeal}}, - }; case 'waterfall': return { type: 'waterfall', - decreasing: {line: {color: COLORS.middleGray}}, - increasing: {line: {color: COLORS.blueTeal}}, - }; - case 'candlestick': - return { - type: 'candlestick', - decreasing: { - line: {color: COLORS.middleGray}, - fillcolor: 'rgba(127, 127, 127, 0.5)', - }, - increasing: { - line: {color: COLORS.blueTeal}, - fillcolor: 'rgba(23, 190, 207, 0.5)', - }, + orientation: 'v', }; case 'box': return { diff --git a/src/lib/traceTypes.js b/src/lib/traceTypes.js index 54ad1695a..ed41f57bc 100644 --- a/src/lib/traceTypes.js +++ b/src/lib/traceTypes.js @@ -200,6 +200,16 @@ export const traceTypes = _ => [ label: _('Waterfall'), category: chartCategory(_).FINANCIAL, }, + { + value: 'funnel', + label: _('Funnel'), + category: chartCategory(_).FINANCIAL, + }, + { + value: 'funnelarea', + label: _('Funnel Area'), + category: chartCategory(_).FINANCIAL, + }, { value: 'scattergl', icon: 'scatter', From 6af5b97653510ca3b324ca2edaa076af6ffbcd61 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Tue, 11 Jun 2019 22:11:16 -0400 Subject: [PATCH 2/4] wip --- src/EditorControls.js | 3 +- .../containers/TraceMarkerSection.js | 10 +- src/components/fields/derived.js | 13 +- src/default_panels/StyleTracesPanel.js | 231 +++++++++--------- src/lib/constants.js | 1 + src/shame.js | 6 + 6 files changed, 144 insertions(+), 120 deletions(-) diff --git a/src/EditorControls.js b/src/EditorControls.js index 204ca4a9e..3b08f5078 100644 --- a/src/EditorControls.js +++ b/src/EditorControls.js @@ -11,6 +11,7 @@ import { shamefullyAdjustSplitStyleTargetContainers, shamefullyDeleteRelatedAnalysisTransforms, shamefullyAdjustSizeref, + shamefullyAdjustAxisDirection, } from './shame'; import {EDITOR_ACTIONS} from './lib/constants'; import isNumeric from 'fast-isnumeric'; @@ -71,7 +72,7 @@ class EditorControls extends Component { } shamefullyAdjustSizeref(graphDiv, payload); - + shamefullyAdjustAxisDirection(graphDiv, payload); shamefullyClearAxisTypes(graphDiv, payload); shamefullyAdjustAxisRef(graphDiv, payload); shamefullyAddTableColumns(graphDiv, payload); diff --git a/src/components/containers/TraceMarkerSection.js b/src/components/containers/TraceMarkerSection.js index 6a26586ce..a798255b0 100644 --- a/src/components/containers/TraceMarkerSection.js +++ b/src/components/containers/TraceMarkerSection.js @@ -15,14 +15,10 @@ class TraceMarkerSection extends Component { setLocals(context) { const _ = this.context.localize; const traceType = context.fullContainer.type; - if (['bar', 'histogram'].includes(traceType)) { + if (['bar', 'histogram', 'funnel', 'waterfall'].includes(traceType)) { this.name = _('Bars'); - } else if (traceType === 'funnelarea') { - this.name = _('Funnel Segments'); - } else if (traceType === 'pie') { - this.name = _('Pie Segments'); - } else if (traceType === 'sunburst') { - this.name = _('Sunburst Segments'); + } else if (['funnelarea', 'pie', 'sunburst'].includes(traceType)) { + this.name = _('Segments'); } else { this.name = _('Points'); } diff --git a/src/components/fields/derived.js b/src/components/fields/derived.js index 9b748dc27..569eda5fc 100644 --- a/src/components/fields/derived.js +++ b/src/components/fields/derived.js @@ -500,12 +500,23 @@ function computeAxesRefOptions(axes, propsAttr) { export const TextInfo = connectToContainer(UnconnectedFlaglist, { modifyPlotProps: (props, context, plotProps) => { const {localize: _, container} = context; - const options = [ + + let options = [ {label: _('Label'), value: 'label'}, {label: _('Value'), value: 'value'}, {label: _('%'), value: 'percent'}, ]; + if (container.type === 'funnel') { + options = [ + {label: _('Label'), value: 'label'}, + {label: _('Value'), value: 'value'}, + {label: _('% initial'), value: 'percent initial'}, + {label: _('% previous'), value: 'percent previous'}, + {label: _('% total'), value: 'percent total'}, + ]; + } + if (container.text) { options.push({label: _('Text'), value: 'text'}); } diff --git a/src/default_panels/StyleTracesPanel.js b/src/default_panels/StyleTracesPanel.js index b97e6be60..f29182491 100644 --- a/src/default_panels/StyleTracesPanel.js +++ b/src/default_panels/StyleTracesPanel.js @@ -91,18 +91,11 @@ const StyleTracesPanel = (props, {localize: _}) => ( - - - - - - - - + ( attr="extendpiecolors" options={[{label: _('On'), value: true}, {label: _('Off'), value: false}]} /> - - - - - - - - ( @@ -279,6 +264,32 @@ const StyleTracesPanel = (props, {localize: _}) => ( /> + + + + + + + + @@ -384,6 +395,60 @@ const StyleTracesPanel = (props, {localize: _}) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -547,6 +612,40 @@ const StyleTracesPanel = (props, {localize: _}) => ( options={[{label: _('Yes'), value: true}, {label: _('No'), value: false}]} /> + + + + + + + + + + + + + + + ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( - - - - - - - - - - - - - - - - - { update['marker.sizemode'] = 'area'; } }; + +export const shamefullyAdjustAxisDirection = (gd, {update}) => { + if (update.type === 'funnel' && gd.data.length === 1) { + gd.layout.yaxis.autorange = 'reversed'; + } +}; From b890a13f789b3b0bffa8a0e63b2445bba5076f20 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Tue, 11 Jun 2019 22:37:21 -0400 Subject: [PATCH 3/4] wip --- src/default_panels/StyleTracesPanel.js | 68 +++++++++++++------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/default_panels/StyleTracesPanel.js b/src/default_panels/StyleTracesPanel.js index f29182491..756265d9d 100644 --- a/src/default_panels/StyleTracesPanel.js +++ b/src/default_panels/StyleTracesPanel.js @@ -612,40 +612,6 @@ const StyleTracesPanel = (props, {localize: _}) => ( options={[{label: _('Yes'), value: true}, {label: _('No'), value: false}]} /> - - - - - - - - - - - - - - - ( + + + + + + + + + + + + + + + Date: Tue, 11 Jun 2019 22:47:31 -0400 Subject: [PATCH 4/4] percy --- dev/mocks.json | 2 ++ dev/percy/funnel.json | 9 +++++++++ dev/percy/funnelarea.json | 9 +++++++++ dev/percy/index.js | 2 ++ 4 files changed, 22 insertions(+) create mode 100644 dev/percy/funnel.json create mode 100644 dev/percy/funnelarea.json diff --git a/dev/mocks.json b/dev/mocks.json index c13a3f0d0..e7436f252 100644 --- a/dev/mocks.json +++ b/dev/mocks.json @@ -3,6 +3,8 @@ "/percy/panelTest.json", "/percy/bar.json", "/percy/box.json", + "/percy/funnel.json", + "/percy/funnelarea.json", "/percy/histogram.json", "/percy/histogram2d.json", "/percy/pie.json", diff --git a/dev/percy/funnel.json b/dev/percy/funnel.json new file mode 100644 index 000000000..8d716a1f1 --- /dev/null +++ b/dev/percy/funnel.json @@ -0,0 +1,9 @@ +{ + "data": [ + { + "type": "funnel", + "y": ["Lead", "Pipeline", "Proposal", "Negotiation", "Closed (Won)"], + "x": [ 610, 432, 231, 103, 54 ] + } + ] +} diff --git a/dev/percy/funnelarea.json b/dev/percy/funnelarea.json new file mode 100644 index 000000000..b5f5d23d1 --- /dev/null +++ b/dev/percy/funnelarea.json @@ -0,0 +1,9 @@ +{ + "data": [ + { + "type": "funnelarea", + "labels": ["Lead", "Pipeline", "Proposal", "Negotiation", "Closed (Won)"], + "values": [ 610, 432, 231, 103, 54 ] + } + ] +} diff --git a/dev/percy/index.js b/dev/percy/index.js index 7598bd307..0c070d867 100644 --- a/dev/percy/index.js +++ b/dev/percy/index.js @@ -8,4 +8,6 @@ export {default as box} from './box.json'; export {default as waterfall} from './waterfall.json'; export {default as sunburst} from './sunburst.json'; export {default as sankey} from './sankey.json'; +export {default as funnel} from './funnel.json'; +export {default as funnelarea} from './funnelarea.json'; export {default as geoTest} from './geoTest.json';