divyanksingh / svg_generator Goto Github PK
View Code? Open in Web Editor NEWBackground: A network monitoring tool collects data regarding whether different systems are running. One view of the data shows a timeline, to visualize the system's status over time. Green means that the status was OK and red means that the system had a problem. This view is called a trend graph. The collected data is saved to a list with events in chronological order. Each event contains a point in time (timestamp) and the system's status (True=OK or False=not OK). In most cases, only a few events are recorded, since most systems have the same state for a long time. However, in some cases, the state can change often which results in hundreds of thousands events. Task The programming task is to visualize the trend graph as a SVG image, given a number of events. Input data: Test data is available in the attached text file testdata_small.txt Each line in the file has the following format: Timestamp True\False True means that the system is OK until the next event False means that the system has a problem until the next event. Timestamp is a unix time stamp (seconds since 1970-01-01 00:00:00 UTC Example: 1429002861 False 1429002965 True 1429002978 False Desired output: The program shall process the input data and generate a SVG with rect elements. Each rect element shall be green or red, depending on the state of the system. The size of the SVG shall be 500x50 pixels. The leftmost position (x=0) is the starting time and the rightmost position (x=500) is the end time. Each rectangle shall fill the entire height of the graph, from top to bottom.