HistoricalTimeline documentation#
- class historical_timelines.HistoricalTimeline(title: str = '')#
- add_event(event: HistoricalEvent) None#
Add a singular event
- Args:
event (HistoricalEvent): The event to be added
- add_events(events: list[historical_timelines.event.HistoricalEvent]) None#
Add a list of events
- Args:
events (list[HistoricalEvent]): A list of events to be added
- collision_sort() list[list[historical_timelines.event.HistoricalEvent]]#
Generates lists of subsets of periods such that no periods overlap
- Returns:
list[list[HistoricalEvent]]: A list of a list of non overlapping periods
- create_event_dict(label_max_line_width: int = 10) dict[str, list]#
Create a dictionary that describes events to help with graphics
- Args:
label_max_line_width (int, optional): The maximum line width for labels. Defaults to 10.
- Returns:
dict[str, list]: An event dict for the graphics generator
- create_period_list(label_max_line_width: int = 10) list[dict]#
Create a list of periods that can be turned into a timeline image
- Args:
label_max_line_width (int, optional): The maximum line width for labels. Defaults to 10.
- Returns:
list[dict]: A list of dictionaries that can be turned into a timeline image
- static json_from_csv(path: str, title_name: str = 'title', description_name: str = 'description', label_name: str = 'label', start_name: str = 'start', end_name: str = 'end', csv_era: Era = Era.CE) list[dict]#
Create a json from a csv that can be used to populate a timeline
This is the function that allows you to take a csv and turn it into a timeline object. The output can be used as an input for populate_timeline_from_dict.
- Args:
path (str): The path to the csv title_name (str, optional): THe name of the title column. Defaults to “title”. description_name (str, optional): The name of the description column. Defaults to “description”. label_name (str, optional): The name of the label column. Defaults to “label”. start_name (str, optional): The name of the start date column. Defaults to “start”. end_name (str, optional): The name of the end date column. Defaults to “end”. csv_era (Era, optional): Which era the timeline is in (CE or BCE). Defaults to Era.CE.
- Returns:
list[dict]: A json that can be used to populate a timeline
- populate_random_timeline(N: int = 10, sort: bool = True) None#
Populate the timeline with random events
- Args:
N (int, optional): The number of events to populate the timeline with. Defaults to 10. sort (bool, optional): Whether or not to sort the timeline after populating it. Defaults to True.
- populate_timeline_from_dict(timeline_dict: list, sort: bool = True) None#
Populate a timeline from from an array of timeline compatible dictionaries
- Args:
timeline_dict (list): An array of timeline compatible objects sort (bool, optional): Whether or not to sort the timeline after populating. Defaults to True.
- render_timeline(output: str, show_timeline: bool = False) None#
Render the timeline as an image
- Args:
output (str): The output filename show_timeline (bool): Whether to show the timeline rather than saving it
- sort()#
Sorts the timeline