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

Introducing plotly.js + Mapbox GL #626

merged 24 commits into from
Jun 13, 2016

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Jun 10, 2016

Have you ever asked yourself: wouldn't it be great to plot Mapbox GL maps with the plotly.js API?

Well, this PR will make your day! 🎉

In more details, this PR adds one new plot type (fittingly named mapbox) and one new trace type scattermapbox to plotly.js.

IMPORTANT: This PR won't make scattermapbox part of our official plotly.js dist bundle. The scattermapbox trace type will only be available through custom bundling, similar to heatmapgl and contourgl. Why? See Testing issues below.

Features

  • Image export 🎉
  • Support markers, lines and text scatter modes
  • Support for toself fills.
  • Support for lines with connectgaps true or false
  • Support for default and custom mapbox styles
  • Streaming 🚐
  • Bubble maps. That is, array (or data-driven as Mapbox like to call it) for maker.color and marker.size when circle marker.symbol.
  • Symbol maps (example) with array symbol for marker.symbol
  • Arbitrary geojson and vector layers can be added to maps
  • Hover text, based on the same to-closest-point algorithm as our cartesian graphs
  • Full restyle, relayout and extendTraces support
  • Multiple maps per plot and mixing mapbox maps with any of our other plot types

Limitations

  • No line.dash support. I ran into some issues on restyle. I think it is an issue with mapbox-gl. Further investigation is needed.
  • No marker.line styling options. mapbox-gl doesn't natively support them. I think it's worth waiting for them instead of hacking something in.
  • No locations as an alternatively to lon / lat coordinates like in scattergeo.
  • Limited arrayOk support, as mentioned in the features section.

Testing issues

I ran into some issues while attempting to run our image tests with the new mapbox mocks on CircleCI. Moreover, our jasmine test runner currently can't create WebGL context on CircleCI (see #241 for more info). So, this leaves this our mapbox integration code untested on CircleCI for now. The tests are working fine on my laptop.

etpinard added 14 commits June 10, 2016 15:43
- N.B. 'docalc' is more conservative then 'doplot'
- that setups build files containing mapbox crendentials
  so that test runners can load them seamlessly.
- note that a MAPBOX_ACCESS_TOKEN env variable has
  been set on the CircleCI plotly.js project.
- this commit will be remove before the first release as
  some mapbox cannot be tested on CircleCI yet.
- as FF launched by karma can't create a webgl context on CircleCI.
- as mapbox toImage blows the image generation queue.
- note that generating image one-by-one on CircleCI works fine
  but very slowly.
@etpinard
Copy link
Contributor Author

Not much existing code is touched by this PR.

If you're wondering why, you might want to have a look at PRs #491 , #554 and #575 .

@mdtusz
Copy link
Contributor

mdtusz commented Jun 10, 2016

🎉 Will start reviewing this asap!

@etpinard
Copy link
Contributor Author

In plotly.js terms, mapbox subplots are much more deeply integrated than geo subplots. Namely, they make full use of gd.calcdata and the reuse the cartesian hover routine.

@@ -87,6 +87,9 @@ module.exports = {
// URL to topojson files used in geo charts
topojsonURL: 'https://cdn.plot.ly/',

// Mapbox access token (required to plot mapbox trace types)
mapboxAccessToken: null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

N.B. an important distinction for mapbox subplots.


// remove empty trace objects
var ids = Object.keys(traceHash);
id_loop:
Copy link
Contributor

@mdtusz mdtusz Jun 13, 2016

Choose a reason for hiding this comment

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

🐄 I've never been a big fan of this - doesn't seem to be necessary in this instance either.

Edit: Nvm I see why. Still not a fan of it though 😑

description: [
'Sets the pitch angle of the map',
'(in degrees, where *0* means perpendicular to the surface of the map).'
].join(' ')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

- also tweak factor for cleaner look
- add bubble with text image test
@@ -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.

@mdtusz
Copy link
Contributor

mdtusz commented Jun 13, 2016

Great tests! I'm gonna say 💃 on this one - there's small things we can improve on and fixup along the way, but let's get it in quick for @jackparmer!

✨ clean!

@jackparmer
Copy link
Contributor

💥 🚢 !

@etpinard etpinard merged commit de65c44 into master Jun 13, 2016
@etpinard etpinard deleted the mapbox branch June 13, 2016 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants