Skip to content

Be able to order legend items when using GroupBy Legend [FEATURE] #9135

Description

@arturomoncadatorres

Ordering legend items can be done very easily by reordering the elements of p.legend. However, when using a GroupBy Legend, this isn't so straightforward, since the order is computed on the JS side, which can lead to lengthy and manual workarounds.

It would be great if the GroupBy Legends could also be ordered using the same syntax as for non-GroupBy ones.

Activity

  1. bryevdv commented on Aug 3, 2019

    @bryevdv
    Member

    @bokeh/dev what do you think about deprecating legend kwarg for glyph methods (it is a little too magic in some ways) and having some more explicit (mutually exclusive) options:

    • legend_label="foo" always creates a single legend item and always with that text as a label
    • legend_field="foo" sets a "field" for client-side grouping on column "foo" in BokehJS
    • legend_group="foo" does a Python side grouping on column "foo" and creates multiple legend items with appropriate indices values

    For the last I think there should be API for it so the items could easily be updated in a Bokeh server app callback. But the main point is that there are definitely cases when it's preferable to do the grouping in python, and that's currently very hard. And there are cases when people don't want grouping in JS but they get it when it's not expected. So this idea would be to disentangle all those cases more clearly.

    To be clear I would leave legend in place for a long time (with a warning message). Also maybe there is better names. The cases I'd like to distinguish:

    • just a label, as-is
    • group on the JS side
    • group on the Python side
  2. added this to the milestone on Aug 3, 2019
  3. birdsarah commented on Aug 6, 2019

    @birdsarah
    Member

    This seems great. Obviously a long deprecation cycle for legend kwarg, but yes, the ability to be more specific seems very appropriate and your API suggestions seem intuitive and compact. That said, I haven't done a lot of legend work in a while and don't feel like I have a deep feeling for the API currently.

  4. modified the milestones: , 1.4 on Aug 11, 2019
  5. github-actions commented on Oct 27, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  6. locked as resolved and limited conversation to collaborators on Oct 27, 2024
  7. added theissue type on Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions