Skip to content

Commit

Permalink
fix(chart): correctly update domain for overlaying axes on off side
Browse files Browse the repository at this point in the history
  • Loading branch information
slaclau committed Nov 7, 2024
1 parent f5f7796 commit f00c64d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/plotly_gtk/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ def _update_positions_and_domains(self):
continue
overlaying_axis = (

Check warning on line 663 in src/plotly_gtk/chart.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/chart.py#L660-L663

Added lines #L660 - L663 were not covered by tests
self.layout[axis]["_overlaying"]
if "_overlaying" in self.layout[axis]
else ""
)
original_overlaying_axis = (

Check warning on line 668 in src/plotly_gtk/chart.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/chart.py#L668

Added line #L668 was not covered by tests
self.layout[axis]["overlaying"][0] + "axis" + self.layout[axis]["overlaying"][1:]

Check failure on line 669 in src/plotly_gtk/chart.py

View workflow job for this annotation

GitHub Actions / lint / reviewdog

[flake8] reported by reviewdog 🐶 line too long (97 > 88 characters) Raw Output: src/plotly_gtk/chart.py:669:89: E501 line too long (97 > 88 characters)
if "overlaying" in self.layout[axis]
else ""
)
Expand All @@ -677,9 +682,11 @@ def _update_positions_and_domains(self):
)
domain = (

Check warning on line 683 in src/plotly_gtk/chart.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/chart.py#L683

Added line #L683 was not covered by tests
self.layout[axis]["domain"]
if "overlaying" not in self.layout[axis] or overlaying_axis == ""
else self.layout[overlaying_axis]["domain"]
if "overlaying" not in self.layout[axis]
or original_overlaying_axis == ""
else self.layout[original_overlaying_axis]["domain"]
)

position = (

Check warning on line 690 in src/plotly_gtk/chart.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/chart.py#L690

Added line #L690 was not covered by tests
self.layout[overlaying_axis]["_position"]
if "autoshift" in self.layout[axis]
Expand Down
26 changes: 19 additions & 7 deletions src/plotly_gtk/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,14 @@ def _get_multiple_axes_test_figure(reference):

fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], name="yaxis data"))

Check warning on line 259 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L259

Added line #L259 was not covered by tests

fig.add_trace(go.Scatter(x=[2, 3, 4], y=[40, 50, 60], name="yaxis2 data", yaxis="y2"))
fig.add_trace(

Check warning on line 261 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L261

Added line #L261 was not covered by tests
go.Scatter(x=[2, 3, 4], y=[40, 50, 60], name="yaxis2 data", yaxis="y2")
)

fig.add_trace(

Check warning on line 265 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L265

Added line #L265 was not covered by tests
go.Scatter(x=[4, 5, 6], y=[1000, 2000, 3000], name="yaxis3 data", yaxis="y3")
go.Scatter(
x=[4, 5, 6], y=[1000, 2000, 3000], name="yaxis3 data", yaxis="y3"
)
)

fig.add_trace(

Check warning on line 271 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L271

Added line #L271 was not covered by tests
Expand All @@ -278,7 +282,9 @@ def _get_multiple_axes_test_figure(reference):
overlaying="y",
side="right",
),
yaxis3=dict(title="yaxis3 title", anchor="free", overlaying="y", autoshift=True),
yaxis3=dict(
title="yaxis3 title", anchor="free", overlaying="y", autoshift=True
),
yaxis4=dict(
title="yaxis4 title",
anchor="free",
Expand All @@ -295,10 +301,14 @@ def _get_multiple_axes_test_figure(reference):

fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], name="yaxis data"))

Check warning on line 302 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L302

Added line #L302 was not covered by tests

fig.add_trace(go.Scatter(x=[2, 3, 4], y=[40, 50, 60], name="yaxis2 data", yaxis="y2"))
fig.add_trace(

Check warning on line 304 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L304

Added line #L304 was not covered by tests
go.Scatter(x=[2, 3, 4], y=[40, 50, 60], name="yaxis2 data", yaxis="y2")
)

fig.add_trace(

Check warning on line 308 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L308

Added line #L308 was not covered by tests
go.Scatter(x=[4, 5, 6], y=[1000, 2000, 3000], name="yaxis3 data", yaxis="y3")
go.Scatter(
x=[4, 5, 6], y=[1000, 2000, 3000], name="yaxis3 data", yaxis="y3"
)
)

fig.add_trace(

Check warning on line 314 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L314

Added line #L314 was not covered by tests
Expand All @@ -315,7 +325,9 @@ def _get_multiple_axes_test_figure(reference):
overlaying="y",
side="right",
),
yaxis3=dict(title="yaxis3 title", anchor="free", overlaying="y", autoshift=True),
yaxis3=dict(
title="yaxis3 title", anchor="free", overlaying="y", autoshift=True
),
yaxis4=dict(
title="yaxis4 title",
anchor="free",
Expand All @@ -338,7 +350,7 @@ def test(app):
paned = Gtk.Paned()
window.set_content(paned)

fig = get_test_figure("shift_by_pixels")
fig = get_test_figure("multiple_y_axes_subplots")

Check warning on line 353 in src/plotly_gtk/demo.py

View check run for this annotation

Codecov / codecov/patch

src/plotly_gtk/demo.py#L353

Added line #L353 was not covered by tests
print(fig)
# print(fig["layout"]["template"])

Expand Down

0 comments on commit f00c64d

Please sign in to comment.