mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
add trace labels space
This commit is contained in:
15
frontend-components/plotly/src/App.tsx
vendored
15
frontend-components/plotly/src/App.tsx
vendored
@@ -71,7 +71,20 @@ function App() {
|
||||
}
|
||||
});
|
||||
}
|
||||
let title = data.layout?.title?.text;
|
||||
|
||||
// We add spaces to all trace names, due to Fira Code font width issues
|
||||
// to make sure that the legend is not cut off
|
||||
data.data.forEach(function (trace) {
|
||||
if (trace.name != undefined) {
|
||||
const name_length = trace.name.length;
|
||||
trace.name = trace.name + " ";
|
||||
trace.hoverlabel = {
|
||||
namelength: name_length,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
let title = data.layout?.title?.text || "Interactive Chart";
|
||||
globals.title = title;
|
||||
return {
|
||||
data: data,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { hideModebar } from "./PlotlyConfig";
|
||||
export default async function ResizeHandler({
|
||||
plotData,
|
||||
volumeBars,
|
||||
setMaximizePlot
|
||||
setMaximizePlot,
|
||||
}: {
|
||||
plotData: Figure;
|
||||
volumeBars: any;
|
||||
@@ -14,7 +14,11 @@ export default async function ResizeHandler({
|
||||
// We hide the modebar and set the number of ticks to 5
|
||||
const XAXIS = Object.keys(plotData.layout)
|
||||
.filter((x) => x.startsWith("xaxis"))
|
||||
.filter((x) => plotData.layout[x].showticklabels);
|
||||
.filter(
|
||||
(x) =>
|
||||
plotData.layout[x].showticklabels ||
|
||||
plotData.layout[x].matches == undefined
|
||||
);
|
||||
|
||||
const TRACES = plotData.data.filter((trace) =>
|
||||
trace?.name?.startsWith("Volume")
|
||||
@@ -29,7 +33,7 @@ export default async function ResizeHandler({
|
||||
height > 420 && width < 920 ? 8 : height > 420 && width < 500 ? 9 : 7;
|
||||
|
||||
if (width < 750) {
|
||||
// We hide the modebar and set the number of ticks to 5
|
||||
// We hide the modebar and set the number of ticks to 6
|
||||
|
||||
TRACES.forEach((trace) => {
|
||||
if (trace.type == "bar") {
|
||||
@@ -44,8 +48,9 @@ export default async function ResizeHandler({
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
XAXIS.forEach((x) => {
|
||||
if (volume.old_nticks?.[x] == undefined) {
|
||||
if (volumeBars.old_nticks?.[x] == undefined) {
|
||||
layout_update[x + ".nticks"] = 6;
|
||||
volume.old_nticks[x] = plotData.layout[x].nticks || 10;
|
||||
}
|
||||
@@ -60,7 +65,7 @@ export default async function ResizeHandler({
|
||||
|
||||
if (volumeBars.old_nticks != undefined) {
|
||||
XAXIS.forEach((x) => {
|
||||
if (volume.old_nticks[x] != undefined) {
|
||||
if (volumeBars.old_nticks[x] != undefined) {
|
||||
layout_update[x + ".nticks"] = volume.old_nticks[x];
|
||||
volume.old_nticks[x] = undefined;
|
||||
}
|
||||
|
||||
@@ -188,18 +188,6 @@ class Backend(PyWry):
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
142
openbb_terminal/core/plots/plotly.html
vendored
142
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