Refactor out graph legend view into a chart component

Pie charts and histograms will need these.