mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
fix no figure title text
This commit is contained in:
6
frontend-components/plotly/src/App.tsx
vendored
6
frontend-components/plotly/src/App.tsx
vendored
@@ -54,12 +54,6 @@ function App() {
|
||||
let time = new Date().toISOString().slice(11, 19).replace(/:/g, "");
|
||||
window.title = `openbb_${filename}_${date}_${time}`;
|
||||
|
||||
let extension = "";
|
||||
if (window.export_image != undefined) {
|
||||
filename = window.export_image.split("/").pop();
|
||||
extension = filename.split(".").pop().replace("jpg", "jpeg");
|
||||
}
|
||||
|
||||
if (data.layout.annotations != undefined) {
|
||||
data.layout.annotations.forEach(function (annotation) {
|
||||
if (annotation.text != undefined)
|
||||
|
||||
@@ -42,7 +42,9 @@ export default function Chart({
|
||||
|
||||
delete json.layout.width;
|
||||
delete json.layout.height;
|
||||
json.layout.title.text = "";
|
||||
if (json.layout?.title?.text) {
|
||||
json.layout.title.text = "";
|
||||
}
|
||||
|
||||
const [barButtons, setModeBarButtons] = useState({});
|
||||
const [LogYaxis, setLogYaxis] = useState(false);
|
||||
|
||||
@@ -186,6 +186,24 @@ class Backend(PyWry):
|
||||
# pylint: disable=C0415
|
||||
from openbb_terminal.helper_funcs import command_location
|
||||
|
||||
title = "Interactive Chart"
|
||||
|
||||
# We check if figure is a subplot and has a title annotation
|
||||
if not fig.layout.title.text and fig._has_subplots(): # pylint: disable=W0212
|
||||
for annotation in fig.select_annotations(
|
||||
selector=dict(xref="paper", yref="paper")
|
||||
):
|
||||
# Subplots always set the first annotation as the title
|
||||
# so we break after the first one
|
||||
if annotation.text:
|
||||
title = annotation.text
|
||||
annotation.text = ""
|
||||
break
|
||||
|
||||
fig.layout.title.text = re.sub(
|
||||
r"<[^>]*>", "", fig.layout.title.text if fig.layout.title.text else title
|
||||
)
|
||||
|
||||
fig.layout.height += 69
|
||||
|
||||
if export_image and isinstance(export_image, str):
|
||||
|
||||
170
openbb_terminal/core/plots/plotly.html
vendored
170
openbb_terminal/core/plots/plotly.html
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user