-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Correct bug when color and values correspond to the same color in treemap or sunburst #2591
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
Changes from 3 commits
f628e94
d2f8b72
31c71fc
ad01147
06b6e08
bc641c2
32432d4
fc8a93f
f896eb4
196bc2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -473,12 +473,16 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref): | |
for k, v in mapping_labels.items(): | ||
# We need to invert the mapping here | ||
k_args = invert_label(args, k) | ||
print(k, k_args, args["hover_data"]) | ||
if k_args in args["hover_data"]: | ||
if args["hover_data"][k_args][0]: | ||
if isinstance(args["hover_data"][k_args][0], str): | ||
mapping_labels_copy[k] = v.replace( | ||
"}", "%s}" % args["hover_data"][k_args][0] | ||
) | ||
formatter = ( | ||
nicolaskruchten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
args["hover_data"][k_args][0] | ||
if isinstance(args["hover_data"][k_args], tuple) | ||
else args["hover_data"][k_args] | ||
) | ||
if formatter: | ||
if isinstance(formatter, str): | ||
mapping_labels_copy[k] = v.replace("}", "%s}" % formatter) | ||
else: | ||
_ = mapping_labels_copy.pop(k) | ||
hover_lines = [k + "=" + v for k, v in mapping_labels_copy.items()] | ||
|
@@ -1499,7 +1503,9 @@ def aggfunc_discrete(x): | |
|
||
if args["color"]: | ||
if args["color"] == args["values"]: | ||
aggfunc_color = "sum" | ||
new_value_col_name = args["values"] + "_total" | ||
df[new_value_col_name] = df[args["values"]] | ||
args["values"] = new_value_col_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so like this, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok let's do |
||
count_colname = args["values"] | ||
else: | ||
# we need a count column for the first groupby and the weighted mean of color | ||
|
@@ -1518,7 +1524,7 @@ def aggfunc_discrete(x): | |
if not _is_continuous(df, args["color"]): | ||
aggfunc_color = aggfunc_discrete | ||
discrete_color = True | ||
elif not aggfunc_color: | ||
else: | ||
|
||
def aggfunc_continuous(x): | ||
return np.average(x, weights=df.loc[x.index, count_colname]) | ||
|
@@ -1576,6 +1582,9 @@ def aggfunc_continuous(x): | |
if args["color"]: | ||
if not args["hover_data"]: | ||
args["hover_data"] = [args["color"]] | ||
elif isinstance(args["hover_data"], dict): | ||
nicolaskruchten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if not args["hover_data"].get(args["color"]): | ||
args["hover_data"][args["color"]] = True | ||
else: | ||
args["hover_data"].append(args["color"]) | ||
return args | ||
|
Uh oh!
There was an error while loading. Please reload this page.