Skip to content

Promote the use of alt.when().then().otherwise() over alt.condition() in the User Guide? #3500

Closed
@joelostblom

Description

@joelostblom

What is your suggestion?

After all the fantastic work of @dangotbanned , we now have alt.when().then().otherwise() as an alternative to alt.condition(condition, if_true, if_false). This new syntax allows for multiple predicates to be specified, which is not possible with alt.condition, looks more idiomatic (in line with our method chaining for encoding channel options), and is similar in length to type to alt.condition (but might be shorter in the future if it becomes possible to pass string literals in an unambiguous manner).

When we introduced the method based syntax for channel options, we updated the docs everywhere and added a note in https://altair-viz.github.io/user_guide/encodings/index.html#channel-options

image

Should we do the same for alt.when().then().otherwise() or are there any reasons to keep alt.condition as the main conditional syntax in the docs?

Have you considered any alternative solutions?

If we keep alt.condition the favored option in the documentation, we should at least add a section on how to use alt.when... in the User Guide.

Regardless of how we decide to update the docs, I think we should also explicitly mention the use of empty inside the conditional, as opposed to in the parameter definition (#3490).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions