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

[BugFix] Bar Chart Fixes #6667

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ def bar_chart( # noqa: PLR0912

bar_df = data.copy().set_index(x) # type: ignore
y = y.split(",") if isinstance(y, str) else y

hovertemplate = bar_kwargs.pop("hovertemplate", None)
width = bar_kwargs.pop("width", None)
for item in y:
figure.add_bar(
x=bar_df.index if orientation == "v" else bar_df[item],
Expand All @@ -436,11 +437,19 @@ def bar_chart( # noqa: PLR0912
legendgroup=bar_df[item].name,
orientation=orientation,
hovertemplate=(
"%{fullData.name}:%{y}<extra></extra>"
if orientation == "v"
else "%{fullData.name}:%{x}<extra></extra>"
hovertemplate
if hovertemplate
else (
"%{fullData.name}:%{y}<extra></extra>"
if orientation == "v"
else "%{fullData.name}:%{x}<extra></extra>"
)
),
width=(
width
if width
else 0.95 / len(y) * 0.75 if barmode == "group" and len(y) > 1 else 0.95
),
width=0.95 / len(y) * 0.75 if barmode == "group" and len(y) > 1 else 0.95,
**bar_kwargs,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,19 +925,6 @@ def show( # noqa: PLR0915
if data.get("layout", {}):
pio.show(data, *args, **kwargs)

self.update_layout(
legend=dict(
orientation=(
"v"
if not self.layout.legend.orientation
else self.layout.legend.orientation
),
),
barmode="overlay",
bargap=0,
bargroupgap=0,
)

return pio.show(self, *args, **kwargs)

def _xaxis_tickformatstops(self) -> None:
Expand Down
Loading