24 lines
645 B
Python
24 lines
645 B
Python
from chart import Chart
|
|
from line import Line
|
|
from pandas import Series
|
|
from plotly.graph_objects import Scatter
|
|
from typing import List
|
|
|
|
class LineChart(Chart):
|
|
|
|
def __init__(self, x: Series, lines: List[Line], title: str = ''):
|
|
self.x = x
|
|
self.lines = lines
|
|
self.title = title
|
|
|
|
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 |