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

fixed bug in hover data #2544

Merged
merged 2 commits into from
Jun 22, 2020
Merged

fixed bug in hover data #2544

merged 2 commits into from
Jun 22, 2020

Conversation

emmanuelle
Copy link
Contributor

Closes #2529

@nicolaskruchten nicolaskruchten added this to the 4.8.2 milestone Jun 8, 2020
if k in args["hover_data"]:
if args["hover_data"][k][0]:
if isinstance(args["hover_data"][k][0], str):
k_args = invert_label(args, k)
Copy link
Contributor

Choose a reason for hiding this comment

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

OK so the problem is that k here is the renamed label? so if labels=dict(a="A") then k would be "A" and we need to find a?

Copy link
Contributor

Choose a reason for hiding this comment

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

might want to add a comment here explaining... it took me 4 tries and 10min to figure this one out :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok :-). Yes, that's what you said.

@nicolaskruchten
Copy link
Contributor

💃 once a changelog entry is added :)

@@ -116,6 +116,14 @@ def get_label(args, column):
return column


def invert_label(args, column):
reversed_labels = {value: key for (key, value) in args["labels"].items()}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works because the default for args["labels"] is set to {} but probably we should use None instead, what do you think @nicolaskruchten ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we should stop using {} as defaults :)

Here btw there's a potential issue if people use the same label for two things... this is a bad idea for a user to do but... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created #2562 to talk about this issue since it already exists before this PR.

@@ -442,6 +446,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
mapping_labels_copy = OrderedDict(mapping_labels)
if args["hover_data"] and isinstance(args["hover_data"], dict):
for k, v in mapping_labels.items():
# We need to invert the mapping here
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# We need to invert the mapping here
# We need to invert the mapping here
# k here is either the column name or remapped from arg["labels"]

@nicolaskruchten
Copy link
Contributor

💃

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.

hover_data formatting don't work if labels is assigned.
2 participants