Fixed the off-by-one issue with chart legend. Also some JavaScript autoformating, apparently