Skip to content
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

carto vl legends #527

Merged
merged 5 commits into from
Jan 9, 2019
Merged

carto vl legends #527

merged 5 commits into from
Jan 9, 2019

Conversation

andy-esch
Copy link
Contributor

@andy-esch andy-esch commented Jan 9, 2019

Adds CARTO VL legends for color ramps and places them in an airship container. If a layer does not have a ramp then the legend and container do not appear. If a category map is created, no legend will appear.

Example

layers = [
    vector.Layer('all_month_3',
                 color='ramp(globalquantiles($mag), antique)',
                 size=20,
                 strokeWidth=0,
                 interactivity={'cols': ['mag', ], 'event': 'click'},
                 legend='Earthquakes'),
    vector.Layer('brooklyn_poverty',
                 color='ramp(globalquantiles($poverty_per_pop, 5), mint)',
                 strokeWidth=0,
                 legend='Brooklyn Poverty'),
    vector.Layer('brooklyn_poverty',
                 color='ramp(globalquantiles($poverty_per_pop, 5), prism)',
                 strokeWidth=0,
                 legend='Brooklyn Poverty 2'),
    vector.LocalLayer(data2,
                      color='ramp(globalquantiles($poverty_per_pop, 7), oryel)',
                      legend='Local Layer')
]
vector.vmap(
    layers,
    context=cc,
    basemap=vector.BaseMaps.darkmatter,
    size=(1024, 512)
)

Output:

screen shot 2019-01-09 at 1 54 09 pm

Future work

  • add category legends
  • legends on continuous variables (e.g., ramp($var, mint)) where there are not discrete breaks
  • Make content responsive in airship so that smaller widths have legends as a separate tab
  • Make layers selectable using checkboxes or clicking on the header
  • Optionally add layer color for non-ramp layers. e.g., if there are two distinct point layers, show a color for each layer with a description next to them so they are identifiable

cc @rochoa

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

7 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 97.716% when pulling 5432edc on carto-vl-legends into d10ceac on master.

@andy-esch andy-esch merged commit e754b2d into master Jan 9, 2019
@andy-esch andy-esch deleted the carto-vl-legends branch January 9, 2019 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants