fix margin in API chart output to Workspace (#7164)

This commit is contained in:
Danglewood
2025-07-07 22:15:44 -07:00
committed by GitHub
parent bd70423989
commit 471ed0bc2f

View File

@@ -1178,10 +1178,12 @@ class OpenBBFigure(go.Figure):
kwargs.update(
dict(
config={
"displayModeBar": False,
"edits": {
"colorbarPosition": True,
"legendPosition": True,
},
"scrollZoom": True,
"displaylogo": False,
"editable": True,
"displayModeBar": "hover",
},
include_plotlyjs=kwargs.pop("include_plotlyjs", False),
full_html=False,
@@ -1224,18 +1226,28 @@ class OpenBBFigure(go.Figure):
def to_plotly_json(self) -> dict:
"""Serialize, then deserialize, the figure to JSON. Returns as a Python dictionary."""
fig = json.loads(self.to_json())
if "t" in self.layout.margin and (
self.layout.margin["t"] is None or (self.layout.margin["t"] < 50)
):
self.layout.margin["t"] = 50
fig = super().to_json() or "{}"
fig = json.loads(fig)
fig.update(
{
"config": {
"displayModeBar": "hover",
"displaylogo": False,
"editable": True,
"displayModeBar": False,
"edits": {
"colorbarPosition": True,
"legendPosition": True,
},
"scrollZoom": True,
}
}
)
return fig
@staticmethod