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

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

arturomoncadatorres opened this issue Aug 1, 2019 · 2 comments · Fixed by #9235

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

arturomoncadatorres opened this issue Aug 1, 2019 · 2 comments · Fixed by #9235


Copy link

@arturomoncadatorres arturomoncadatorres commented Aug 1, 2019

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.

Copy link

@bryevdv bryevdv commented Aug 3, 2019

@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

Copy link

@birdsarah birdsarah commented Aug 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants