Skip to content

Commit

Permalink
[Bug] Fixed hidden axis labels in px.parallel_coordinates (#941)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
manuelkonrad and pre-commit-ci[bot] authored Jan 8, 2025
1 parent 88f5c7e commit 996e749
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->

### Fixed

- Fix hidden axis and tick labels for Graph components using `px.parallel_coordinates`. ([#941](https://github.com/mckinsey/vizro/pull/941))


<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
21 changes: 17 additions & 4 deletions vizro-core/src/vizro/models/_components/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,23 @@ def _filter_interaction(
@staticmethod
def _optimise_fig_layout_for_dashboard(fig):
"""Post layout updates to visually enhance charts used inside dashboard."""
if fig.layout.title.text:
if fig.layout.margin.t is None:
# Reduce `margin_t` if not explicitly set.
fig.update_layout(margin_t=64)
# Determine if a title is present
has_title = bool(fig.layout.title.text)

# TODO: Check whether we should increase margins for all chart types in template_dashboard_overrides.py instead
if any(isinstance(plotly_obj, go.Parcoords) for plotly_obj in fig.data):
# Avoid hidden labels in Parcoords figures by increasing margins compared to dashboard defaults
fig.update_layout(
margin={
"t": fig.layout.margin.t or (92 if has_title else 40),
"l": fig.layout.margin.l or 36,
"b": fig.layout.margin.b or 24,
},
)

if has_title and fig.layout.margin.t is None:
# Reduce `margin_t` if not explicitly set.
fig.update_layout(margin_t=64)

return fig

Expand Down

0 comments on commit 996e749

Please sign in to comment.