Generate dygraph graph legend on server.

Dygraph legend does not have all the options we need -- generate the legend in the template instead.