45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
import sys
|
|
import pandas as pd
|
|
import datetime
|
|
import plotly.express as px
|
|
from dateutil import relativedelta
|
|
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.dates as mdates
|
|
import matplotlib.patches as mpatches
|
|
import mplcursors
|
|
|
|
from matplotlib import rcParams
|
|
from matplotlib.widgets import CheckButtons
|
|
from .settings import (
|
|
TITLE, TITLE_SIZE, TITLE_FONT_WEIGHT,
|
|
FONT_FAMILY, FONT_SANS_SERIF, FONT_COLOR,
|
|
LABEL_SIZE, DAY_FONT_SIZE, MONTH_FONT_SIZE, MONTH_FONT_WEIGHT,
|
|
X_LABEL, Y_LABEL, BAR_COLOR, TEAM_BAR_COLORS, DATE_FORMAT
|
|
)
|
|
from .gant_project import work_packages, deliverables, milestones
|
|
|
|
# style confs
|
|
rcParams['font.family'] = FONT_FAMILY
|
|
rcParams['font.sans-serif'] = FONT_SANS_SERIF
|
|
rcParams['axes.titlesize'] = TITLE_SIZE
|
|
rcParams['axes.labelsize'] = LABEL_SIZE
|
|
|
|
start = datetime.datetime.now()
|
|
|
|
data_frame = pd.DataFrame(reversed([
|
|
{
|
|
'Work Package': f"WP {n+1}",
|
|
'Label': f"WP {n+1}: {elt['title']}",
|
|
'start_date': start + relativedelta.relativedelta(months=elt['start']),
|
|
'end_date': start + \
|
|
relativedelta.relativedelta(months=elt['start']) + \
|
|
relativedelta.relativedelta(months=elt['duration']),
|
|
}
|
|
for n, elt in enumerate(work_packages)
|
|
]))
|
|
fig = px.timeline(data_frame, x_start="start_date", x_end="end_date",
|
|
y="Work Package", color="Label")
|
|
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up
|
|
fig.show()
|