This repository has been archived by the owner on Nov 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ex_gantt_chart.py
82 lines (65 loc) · 2.29 KB
/
ex_gantt_chart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""Example Gantt Chart."""
from pathlib import Path
import pandas as pd
from dash import html
from implements import implements
from palettable.wesanderson import FantasticFox2_5
from dash_charts.gantt_chart import GanttChart
from dash_charts.utils_app import AppBase, AppInterface
from dash_charts.utils_fig import min_graph
from dash_charts.utils_helpers import parse_dash_cli_args
@implements(AppInterface) # noqa: H601
class GanttDemo(AppBase):
"""Example creating a Gantt chart."""
name = 'Example Gantt Chart'
"""Application name"""
chart_main = None
"""Main chart (Gantt)."""
id_chart = 'Gantt'
"""Unique name for the main chart."""
def initialization(self) -> None:
"""Initialize ids with `self.register_uniq_ids([...])` and other one-time actions."""
super().initialization()
self.register_uniq_ids([self.id_chart])
def create_elements(self) -> None:
"""Initialize the charts, tables, and other Dash elements."""
self.chart_main = GanttChart(
title='Sample Gantt Chart',
xlabel=None,
ylabel=None,
)
self.chart_main.pallette = FantasticFox2_5.hex_colors
def generate_data(self) -> None:
"""Create self.data_raw with sample data."""
csv_filename = Path(__file__).parent / 'ex_gantt_data.csv'
self.data_raw = pd.read_csv(csv_filename)
def return_layout(self) -> dict:
"""Return Dash application layout.
Returns:
dict: Dash HTML object
"""
return html.Div(
style={
'maxWidth': '1000px',
'marginRight': 'auto',
'marginLeft': 'auto',
}, children=[
html.H4(children=self.name),
html.Div([
min_graph(
id=self._il[self.id_chart],
figure=self.chart_main.create_figure(df_raw=self.data_raw),
),
]),
],
)
def create_callbacks(self) -> None:
"""Create Dash callbacks."""
... # No callbacks necessary for this simple example
instance = GanttDemo
app = instance()
app.create()
if __name__ == '__main__':
app.run(**parse_dash_cli_args())
else:
FLASK_HANDLE = app.get_server()