Skip to content

Commit

Permalink
bar chart fixes (#6667)
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone authored Sep 15, 2024
1 parent d9ebf73 commit 77e22cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
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

0 comments on commit 77e22cc

Please sign in to comment.