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

Add viz default helpers #1432

Merged
merged 18 commits into from
Jan 10, 2020
Merged

Add viz default helpers #1432

merged 18 commits into from
Jan 10, 2020

Conversation

Jesus89
Copy link
Member

@Jesus89 Jesus89 commented Dec 31, 2019

Closes #1430

PoC implementation of default values and default helpers.

# Layer with default style

Layer(
    'population'
)


# Layer with custom style: legend and hover enabled by default

Layer(
    'population',
    color_bins_style('pop_max')
)


# Layer with default UI components enabled
# It uses "pop_max" as the default title for Legend, Widget and Popup

Layer(
    'population',
    color_bins_style('pop_max'),
    default_legend=True,
    default_widget=True,
    default_popup_hover=True,
    default_popup_click=True
)


# Layer with default UI components enabled with custom title
# It uses "Max population" as the default title for Legend, Widget and Popup

Layer(
    'population',
    color_bins_style('pop_max'),
    default_legend=True,
    default_widget=True,
    default_popup_hover=True,
    default_popup_click=True,
    title='Max population'
)


# Layer with default UI components enabled with custom content

Layer(
    'population',
    color_bins_style('pop_max'),
    legends=default_legend('Legend title', 'Legend description', 'Legend footer'),
    widgets=default_widget('Widget title', 'Widget description', 'Widget footer'),
    popup_hover=default_popup_element('Popup title (Hover)'),
    popup_click=default_popup_element('Popup title (Click)')
)


# Layer with default + new UI components

Layer(
    'population',
    color_bins_style('pop_max'),
    legends=[default_legend('Legend title', 'Legend description', 'Legend footer'), basic_legend('Title', 'description', 'footer')],
    widgets=[default_widget('Widget title', 'Widget description', 'Widget footer') histogram_widget('cartodb_id', 'CARTODB ID')],
    popup_hover=[default_popup_element('Popup title (Hover)'), popup_element('cartodb_id', 'CARTODB ID')]
    popup_click=[default_popup_element('Popup title (Click)'), popup_element('cartodb_id', 'CARTODB ID')]
)

@makella
Copy link
Contributor

makella commented Jan 7, 2020

I'm still trying to understand how the components are loaded as part of a style while at the same time not part of the style but that's my own thing to sort through!

Here are some comments/questions after taking a look through:

  • Shouldn't we also have a default_style? I guess that is the basic_style but to keep consistent, should that be renamed?

  • How do I easily change the title of the hover that is available with the style? Finding this confusing and unless I also define the attribute (basically recreating the hover popup from scratch ). default_popup=(title='my title') for instance seemed the logical way with the other patterns, but this isn't working for me. This is what worked:

Layer(
    'eng_wales_pop', 
    color_bins_style('pop_sq_km'),
    default_legend(title='Legend'),
    default_widget(title='Distribution'),
    popup_element('pop_sq_km', title='Value')
)

There seem to be a couple of different ways to do this, so maybe I am missing something! I also don't really understand why things like widgets=True works even though something like default_widget=True doesn't work but default_widget is what I use to customize the widget I get when I use widgets=True. I get that behind the scenes it is widgets=default_widget(...) but as you can see, I'm still getting my head around it!

  • Related, in help(Layer) it says that you only get a hover popup with a style but if I set both hover_popup and/or click_popup to True, I get both.

  • Regarding the default titles
    Suggestion here is to give more meaningful titles to each component by default, not just the widget:

    • set legend title to "Legend"
    • set hover title to "Value"
    • set widget title to "Categories" / "Distribution"

Example category:
Screen Shot 2020-01-07 at 2 09 41 PM

Example numeric:
Screen Shot 2020-01-07 at 2 19 06 PM

I'm gonna keep working with this new stuff to understand it better..
thanks!

@Jesus89
Copy link
Member Author

Jesus89 commented Jan 9, 2020

Hi 👋, I have updated the ticket description with the changes from the last meeting.

@elenatorro
Copy link
Contributor

Note: update examples cc @Jesus89

@Jesus89
Copy link
Member Author

Jesus89 commented Jan 9, 2020

I have added an example in the PR to test this: examples/_debug/viz-flow.

@elenatorro
Copy link
Contributor

As we've talked, after this is ready for merge let's add it and review doc related stuff in this issue #1419

@Jesus89 Jesus89 marked this pull request as ready for review January 10, 2020 08:58
@Jesus89 Jesus89 requested a review from elenatorro January 10, 2020 09:50
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 3ef1a87 into develop Jan 10, 2020
@Jesus89 Jesus89 deleted the 1430-add-viz-default-config branch January 10, 2020 10:08
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.

Add defaults to visualization API
3 participants