Package: pytimeline
Pytimelinepytimelineis a command line tool for the creating of SVG timelines from JSON.Note: This is a rewrite of the oldtimeline scriptfrom Jason Reisman and full credits go to him for most of the work.InstallThe package is compatible withPython 3.7+and can be installed in your current environment withpip:python-mpipinstallpytimelineUsageWhen the package is installed in your activated environment, it can be called throughpython -m colorframe.
Detailed usage goes as follows:Usage:python-mpytimeline[OPTIONS]Options:--inputfilePATHPathtotheinputJSONfilewiththetimelinedata.[required]--outputdirDIRECTORYPathtothedirectoryinwhichtowritetheoutputSVGfile.Ifnotprovided,willpickthedirectoryoftheinputfile.--logging[trace|debug|info|warning|error|critical]Setsthelogginglevel.[default:info]--helpShowthismessageandexit.The script will parse your input file and export theSVGdocument in the provided output folder or, if not provided, in the same directory as the input file.One can otherwise import the high-level object from the package and use it directly:frompytimelineimportTimelinetimeline=Timeline(inputfile="your_input.json")timeline.build()timeline.save("timeline.svg")Input Data FormatThe input file is aJSONdocument that describes the start and end points of the timeline, tickmarks along the main axis, as well as callouts to specifc dates/times, and eras which highlight temporal periods.All date fields can be described in several common date formats and may optionally also include a time of day (e.g. "3/14/15 9:26am").
Datetime parsing is handled by thependulumpackage, and one can find all the accepted date formatsin the relevant documentation.Required and Optional FieldsThe required fields arewidth,start, andend.
All other fields are optional.Required:widthdescribes the width, in pixels, of the output SVG document, and the height will be determined automatically.startis the date/time of the leftmost date/time on the axis.endis the date/time of the rightmost date/time on the axis.Optional:num_tickscontols the number of tickmarks along the axis between thestartandenddate/times (inclusive).  If this field is not present, no tickmarks will be generated except for those at thestartandenddates.tick_formatdescribes the string format of the tickmarks along the axis. See thevalid formatsfor thependulumpackage.Special FieldsCalloutsCallouts along the axis are described in thecalloutslist, in which each entry is also a list with two to three string values:The first value is thedescriptionof the callout (e.g., "Pi Day"). It is required.The second value is thedate/timeof the callout (e.g., "3/14/15 9:26am"). It is required.The third value can specify acolorfor the callout, either as a hexcode or a valid SVG color alias. It is optional.Callout examples:["Ultimate Pi Day","3/14/15 9:26am"]Or, with a custom callout color:["Ultimate Pi Day","3/14/15 9:26am","#CD3F85"]ErasEras are highlighted temporal periods and are described in theeraslist.
Like thecalloutslist, each entry in the eras list is itself a list with either three or four string values:The first value is thedescriptionof the era (e.g., "Summer"). It is required.The second value is the startdate/timeof the era (e.g., "6/21/15 12am"). It is required.The third value is the enddate/timeof the era (e.g. "9/20/15 11:59pm"). It is required.The fourth value can specify acolorfor the era, either as a hexcode or a valid SVG color alias. It is optional.Era examples:["Summer 2015","6/21/15 12am","9/20/15 11:59pm"]Or, with a custom era color:["Summer 2015","6/21/15 12am","9/20/15 11:59pm","Orange"]Simple ExampleTheJSONinput for the example timeline at the top of thisREADMEis:{"width":750,"start":"Oct 8 2015","end":"Oct 15 2015","num_ticks":14,"tick_format":"%b %d, %Y - %I:%M%p","callouts":[["ABC easy as 123","Oct 14, 2015 3pm"],["Midnight Event A","12am Oct 10, 2015","#DD0000"],["Noon Event A","12pm Oct 10, 2015"],["5pm Event A","5pm Oct 10, 2015"],["Something amazing happening","Oct 11, 2015"],["Awesome Event B","Oct 12, 2015","#DD0000"],["C","Oct 13, 2015"],["Event E","Oct 14, 2015"]],"eras":[["Era 1","12pm Oct 8, 2015","3am Oct 12, 2015","#CD3F85"],["Era 2","8am Oct 12, 2015","12am Oct 15, 2015","#C0C0FF"]]}