tidying up javascript to generate chart data
moving hovered over to selected as clicking on the bar chart is more intentional