Skip to content

Gantt Chart

Render to a Gantt chart

matplotlib

Call the :func:render_gantt_matplotlib to render the solution as a Gantt chart. The time line is from 0 to horizon value, you can choose to render either Task or Resource (default).

def render_gantt_matplotlib(
    solution: SchedulingSolution,
    fig_size: Optional[Tuple[int, int]] = (9, 6),
    show_plot: Optional[bool] = True,
    show_indicators: Optional[bool] = True,
    render_mode: Optional[str] = "Resource",
    fig_filename: Optional[str] = None,
)
solution = solver.solve()
if solution is not None:
    solution.render_gantt_matplotlib()  # default render_mode is 'Resource'
    # a second gantt chart, in 'Task' mode
    solution.render_gantt_matplotlib(render_mode='Task')

plotly

Note

Be sure plotly is installed.

def render_gantt_plotly(
    solution: SchedulingSolution,
    fig_size: Optional[Tuple[int, int]] = None,
    show_plot: Optional[bool] = True,
    show_indicators: Optional[bool] = True,
    render_mode: Optional[str] = "Resource",
    sort: Optional[str] = None,
    fig_filename: Optional[str] = None,
    html_filename: Optional[str] = None,
) -> None:

Call the ps.render_gantt_plotly to render the solution as a Gantt chart using plotly.

Warning

Take care that plotly rendering needs real timepoints (set at least delta_time at the problem creation).

sol = solver.solve()
if sol is not None:
    # default render_mode is 'Resource'
    ps.render_gantt_plotly(solution=sol, sort="Start", html_filename="index.html")
    # a second gantt chart, in 'Task' mode
    ps.render_gantt_plotly(solution=sol, render_mode='Task')