plotting/line_chart.py

24 lines
645 B
Python
Raw Normal View History

2023-12-30 14:15:30 +00:00
from chart import Chart
from line import Line
2023-12-30 14:15:30 +00:00
from pandas import Series
from plotly.graph_objects import Scatter
from typing import List
2023-12-30 14:15:30 +00:00
class LineChart(Chart):
def __init__(self, x: Series, lines: List[Line], title: str = ''):
2023-12-30 14:15:30 +00:00
self.x = x
self.lines = lines
2024-01-03 14:32:29 +00:00
self.title = title
2023-12-30 14:15:30 +00:00
def traces(self) -> List[Scatter]:
traces = []
for line in self.lines:
traces.append(Scatter(
x = self.x,
y = line.values,
mode = 'lines',
name = line.name,
line = dict(color = line.color)
))
return traces