fix no figure title text

This commit is contained in:
teh_coderer
2023-05-03 17:22:46 -04:00
parent 62ee6d6b4b
commit c19713cd3b
4 changed files with 106 additions and 92 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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):

File diff suppressed because one or more lines are too long