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

677 popup api #682

Merged
merged 24 commits into from
May 21, 2019
Merged

677 popup api #682

merged 24 commits into from
May 21, 2019

Conversation

Jesus89
Copy link
Member

@Jesus89 Jesus89 commented May 20, 2019

Related to #677.

output = []
for item in array:
if isinstance(item, str):
name = gen_variable_name(item)

Choose a reason for hiding this comment

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

local variable 'name' is assigned to but never used

"""

def __init__(self, data=None):
self._init_popup(data)

Choose a reason for hiding this comment

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

trailing whitespace

@Jesus89 Jesus89 marked this pull request as ready for review May 21, 2019 11:59
Copy link
Contributor

@rjimenezda rjimenezda left a comment

Choose a reason for hiding this comment

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

Looks good, other than the lack of tests and the formatting which I think we can leave as-is right now

attrs.forEach((item) => {
let value = feature.variables[item.name].value;
if (typeof value === 'number') {
if (Math.abs(value) > 1000) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for now, but we should probably use a proper formatter for this

@Jesus89
Copy link
Member Author

Jesus89 commented May 21, 2019

Tests added / updated.

Copy link
Contributor

@elenatorro elenatorro left a comment

Choose a reason for hiding this comment

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

Just reviewed a couple of typos and a suggestion, the rest looks ✨

popup (dict, :py:class:`Popup <cartoframes.vis.Popup>`, optional):
This option adds interactivity (click and hover) to a layer to show popups.
The columns to be shown must be added in a list format for each event. It
must be written using `CARTL VL expressions syntax
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: using CARTO VL expressions syntax

Args:
data (dict): The popup definition for a layer. It contains the information
to show a popup on 'click' and 'hover' events with the attributes provided
in the definition using the `VL expressions syntax
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: using the CARTO VL expressions syntax (maybe is not a typo, but I wouldn't use only VL)

raise ValueError('Wrong popup input')
return output

def get_variables(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

As a suggestion, I think _get_vars method shouldn't modify the input since it's supposed, by its name, to return some variables. I would do something like:

def _parse_popup_variables(self, variables):
    popup_variables = {}

    # same but using o popup_variables instead of variables and variables instead of array

   return popup_variables
def get_variables(self):
   return self._parse_vars(self._click + self._hover)

Since the values would be overwritten we could use a Set ( return self._parse_vars(list(set(self._click + self._hover)))), but I think this is only available in Python 3.

Copy link
Member Author

Choose a reason for hiding this comment

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

True. This is a nice refactor :)

There is not a problem with repeated variables because each key is related 1:1 with the value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

'v8e0f74': '$name'
})

def test_wrong_attribute(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests!!

Copy link
Contributor

@elenatorro elenatorro left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Jesus89 Jesus89 merged commit fe4c74c into develop May 21, 2019
@Jesus89 Jesus89 deleted the 677-popup-api branch May 21, 2019 15:33
@Jesus89 Jesus89 mentioned this pull request May 21, 2019
3 tasks
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.

4 participants