2023-12-30 14:15:30 +00:00
|
|
|
from chart import Chart
|
|
|
|
from pandas import Series
|
|
|
|
from plotly.graph_objects import Scatter
|
2024-01-01 14:00:09 +00:00
|
|
|
from typing import List
|
2023-12-30 14:15:30 +00:00
|
|
|
|
|
|
|
class LineChart(Chart):
|
|
|
|
|
2024-01-01 14:00:09 +00:00
|
|
|
def __init__(self, x: Series, values: List[Series]):
|
2023-12-30 14:15:30 +00:00
|
|
|
self.x = x
|
2024-01-01 14:00:09 +00:00
|
|
|
self.values = values
|
2023-12-30 14:15:30 +00:00
|
|
|
|
2024-01-01 14:00:09 +00:00
|
|
|
def traces(self) -> List[Scatter]:
|
|
|
|
traces = []
|
|
|
|
for value in self.values:
|
|
|
|
traces.append(Scatter(
|
|
|
|
x = self.x,
|
|
|
|
y = value,
|
|
|
|
mode = 'lines',
|
|
|
|
line=dict(color = 'yellow') # TODO: Make this configurable.
|
|
|
|
))
|
|
|
|
return traces
|