Skip to content

Commit ee9eed9

Browse files
Merge pull request #903 from plotly/choropleth-text
Choropleth text
2 parents e2fb6a1 + eed5751 commit ee9eed9

File tree

7 files changed

+92
-31
lines changed

7 files changed

+92
-31
lines changed

dev/mocks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"/percy/waterfall.json",
1111
"/percy/sunburst.json",
1212
"/percy/sankey.json",
13+
"/percy/choropleth.json",
1314
"0.json",
1415
"1.json",
1516
"10.json",

dev/percy/choropleth.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"data": [
3+
{
4+
"zmax": 1000,
5+
"colorscale": "RdBu",
6+
"zmin": -1000,
7+
"locations": [
8+
"AGO",
9+
"ALB",
10+
"ARE"
11+
],
12+
"locationssrc": "x1",
13+
"z": [
14+
-639.491311425916,
15+
21.2123434330386,
16+
-179.388449582104
17+
],
18+
"zsrc": "x1",
19+
"text": [
20+
"AGO",
21+
"ALB",
22+
"ARE"
23+
],
24+
"textsrc": "x1",
25+
"type": "choropleth",
26+
"zauto": false,
27+
"hoverinfo": "text"
28+
}
29+
],
30+
"layout": {
31+
"autosize": true,
32+
"showlegend": false,
33+
"geo": {
34+
"showcountries": true,
35+
"showocean": true,
36+
"showland": true,
37+
"showlakes": true,
38+
"showrivers": true
39+
}
40+
},
41+
"frames": []
42+
}

dev/percy/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ 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 choropleth} from './choropleth.json';

src/__stories__/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const panelsToTest = {
2727
waterfall: ['GraphCreatePanel', 'StyleTracesPanel'],
2828
sunburst: ['GraphCreatePanel', 'StyleTracesPanel'],
2929
sankey: ['GraphCreatePanel', 'StyleTracesPanel'],
30+
choropleth: ['GraphCreatePanel', 'GraphSubplotsPanel', 'StyleTracesPanel'],
3031
};
3132

3233
window.URL.createObjectURL = function() {

src/default_panels/StyleLayoutPanel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ const StyleLayoutPanel = (props, {localize: _}) => (
144144
</PlotlySection>
145145
<PlotlySection name={_('Hover')}>
146146
<HovermodeDropdown label={_('Mode')} attr="hovermode">
147+
<Dropdown
148+
label={_('Text Alignment')}
149+
attr="hoverlabel.align"
150+
options={[
151+
{label: _('Auto'), value: 'auto'},
152+
{label: _('Left'), value: 'left'},
153+
{label: _('Right'), value: 'right'},
154+
]}
155+
clearable={false}
156+
/>
147157
<HoverColor
148158
label={_('Background Color')}
149159
attr="hoverlabel.bgcolor"

src/default_panels/StyleTracesPanel.js

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ import {
4646
HoveronDropdown,
4747
LevelRendered,
4848
} from '../components/fields/derived';
49+
import {traceTypes} from 'lib/traceTypes';
50+
import localize from 'lib/localize';
51+
52+
const allTraceTypes = traceTypes(localize).map(({value}) => value);
4953

5054
const StyleTracesPanel = (props, {localize: _}) => (
5155
<TraceAccordion canGroup>
@@ -435,12 +439,19 @@ const StyleTracesPanel = (props, {localize: _}) => (
435439
'scatterternary',
436440
'scatterpolar',
437441
'scatterpolargl',
442+
'box',
443+
'violin',
438444
'scatter3d',
439445
'scattergl',
440446
'scattergeo',
447+
'parcoords',
448+
'parcats',
441449
'scattermapbox',
442-
'box',
443-
'violin',
450+
'scattercarpet',
451+
'contourcarpet',
452+
'ohlc',
453+
'candlestick',
454+
'histogram2dcontour',
444455
]}
445456
mode="trace"
446457
>
@@ -477,21 +488,19 @@ const StyleTracesPanel = (props, {localize: _}) => (
477488
</PlotlySection>
478489
<TraceTypeSection
479490
name={_('Text')}
480-
traceTypes={[
481-
'scatter',
482-
'scattergl',
483-
'scatterpolar',
484-
'scatterpolargl',
485-
'barpolar',
486-
'pie',
487-
'scatter3d',
488-
'scatterternary',
489-
'bar',
490-
'scattergeo',
491-
'scattermapbox',
492-
'sunburst',
493-
'waterfall',
494-
]}
491+
traceTypes={allTraceTypes.filter(
492+
t =>
493+
![
494+
'histogram2d',
495+
'histogram2dcontour',
496+
'parcoords',
497+
'parcats',
498+
'sankey',
499+
'table',
500+
'scattercarpet',
501+
'carpet',
502+
].includes(t)
503+
)}
495504
mode="trace"
496505
>
497506
<DataSelector label={_('Text')} attr="text" />
@@ -738,6 +747,16 @@ const StyleTracesPanel = (props, {localize: _}) => (
738747
<MultiColorPicker label={_('Contour Color')} attr="contour.color" />
739748
<Numeric label={_('Contour Width')} attr="contour.width" />
740749
</VisibilitySelect>
750+
<Dropdown
751+
label={_('Text Alignment')}
752+
attr="hoverlabel.align"
753+
options={[
754+
{label: _('Auto'), value: 'auto'},
755+
{label: _('Left'), value: 'left'},
756+
{label: _('Right'), value: 'right'},
757+
]}
758+
clearable={false}
759+
/>
741760
<Text label={_('Value Format')} attr="valueformat" />
742761
<Text label={_('Value Suffix')} attr="valuesuffix" />
743762
</PlotlySection>

src/lib/constants.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,4 @@ export const COLORS = {
142142
black: '#000000',
143143
};
144144

145-
export const DEFAULT_COLORS = [
146-
COLORS.charcoal,
147-
COLORS.white,
148-
COLORS.mutedBlue,
149-
COLORS.safetyOrange,
150-
COLORS.cookedAsparagusGreen,
151-
COLORS.brickRed,
152-
COLORS.mutedPurple,
153-
COLORS.chestnutBrown,
154-
COLORS.raspberryYogurtPink,
155-
COLORS.middleGray,
156-
COLORS.curryYellowGreen,
157-
COLORS.blueTeal,
158-
];
145+
export const DEFAULT_COLORS = Object.values(COLORS);

0 commit comments

Comments
 (0)