Add in HorizontalLegend.

Lists entries side-by-side in the available width, after which the
entries wrap onto the next row. If an entry is too wide it is
truncated. If there are too many entries some rows will not be shown.

Close #755.
I think the use of the r variable here can be avoided.  It seems the only use of r is to locate the last row, where a this.rows.length - 1 or so can do.