Skip to content

Commit cb1b934

Browse files
treemap support
1 parent e61d64d commit cb1b934

File tree

6 files changed

+54
-11
lines changed

6 files changed

+54
-11
lines changed

src/components/containers/SubplotAccordion.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class SubplotAccordion extends Component {
118118
pie: 0,
119119
table: 0,
120120
sunburst: 0,
121+
treemap: 0,
121122
sankey: 0,
122123
parcoords: 0,
123124
parcats: 0,
@@ -126,9 +127,16 @@ class SubplotAccordion extends Component {
126127
data.forEach((d, i) => {
127128
if (
128129
(d.type === 'pie' && d.values) ||
129-
['pie', 'table', 'sunburst', 'sankey', 'parcoords', 'parcats', 'funnelarea'].includes(
130-
d.type
131-
)
130+
[
131+
'pie',
132+
'table',
133+
'sunburst',
134+
'treemap',
135+
'sankey',
136+
'parcoords',
137+
'parcats',
138+
'funnelarea',
139+
].includes(d.type)
132140
) {
133141
counter[d.type]++;
134142
const currentCount = counter[d.type];

src/components/containers/TraceMarkerSection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TraceMarkerSection extends Component {
1717
const traceType = context.fullContainer.type;
1818
if (['bar', 'histogram', 'funnel', 'waterfall'].includes(traceType)) {
1919
this.name = _('Bars');
20-
} else if (['funnelarea', 'pie', 'sunburst'].includes(traceType)) {
20+
} else if (['funnelarea', 'pie', 'sunburst', 'treemap'].includes(traceType)) {
2121
this.name = _('Segments');
2222
} else {
2323
this.name = _('Points');

src/components/fields/derived.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ export const TickFormat = connectToContainer(UnconnectedDropdownCustom, {
169169

170170
export const ShowInLegend = connectToContainer(UnconnectedVisibilitySelect, {
171171
modifyPlotProps: (props, context, plotProps) => {
172-
if (context.container.type && context.container.type !== 'sunburst') {
172+
if (
173+
context.container.type &&
174+
context.container.type !== 'sunburst' &&
175+
context.container.type !== 'treemap'
176+
) {
173177
plotProps.isVisible = context.fullLayout.showlegend;
174178
}
175179

@@ -628,15 +632,15 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
628632
{label: _('Norm'), value: 'norm'},
629633
{label: _('Divergence'), value: 'divergence'},
630634
];
631-
} else if (container.type === 'sunburst') {
635+
} else if (container.type === 'sunburst' || container.type === 'treemap') {
632636
options = [];
633637
}
634638

635-
if (container.labels && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) {
639+
if (container.labels && ['pie', 'sunburst', 'treemap', 'funnelarea'].includes(container.type)) {
636640
options.push({label: _('Label'), value: 'label'});
637641
}
638642

639-
if (container.values && ['pie', 'sunburst', 'funnelarea'].includes(container.type)) {
643+
if (container.values && ['pie', 'sunburst', 'treemap', 'funnelarea'].includes(container.type)) {
640644
options.push({label: _('Value'), value: 'value'});
641645
}
642646

src/default_panels/GraphCreatePanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const GraphCreatePanel = (props, {localize: _, setPanel}) => {
3838
<DataSelector label={_('Labels')} attr="labels" />
3939
<DataSelector label={_('Parents')} attr="parents" />
4040

41-
<TraceTypeSection traceTypes={['sunburst']} mode="trace">
41+
<TraceTypeSection traceTypes={['sunburst', 'treemap']} mode="trace">
4242
<DataSelector label={_('IDs')} attr="ids" />
4343
</TraceTypeSection>
4444
<Dropdown

src/default_panels/StyleTracesPanel.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
5656
<TraceAccordion canGroup>
5757
<TextEditor label={_('Name')} attr="name" richTextOnly />
5858
<NumericFraction label={_('Trace Opacity')} attr="opacity" />
59-
<TraceTypeSection name={_('Leaves')} traceTypes={['sunburst']} mode="trace">
59+
<TraceTypeSection name={_('Leaves')} traceTypes={['sunburst', 'treemap']} mode="trace">
6060
<LevelRendered label={_('Start at Level')} attr="level" />
6161
<Numeric label={_('Max Depth')} attr="maxdepth" min={-1} step={1} />
6262
<NumericFraction label={_('Opacity')} attr="leaf.opacity" />
@@ -99,7 +99,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
9999
<MultiColorPicker label={_('Color')} attr="color" />
100100
<TraceTypeSection
101101
name={_('Segment Colors')}
102-
traceTypes={['pie', 'sunburst', 'funnelarea']}
102+
traceTypes={['pie', 'sunburst', 'treemap', 'funnelarea']}
103103
mode="trace"
104104
>
105105
<LayoutSection attr="name">
@@ -113,6 +113,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
113113
]}
114114
/>
115115
<ColorwayPicker label={_('Colors')} attr="sunburstcolorway" />
116+
<ColorwayPicker label={_('Colors')} attr="treemapcolorway" />
116117
<Radio
117118
label={_('Extended Colors')}
118119
attr="extendsunburstcolors"
@@ -121,6 +122,14 @@ const StyleTracesPanel = (props, {localize: _}) => (
121122
{label: _('Off'), value: false},
122123
]}
123124
/>
125+
<Radio
126+
label={_('Extended Colors')}
127+
attr="extendtreemapcolors"
128+
options={[
129+
{label: _('On'), value: true},
130+
{label: _('Off'), value: false},
131+
]}
132+
/>
124133
<ColorwayPicker label={_('Colors')} attr="funnelareacolorway" />
125134
<Radio
126135
label={_('Extended Colors')}
@@ -879,6 +888,23 @@ const StyleTracesPanel = (props, {localize: _}) => (
879888
<MultiColorPicker label={_('Line Color')} attr="link.line.color" />
880889
<Numeric label={_('Line Width')} attr="link.line.width" min={0} />
881890
</PlotlySection>
891+
<PlotlySection name={_('Path Bar')} attr="pathbar.visible">
892+
<Radio
893+
attr="pathbar.visible"
894+
options={[
895+
{label: _('Show'), value: true},
896+
{label: _('Hide'), value: false},
897+
]}
898+
/>
899+
<Radio
900+
attr="pathbar.side"
901+
options={[
902+
{label: _('Top'), value: 'top'},
903+
{label: _('Bottom'), value: 'bottom'},
904+
]}
905+
label={_('Side')}
906+
/>
907+
</PlotlySection>
882908
<PlotlySection name={_('Hover/Tooltip')}>
883909
<HoveronDropdown attr="hoveron" label={_('Hover on')} />
884910
<Radio

src/lib/traceTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ export const traceTypes = _ => [
190190
label: _('Sunburst'),
191191
category: chartCategory(_).SPECIALIZED,
192192
},
193+
{
194+
value: 'treemap',
195+
label: _('Treemap'),
196+
category: chartCategory(_).SPECIALIZED,
197+
},
193198
{
194199
value: 'sankey',
195200
label: _('Sankey'),

0 commit comments

Comments
 (0)