Skip to content

Commit 7f9e8e2

Browse files
basic support for no-token mapbox
1 parent 87e4c5d commit 7f9e8e2

File tree

9 files changed

+85
-25
lines changed

9 files changed

+85
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"fast-isnumeric": "^1.1.2",
1616
"immutability-helper": "^3.0.0",
1717
"plotly-icons": "1.3.12",
18-
"plotly.js": "1.48.3",
18+
"plotly.js": "1.49.4",
1919
"prop-types": "^15.7.2",
2020
"raf": "^3.4.1",
2121
"react-color": "^2.17.0",

src/EditorControls.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
shamefullyDeleteRelatedAnalysisTransforms,
1919
shamefullyAdjustSizeref,
2020
shamefullyAdjustAxisDirection,
21+
shamefullyAdjustMapbox,
2122
} from './shame';
2223
import {EDITOR_ACTIONS} from './lib/constants';
2324
import isNumeric from 'fast-isnumeric';
@@ -87,6 +88,9 @@ class EditorControls extends Component {
8788
shamefullyAdjustAxisRef(graphDiv, payload);
8889
shamefullyAddTableColumns(graphDiv, payload);
8990
shamefullyAdjustSplitStyleTargetContainers(graphDiv, payload);
91+
if (!this.props.mapBoxAccess) {
92+
shamefullyAdjustMapbox(graphDiv, payload);
93+
}
9094

9195
for (let i = 0; i < payload.traceIndexes.length; i++) {
9296
for (const attr in payload.update) {

src/components/fields/derived.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,14 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
574574
} else if (container.lat || container.lon) {
575575
options = [{label: _('Longitude'), value: 'lon'}, {label: _('Latitude'), value: 'lat'}];
576576
}
577-
} else if (container.type === 'scattermapbox') {
577+
} else if (container.type === 'scattermapbox' || container.type === 'densitymapbox') {
578578
options = [{label: _('Longitude'), value: 'lon'}, {label: _('Latitude'), value: 'lat'}];
579+
} else if (container.type === 'densitymapbox') {
580+
options = [
581+
{label: _('Longitude'), value: 'lon'},
582+
{label: _('Latitude'), value: 'lat'},
583+
{label: _('Z'), value: 'z'},
584+
];
579585
} else if (container.type === 'scatterternary') {
580586
options = [
581587
{label: _('A'), value: 'a'},
@@ -655,6 +661,34 @@ export const FillDropdown = connectToContainer(UnconnectedDropdown, {
655661
},
656662
});
657663

664+
export const MapboxStyleDropdown = connectToContainer(UnconnectedDropdown, {
665+
modifyPlotProps: (props, context, plotProps) => {
666+
const {mapBoxAccess, localize: _} = context;
667+
668+
plotProps.options = [
669+
{label: _('No tiles (white background)'), value: 'white-bg'},
670+
{label: _('Open Street Map'), value: 'open-street-map'},
671+
{label: _('Carto Positron'), value: 'carto-positron'},
672+
{label: _('Carto Dark Matter'), value: 'carto-darkmatter'},
673+
{label: _('Stamen Terrain'), value: 'stamen-terrain'},
674+
{label: _('Stamen Toner'), value: 'stamen-toner'},
675+
{label: _('Stamen Watercolor'), value: 'stamen-watercolor'},
676+
].concat(
677+
!mapBoxAccess
678+
? []
679+
: [
680+
{label: _('Mapbox Basic'), value: 'basic'},
681+
{label: _('Mapbox Outdoors'), value: 'outdoors'},
682+
{label: _('Mapbox Light'), value: 'light'},
683+
{label: _('Mapbox Dark'), value: 'dark'},
684+
{label: _('Mapbox Satellite'), value: 'satellite'},
685+
{label: _('Mapbox Satellite with Streets'), value: 'satellite-streets'},
686+
]
687+
);
688+
plotProps.clearable = false;
689+
},
690+
});
691+
658692
export const HoveronDropdown = connectToContainer(UnconnectedDropdown, {
659693
modifyPlotProps: (props, context, plotProps) => {
660694
const {localize: _} = context;

src/components/widgets/TraceTypeSelector.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,16 @@ class TraceTypeSelector extends Component {
137137

138138
renderCategories() {
139139
const {fullValue} = this.props;
140-
const {mapBoxAccess, localize: _, chartHelp} = this.context;
140+
const {localize: _, chartHelp} = this.context;
141141
const {
142142
traceTypesConfig: {traces, categories, complex},
143143
} = this.props;
144144

145145
return categories(_).map((category, i) => {
146-
let items = traces(_)
146+
const items = traces(_)
147147
.filter(({category: {value}}) => value === category.value)
148148
.filter(i => i.value !== 'scattergl' && i.value !== 'scatterpolargl');
149149

150-
if (!mapBoxAccess) {
151-
items = items.filter(i => i.value !== 'scattermapbox');
152-
}
153-
154150
const MAX_ITEMS = 4;
155151

156152
const columnClasses =

src/default_panels/GraphCreatePanel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TraceSelector,
1212
TraceTypeSection,
1313
LocationSelector,
14+
Numeric,
1415
} from '../components';
1516
import {
1617
HistogramInfoVertical,
@@ -68,6 +69,7 @@ const GraphCreatePanel = (props, {localize: _, setPanel}) => {
6869
}}
6970
attr="z"
7071
/>
72+
<Numeric label={_('Radius')} attr="radius" min={0} max={50} showSlider />
7173
<DataSelector label={_('Measure')} attr="measure" />
7274

7375
<PlotlySection name={_('Nodes')}>

src/default_panels/StyleMapsPanel.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@ import {
1111

1212
const StyleMapsPanel = (props, {localize: _}) => (
1313
<SubplotAccordion>
14-
<PlotlySection name={_('Map Style')} attr="style">
14+
<PlotlySection name={_('Base Map')} attr="style">
1515
<Dropdown
16-
label={_('Mapbox Style')}
16+
label={_('Tiles')}
1717
attr="style"
1818
options={[
19-
{label: _('Basic'), value: 'basic'},
20-
{label: _('Outdoors'), value: 'outdoors'},
21-
{label: _('Light'), value: 'light'},
22-
{label: _('Dark'), value: 'dark'},
23-
{label: _('Satellite'), value: 'satellite'},
24-
{label: _('Satellite with Streets'), value: 'satellite-streets'},
19+
{label: _('No tiles (white background)'), value: 'white-bg'},
20+
{label: _('Open Street Map'), value: 'open-street-map'},
21+
{label: _('Carto Positron'), value: 'carto-positron'},
22+
{label: _('Carto Dark Matter'), value: 'carto-darkmatter'},
23+
{label: _('Stamen Terrain'), value: 'stamen-terrain'},
24+
{label: _('Stamen Toner'), value: 'stamen-toner'},
25+
{label: _('Stamen Watercolor'), value: 'stamen-watercolor'},
26+
{label: _('Mapbox Basic'), value: 'basic'},
27+
{label: _('Mapbox Outdoors'), value: 'outdoors'},
28+
{label: _('Mapbox Light'), value: 'light'},
29+
{label: _('Mapbox Dark'), value: 'dark'},
30+
{label: _('Mapbox Satellite'), value: 'satellite'},
31+
{label: _('Mapbox Satellite with Streets'), value: 'satellite-streets'},
2532
]}
2633
clearable={false}
2734
/>

src/lib/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const TRACE_TO_AXIS = {
7878
ternary: ['scatterternary'],
7979
gl3d: ['scatter3d', 'surface', 'mesh3d', 'cone', 'streamtube'],
8080
geo: ['scattergeo', 'choropleth'],
81-
mapbox: ['scattermapbox'],
81+
mapbox: ['scattermapbox', 'choroplethmapbox', 'densitymapbox'],
8282
polar: ['scatterpolar', 'scatterpolargl', 'barpolar'],
8383
};
8484

@@ -104,8 +104,8 @@ export const subplotName = (type, _) =>
104104
ternary: _('Ternary'),
105105
gl3d: _('Scene'),
106106
scene: _('Scene'),
107-
geo: _('Geo'),
108-
mapbox: _('Mapbox'),
107+
geo: _('Map'),
108+
mapbox: _('Tile Map'),
109109
polar: _('Polar'),
110110
}[type]);
111111

src/lib/traceTypes.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,31 @@ export const traceTypes = _ => [
145145
label: _('2D Contour Histogram'),
146146
category: chartCategory(_).DISTRIBUTIONS,
147147
},
148-
{
149-
value: 'choropleth',
150-
label: _('Choropleth'),
151-
category: chartCategory(_).MAPS,
152-
},
153148
{
154149
value: 'scattermapbox',
155-
label: _('Satellite Map'),
150+
label: _('Tile Map'),
156151
category: chartCategory(_).MAPS,
157152
},
158153
{
159154
value: 'scattergeo',
160155
label: _('Atlas Map'),
161156
category: chartCategory(_).MAPS,
162157
},
158+
{
159+
value: 'choroplethmapbox',
160+
label: _('Choropleth Tile Map'),
161+
category: chartCategory(_).MAPS,
162+
},
163+
{
164+
value: 'choropleth',
165+
label: _('Choropleth Atlas Map'),
166+
category: chartCategory(_).MAPS,
167+
},
168+
{
169+
value: 'densitymapbox',
170+
label: _('Density Tile Map'),
171+
category: chartCategory(_).MAPS,
172+
},
163173
{
164174
value: 'scatterpolar',
165175
label: _('Polar Scatter'),

src/shame.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ export const shamefullyAdjustGeo = ({layout}, {update}) => {
8989
});
9090
};
9191

92+
export const shamefullyAdjustMapbox = gd => {
93+
if (gd.layout && gd.layout.mapbox && gd.layout.mapbox.style) {
94+
return;
95+
}
96+
nestedProperty(gd.layout, 'mapbox.style').set('open-street-map');
97+
};
98+
9299
export const shamefullyAddTableColumns = (graphDiv, {traceIndexes, update}) => {
93100
if (
94101
update['cells.values'] &&

0 commit comments

Comments
 (0)