Skip to content

Introducing plotly.js + Mapbox GL #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jun 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
70856b2
introducing the 'mapbox' base plot module
etpinard Jun 10, 2016
3968417
introducting the 'scattermapbox' trace module
etpinard Jun 10, 2016
3648744
add 'mapbox' to layout attributes
etpinard Jun 10, 2016
6254578
make sure that non-svg plot types go through calc on restyle,
etpinard Jun 10, 2016
6a73378
handle mapbox.layers relayouts
etpinard Jun 10, 2016
3e79f0d
add 'pretest' tasks,
etpinard Jun 10, 2016
3ea7436
set mapbox crendentials in test dashboard and image test index
etpinard Jun 10, 2016
3b2c2e2
run pretest on circleci,
etpinard Jun 10, 2016
a47704c
tmp commit: register scattermapbox in main index file,
etpinard Jun 10, 2016
f300d27
add test jasmine for the mapbox base plot module
etpinard Jun 10, 2016
9255ca1
add tests for the scattermapbox trace module
etpinard Jun 10, 2016
b6e4734
exclude mapbox jasmine tests on CircleCI,
etpinard Jun 10, 2016
7167a9f
add mapbox image tests
etpinard Jun 10, 2016
7af55ea
skip mapbox mocks on CircleCI,
etpinard Jun 10, 2016
911e872
clean up update steps upon layer creation
etpinard Jun 13, 2016
a4a9100
improve description for pitch and bearing
etpinard Jun 13, 2016
28125a4
simplify purge layer step
etpinard Jun 13, 2016
2d6db7b
add 'mapbox.layers' to list of _isLinkedAtoArray attr to check
etpinard Jun 13, 2016
d99bfd5
make convert handle bubble with text case:
etpinard Jun 13, 2016
d2fe7f4
clear navigation container on map creation:
etpinard Jun 13, 2016
dceaece
Revert "tmp commit: register scattermapbox in main index file,"
etpinard Jun 13, 2016
fc34488
add scattermapbox trace module to lib/
etpinard Jun 13, 2016
4f2812d
register 'scattermapbox' in jasmine suite that rely on it
etpinard Jun 13, 2016
df77966
skip over mapbox image mock (for now),
etpinard Jun 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/traces/scattermapbox/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module.exports = function convert(calcTrace) {
hasLines = subTypes.hasLines(trace),
hasMarkers = subTypes.hasMarkers(trace),
hasText = subTypes.hasText(trace),
hasCircles = (hasMarkers && trace.marker.symbol === 'circle');
hasCircles = (hasMarkers && trace.marker.symbol === 'circle'),
hasSymbols = (hasMarkers && trace.marker.symbol !== 'circle');

var fill = initContainer(),
line = initContainer(),
Expand Down Expand Up @@ -84,7 +85,7 @@ module.exports = function convert(calcTrace) {
});
}

if(!hasCircles || hasText) {
if(hasSymbols || hasText) {
symbol.geojson = makeSymbolGeoJSON(calcTrace);

Lib.extendFlat(symbol.layout, {
Expand All @@ -93,7 +94,7 @@ module.exports = function convert(calcTrace) {
'text-field': '{text}'
});

if(hasMarkers) {
if(hasSymbols) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriddyp this should fix the console errors we were seeing on Friday.

Lib.extendFlat(symbol.layout, {
'icon-size': trace.marker.size / 10
});
Expand Down Expand Up @@ -314,8 +315,9 @@ function calcTextOpts(trace) {

// ballpack values
var ms = (trace.marker || {}).size,
xInc = 0.5 + (ms / 15),
yInc = 1.5 + (ms / 15);
factor = Array.isArray(ms) ? Lib.mean(ms) : ms,
xInc = 0.5 + (factor / 100),
yInc = 1.5 + (factor / 100);

var anchorVals = ['', ''],
offset = [0, 0];
Expand Down
Binary file added test/image/baselines/mapbox_bubbles-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_symbol-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions test/image/mocks/mapbox_bubbles-text.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"data": [
{
"type": "scattermapbox",
"mode": "markers+lines+text",
"lon": [
10,
20,
30
],
"lat": [
10,
20,
30
],
"marker": {
"size": [
10,
30,
20
],
"color": [
"red",
"green",
"blue"
]
},
"text": [
"A",
"B",
"C"
],
"textposition": "top left",
"textfont": {
"size": 20,
"color": "red"
}
}
],
"layout": {
"mapbox": {
"style": "light",
"zoom": 2.5,
"center": {
"lon": 19.5,
"lat": 22
}
},
"width": 700,
"height": 450
}
}
16 changes: 8 additions & 8 deletions test/jasmine/tests/scattermapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ describe('scattermapbox convert', function() {

it('should correctly convert \'textposition\' to \'text-anchor\' and \'text-offset\'', function() {
var specs = {
'top left': ['top-right', [-1.5, -2.5]],
'top center': ['top', [0, -2.5]],
'top right': ['top-left', [1.5, -2.5]],
'middle left': ['right', [-1.5, 0]],
'top left': ['top-right', [-0.65, -1.65]],
'top center': ['top', [0, -1.65]],
'top right': ['top-left', [0.65, -1.65]],
'middle left': ['right', [-0.65, 0]],
'middle center': ['center', [0, 0]],
'middle right': ['left', [1.5, 0]],
'bottom left': ['bottom-right', [-1.5, 2.5]],
'bottom center': ['bottom', [0, 2.5]],
'bottom right': ['bottom-left', [1.5, 2.5]]
'middle right': ['left', [0.65, 0]],
'bottom left': ['bottom-right', [-0.65, 1.65]],
'bottom center': ['bottom', [0, 1.65]],
'bottom right': ['bottom-left', [0.65, 1.65]]
};

Object.keys(specs).forEach(function(k) {
Expand Down