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

[🐛 BUG] Default go.Figure title position overridden to center by dark mode theme #2274

Closed
1 of 7 tasks
arcanaxion opened this issue Nov 23, 2024 · 3 comments · Fixed by #2282
Closed
1 of 7 tasks
Assignees
Labels
GUI: Front-End 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon

Comments

@arcanaxion
Copy link

arcanaxion commented Nov 23, 2024

What went wrong? 🤔

I have created a plotly figure with a title without specifying the title position. When I switch taipy to dark mode, the figure's theme is updated (which is great) but the title is undesirably centered.

Expected Behavior

Title position should be consistent between modes.

Steps to Reproduce Issue

import taipy.gui.builder as tgb
from taipy.gui import Gui
import pandas as pd
import plotly.express as px


df = pd.DataFrame({"x": range(1000)})
df["y"] = df["x"] ** 3

fig = px.line(df, x="x", y="y", title="Chart title")
# fig.update_layout(title=dict(text="Chart title", x=0, xanchor="left", xref="paper"))  # This is a workaround


with tgb.Page() as page:
    tgb.toggle(theme=True)
    tgb.text("# Chart title in dark mode", mode="md")
    with tgb.layout(columns="1 1", gap="1em"):
        with tgb.part():
            tgb.chart(figure="{fig}")
        with tgb.part():
            tgb.chart("{df}", x="x", y="y", layout={"title": "Chart title"}, mode="lines")


Gui(page).run(dark_mode=False)

Screenshots

  1. Left chart: go.Figure
  2. Right chart: Taipy syntax

Light mode:
image

Dark mode:
image

Title in the left chart was centered when switching to dark mode.

Browsers

Chrome, Firefox

OS

Windows, Linux

Version of Taipy

4.0.1

Acceptance Criteria

  • A unit test reproducing the bug is added.
  • Any new code is covered by a unit tested.
  • Check code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@arcanaxion arcanaxion added the 💥Malfunction Addresses an identified problem. label Nov 23, 2024
@FredLL-Avaiga
Copy link
Member

I didn't see any title positioning rule in the dark template used for plotly

export const darkThemeTemplate = {

@arcanaxion
Copy link
Author

@FredLL-Avaiga

The default python plotly template is setting the title position:

> import plotly.io as pio
> pio.templates["plotly"]["layout"]["title"]
layout.Title({
    'x': 0.05
})

Might it be a good solution to nested merge fig.layout.template with the dark mode template and apply it?

@FredLL-Avaiga
Copy link
Member

Good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: Front-End 💥Malfunction Addresses an identified problem. 🟧 Priority: High Must be addressed as soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants