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

Legend API #693

Closed
4 tasks done
Jesus89 opened this issue May 23, 2019 · 4 comments
Closed
4 tasks done

Legend API #693

Jesus89 opened this issue May 23, 2019 · 4 comments
Assignees

Comments

@Jesus89
Copy link
Member

Jesus89 commented May 23, 2019

  • Create Legend class (+doc) / Review Legend API (naming)
from cartoframes.viz import Legend

Legend({
    'title': '...',
    'description': '...'
})

Types:

color-category
color-bins
color-continuous
size-bins
size-continuous

Properties: 'color', 'strokeColor'

from cartoframes.viz import Legend

Legend({
    'type': '...',
    'prop': '...',
    'title': '...',
    'description': '...',
    'footer': '...'
})

The type of the legend could be different for each geometry type:

from cartoframes.viz import Legend

Legend({
    'type': {
        'point': '...',
        'line': '...',
        'polygon': '...',
    },
    'property': '...'
})
  • Review default legend (False)
  • Template naming refactor
  • Unify legend/popup format
@andy-esch
Copy link
Contributor

About the Legend API, why not keyword args instead of a dict? That way we can still pass a dict as Legend(**legend_dict)

@Jesus89
Copy link
Member Author

Jesus89 commented May 27, 2019

We are following the same structure in this class as in the rest of viz classes. For example, this is a layer using all the classes:

Map(
    Layer(
        Source('populated_places'),
        style=Style('color: blue'),
        popup=Popup({
            'hover': '$name',
            'click': '$pop_max'
        }),
        legend=Legend({
            'type': 'color-category',
            'prop': 'color'
        })
    )
)

But the point is that the sugar API does not need the class instantiation so you can do:

Map(
    Layer(
        'populated_places',
        style='color: blue',
        popup={
            'hover': '$name',
            'click': '$pop_max'
        },
        legend={
            'type': 'color-category',
            'prop': 'color'
        }
    )
)

Since this is the simplest API, it will be most used one, and in this case, it is not possible to use args as params.

@andy-esch
Copy link
Contributor

👍 Makes sense

@Jesus89 Jesus89 mentioned this issue May 29, 2019
@Jesus89
Copy link
Member Author

Jesus89 commented May 30, 2019

Closed via #712

@Jesus89 Jesus89 closed this as completed May 30, 2019
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

No branches or pull requests

2 participants