Using the dataset below, build a lease history gantt chart. The X-Axis should be time, with the Y-Axis representing unique "unitName" values. On the gantt chart, each lease is represented by a rectangle, in the row corresponding to the unit. The graph should also highlight the month with the highest aggregated rent.
Please fork this CodePen to submit your result, you may use any HTML/CSS/JS preprocessors or framework you wish.
DO NOT USE A CHARTING/GRAPHING LIBRARY (excluding D3).
- For convenience and elegance, I'm using
$.getJSON
which requires that this code is run using an http server and cannot simply be loaded withfile://
- Much of this code was adapted from the Gantt Chart example from D3
- While working on this, I realized that the example above uses an extension to D3 which may or may not be considered legal for the purposes of this example
- Partway through using this library, I (of course) realized that it lacked a feature I needed, so I forked it to my own Github repository and included it in the GIST through Rawgit
- While implementing the "highest aggregated rent" feature, I made a few observations that lead to slight changes in implementation
- First of all, leases don't necessarily begin on the first of the month, so highlighting the month with the highest aggregated rent doesn't really tell the whole story. Instead, I've implemented a date range during which the total income from current leases is highest. This is not constrained to a month boundary. (though with the given data, it still effectively highlights a month)
- Second, the instructions recommend highlighting the month with the highest aggregated rent, but it's very possible (likely even) that more than one month will have the same aggregate rent. This can happen in both a jointed and disjointed fashion. The implementation I went with finds the maximum amount of rent money being earned at a given time and then highlights all ranges that equal that income.