32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from chart import Chart
|
|
from plotly.graph_objects import Figure
|
|
from plotly.subplots import make_subplots
|
|
from typing import List
|
|
|
|
def figure_with_subplots(subplots: List[List[Chart]]) -> Figure:
|
|
num_rows = len(subplots)
|
|
num_columns = len(subplots[0])
|
|
|
|
figure = make_subplots(rows = num_rows, cols = num_columns)
|
|
|
|
for i, row in enumerate(subplots, start = 1):
|
|
for j, chart in enumerate(row, start = 1):
|
|
figure.add_trace(chart.trace(), row = i, col = j)
|
|
figure.update_xaxes(showgrid = False, showticklabels = True, rangeslider = dict(visible = False), row = i, col = j)
|
|
figure.update_yaxes(showgrid = False, side = 'right', row = i, col = j)
|
|
|
|
# TODO: Make this configurable.
|
|
figure.update_layout(
|
|
paper_bgcolor = '#0f0f0f',
|
|
plot_bgcolor = '#0f0f0f',
|
|
font_color = '#7a7c7d',
|
|
showlegend = False,
|
|
margin = dict(
|
|
pad = 15
|
|
)
|
|
)
|
|
|
|
return figure
|
|
|
|
def plot(chart: Chart) -> None:
|
|
figure_with_subplots([[chart]]).show(config={'displayModeBar': False}) |